Fix issue #23758 - Restore Canary sensors and ensure alarm con… (#32627)

* Fixed missing Canary sensors and Canary alarm control panel that was not updating correctly

* Resolved pylinting warnings in original tests
This commit is contained in:
chiefdragon authored and GitHub committed 2020-03-11 11:58:42 -07:00
1 parent d28d1ff657
commit 3e8728ad5f
3 files changed
+55 -48

No files matched your search

@@ -49,7 +49,6 @@ class CanaryAlarm(AlarmControlPanel):
@property
def state(self):
"""Return the state of the device."""
location = self._data.get_location(self._location_id)
if location.is_private:
@@ -82,15 +81,16 @@ class CanaryAlarm(AlarmControlPanel):
def alarm_arm_home(self, code=None):
"""Send arm home command."""
self._data.set_location_mode(self._location_id, LOCATION_MODE_HOME)
def alarm_arm_away(self, code=None):
"""Send arm away command."""
self._data.set_location_mode(self._location_id, LOCATION_MODE_AWAY)
def alarm_arm_night(self, code=None):
"""Send arm night command."""
self._data.set_location_mode(self._location_id, LOCATION_MODE_NIGHT)
def update(self):
"""Get the latest state of the sensor."""
self._data.update()
+12 -5
View File
@@ -10,14 +10,21 @@ from . import DATA_CANARY
SENSOR_VALUE_PRECISION = 2
ATTR_AIR_QUALITY = "air_quality"
# Define variables to store the device names, as referred to by the Canary API.
# Note: If Canary change the name of any of their devices (which they have done),
# then these variables will need updating, otherwise the sensors will stop working
# and disappear in Home Assistant.
CANARY_PRO = "Canary Pro"
CANARY_FLEX = "Canary Flex"
# Sensor types are defined like so:
# sensor type name, unit_of_measurement, icon
SENSOR_TYPES = [
["temperature", TEMP_CELSIUS, "mdi:thermometer", ["Canary"]],
["humidity", UNIT_PERCENTAGE, "mdi:water-percent", ["Canary"]],
["air_quality", None, "mdi:weather-windy", ["Canary"]],
["wifi", "dBm", "mdi:wifi", ["Canary Flex"]],
["battery", UNIT_PERCENTAGE, "mdi:battery-50", ["Canary Flex"]],
["temperature", TEMP_CELSIUS, "mdi:thermometer", [CANARY_PRO]],
["humidity", UNIT_PERCENTAGE, "mdi:water-percent", [CANARY_PRO]],
["air_quality", None, "mdi:weather-windy", [CANARY_PRO]],
["wifi", "dBm", "mdi:wifi", [CANARY_FLEX]],
["battery", UNIT_PERCENTAGE, "mdi:battery-50", [CANARY_FLEX]],
]
STATE_AIR_QUALITY_NORMAL = "normal"