Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -35,8 +35,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
device_type = device.device_type
|
||||
for sensor_type in SENSOR_TYPES:
|
||||
if device_type.get("name") in sensor_type[3]:
|
||||
devices.append(CanarySensor(data, sensor_type,
|
||||
location, device))
|
||||
devices.append(
|
||||
CanarySensor(data, sensor_type, location, device)
|
||||
)
|
||||
|
||||
add_entities(devices, True)
|
||||
|
||||
|
@ -52,9 +53,7 @@ class CanarySensor(Entity):
|
|||
self._sensor_value = None
|
||||
|
||||
sensor_type_name = sensor_type[0].replace("_", " ").title()
|
||||
self._name = '{} {} {}'.format(location.name,
|
||||
device.name,
|
||||
sensor_type_name)
|
||||
self._name = "{} {} {}".format(location.name, device.name, sensor_type_name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -87,19 +86,16 @@ class CanarySensor(Entity):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
if self._sensor_type[0] == "air_quality" \
|
||||
and self._sensor_value is not None:
|
||||
if self._sensor_type[0] == "air_quality" and self._sensor_value is not None:
|
||||
air_quality = None
|
||||
if self._sensor_value <= .4:
|
||||
if self._sensor_value <= 0.4:
|
||||
air_quality = STATE_AIR_QUALITY_VERY_ABNORMAL
|
||||
elif self._sensor_value <= .59:
|
||||
elif self._sensor_value <= 0.59:
|
||||
air_quality = STATE_AIR_QUALITY_ABNORMAL
|
||||
elif self._sensor_value <= 1.0:
|
||||
air_quality = STATE_AIR_QUALITY_NORMAL
|
||||
|
||||
return {
|
||||
ATTR_AIR_QUALITY: air_quality
|
||||
}
|
||||
return {ATTR_AIR_QUALITY: air_quality}
|
||||
|
||||
return None
|
||||
|
||||
|
@ -108,6 +104,7 @@ class CanarySensor(Entity):
|
|||
self._data.update()
|
||||
|
||||
from canary.api import SensorType
|
||||
|
||||
canary_sensor_type = None
|
||||
if self._sensor_type[0] == "air_quality":
|
||||
canary_sensor_type = SensorType.AIR_QUALITY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue