diff --git a/homeassistant/components/totalconnect/alarm_control_panel.py b/homeassistant/components/totalconnect/alarm_control_panel.py index b255132a365..2ab06e2f6bd 100644 --- a/homeassistant/components/totalconnect/alarm_control_panel.py +++ b/homeassistant/components/totalconnect/alarm_control_panel.py @@ -18,7 +18,7 @@ from homeassistant.const import ( STATE_ALARM_TRIGGERED, ) -from . import DOMAIN as TOTALCONNECT_DOMAIN +from .const import DOMAIN _LOGGER = logging.getLogger(__name__) @@ -30,7 +30,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): alarms = [] - client = hass.data[TOTALCONNECT_DOMAIN].client + client = hass.data[DOMAIN].client for location_id, location in client.locations.items(): location_name = location.location_name @@ -71,7 +71,7 @@ class TotalConnectAlarm(alarm.AlarmControlPanel): def update(self): """Return the state of the device.""" - status = self._client.get_armed_status(self._location_id) + self._client.get_armed_status(self._location_id) attr = { "location_name": self._name, "location_id": self._location_id, @@ -79,47 +79,36 @@ class TotalConnectAlarm(alarm.AlarmControlPanel): "low_battery": self._client.locations[self._location_id].low_battery, "cover_tampered": self._client.locations[ self._location_id - ].is_cover_tampered, + ].is_cover_tampered(), "triggered_source": None, "triggered_zone": None, } - if status in (self._client.DISARMED, self._client.DISARMED_BYPASS): + if self._client.locations[self._location_id].is_disarmed(): state = STATE_ALARM_DISARMED - elif status in ( - self._client.ARMED_STAY, - self._client.ARMED_STAY_INSTANT, - self._client.ARMED_STAY_INSTANT_BYPASS, - ): + elif self._client.locations[self._location_id].is_armed_home(): state = STATE_ALARM_ARMED_HOME - elif status == self._client.ARMED_STAY_NIGHT: + elif self._client.locations[self._location_id].is_armed_night(): state = STATE_ALARM_ARMED_NIGHT - elif status in ( - self._client.ARMED_AWAY, - self._client.ARMED_AWAY_BYPASS, - self._client.ARMED_AWAY_INSTANT, - self._client.ARMED_AWAY_INSTANT_BYPASS, - ): + elif self._client.locations[self._location_id].is_armed_away(): state = STATE_ALARM_ARMED_AWAY - elif status == self._client.ARMED_CUSTOM_BYPASS: + elif self._client.locations[self._location_id].is_armed_custom_bypass(): state = STATE_ALARM_ARMED_CUSTOM_BYPASS - elif status == self._client.ARMING: + elif self._client.locations[self._location_id].is_arming(): state = STATE_ALARM_ARMING - elif status == self._client.DISARMING: + elif self._client.locations[self._location_id].is_disarming(): state = STATE_ALARM_DISARMING - elif status == self._client.ALARMING: + elif self._client.locations[self._location_id].is_triggered_police(): state = STATE_ALARM_TRIGGERED attr["triggered_source"] = "Police/Medical" - elif status == self._client.ALARMING_FIRE_SMOKE: + elif self._client.locations[self._location_id].is_triggered_fire(): state = STATE_ALARM_TRIGGERED attr["triggered_source"] = "Fire/Smoke" - elif status == self._client.ALARMING_CARBON_MONOXIDE: + elif self._client.locations[self._location_id].is_triggered_gas(): state = STATE_ALARM_TRIGGERED attr["triggered_source"] = "Carbon Monoxide" else: - logging.info( - "Total Connect Client returned unknown status code: %s", status - ) + logging.info("Total Connect Client returned unknown status") state = None self._state = state diff --git a/homeassistant/components/totalconnect/const.py b/homeassistant/components/totalconnect/const.py new file mode 100644 index 00000000000..6c19bf0a217 --- /dev/null +++ b/homeassistant/components/totalconnect/const.py @@ -0,0 +1,3 @@ +"""TotalConnect constants.""" + +DOMAIN = "totalconnect"