From 12d59797a7fac96859970134463cd6491743649e Mon Sep 17 00:00:00 2001 From: Austin Mroczek Date: Sat, 1 Jun 2019 13:12:58 -0700 Subject: [PATCH] Add details to triggered state for total connect alarms (#24106) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() --- .../totalconnect/alarm_control_panel.py | 24 ++++++++++++++++--- .../components/totalconnect/manifest.json | 2 +- requirements_all.txt | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/totalconnect/alarm_control_panel.py b/homeassistant/components/totalconnect/alarm_control_panel.py index 848202d6ce1..6d4c7a9671a 100644 --- a/homeassistant/components/totalconnect/alarm_control_panel.py +++ b/homeassistant/components/totalconnect/alarm_control_panel.py @@ -9,9 +9,8 @@ from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA from homeassistant.const import ( CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED, - STATE_ALARM_ARMING, STATE_ALARM_DISARMING, CONF_NAME, - STATE_ALARM_ARMED_CUSTOM_BYPASS) - + STATE_ALARM_ARMING, STATE_ALARM_DISARMING, STATE_ALARM_TRIGGERED, + CONF_NAME, STATE_ALARM_ARMED_CUSTOM_BYPASS) _LOGGER = logging.getLogger(__name__) @@ -46,6 +45,7 @@ class TotalConnect(alarm.AlarmControlPanel): self._username = username self._password = password self._state = None + self._device_state_attributes = {} self._client = TotalConnectClient.TotalConnectClient( username, password) @@ -59,9 +59,15 @@ class TotalConnect(alarm.AlarmControlPanel): """Return the state of the device.""" return self._state + @property + def device_state_attributes(self): + """Return the state attributes of the device.""" + return self._device_state_attributes + def update(self): """Return the state of the device.""" status = self._client.get_armed_status() + attr = {'triggered_source': None, 'triggered_zone': None} if status == self._client.DISARMED: state = STATE_ALARM_DISARMED @@ -77,10 +83,22 @@ class TotalConnect(alarm.AlarmControlPanel): state = STATE_ALARM_ARMING elif status == self._client.DISARMING: state = STATE_ALARM_DISARMING + elif status == self._client.ALARMING: + state = STATE_ALARM_TRIGGERED + attr['triggered_source'] = 'Police/Medical' + elif status == self._client.ALARMING_FIRE_SMOKE: + state = STATE_ALARM_TRIGGERED + attr['triggered_source'] = 'Fire/Smoke' + elif status == self._client.ALARMING_CARBON_MONOXIDE: + state = STATE_ALARM_TRIGGERED + attr['triggered_source'] = 'Carbon Monoxide' else: + logging.info("Total Connect Client returned unknown " + "status code: %s", status) state = None self._state = state + self._device_state_attributes = attr def alarm_disarm(self, code=None): """Send disarm command.""" diff --git a/homeassistant/components/totalconnect/manifest.json b/homeassistant/components/totalconnect/manifest.json index adb60599ae5..3ff3b5c5b46 100644 --- a/homeassistant/components/totalconnect/manifest.json +++ b/homeassistant/components/totalconnect/manifest.json @@ -3,7 +3,7 @@ "name": "Totalconnect", "documentation": "https://www.home-assistant.io/components/totalconnect", "requirements": [ - "total_connect_client==0.25" + "total_connect_client==0.27" ], "dependencies": [], "codeowners": [] diff --git a/requirements_all.txt b/requirements_all.txt index 0126cbddaf8..375b4ae9124 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1755,7 +1755,7 @@ todoist-python==7.0.17 toonapilib==3.2.2 # homeassistant.components.totalconnect -total_connect_client==0.25 +total_connect_client==0.27 # homeassistant.components.tplink_lte tp-connected==0.0.4