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()
This commit is contained in:
Austin Mroczek 2019-06-01 13:12:58 -07:00 committed by Paulus Schoutsen
parent 673290d2e1
commit 12d59797a7
3 changed files with 23 additions and 5 deletions

View File

@ -9,9 +9,8 @@ from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.const import ( from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY, CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED,
STATE_ALARM_ARMING, STATE_ALARM_DISARMING, CONF_NAME, STATE_ALARM_ARMING, STATE_ALARM_DISARMING, STATE_ALARM_TRIGGERED,
STATE_ALARM_ARMED_CUSTOM_BYPASS) CONF_NAME, STATE_ALARM_ARMED_CUSTOM_BYPASS)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -46,6 +45,7 @@ class TotalConnect(alarm.AlarmControlPanel):
self._username = username self._username = username
self._password = password self._password = password
self._state = None self._state = None
self._device_state_attributes = {}
self._client = TotalConnectClient.TotalConnectClient( self._client = TotalConnectClient.TotalConnectClient(
username, password) username, password)
@ -59,9 +59,15 @@ class TotalConnect(alarm.AlarmControlPanel):
"""Return the state of the device.""" """Return the state of the device."""
return self._state return self._state
@property
def device_state_attributes(self):
"""Return the state attributes of the device."""
return self._device_state_attributes
def update(self): def update(self):
"""Return the state of the device.""" """Return the state of the device."""
status = self._client.get_armed_status() status = self._client.get_armed_status()
attr = {'triggered_source': None, 'triggered_zone': None}
if status == self._client.DISARMED: if status == self._client.DISARMED:
state = STATE_ALARM_DISARMED state = STATE_ALARM_DISARMED
@ -77,10 +83,22 @@ class TotalConnect(alarm.AlarmControlPanel):
state = STATE_ALARM_ARMING state = STATE_ALARM_ARMING
elif status == self._client.DISARMING: elif status == self._client.DISARMING:
state = STATE_ALARM_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: else:
logging.info("Total Connect Client returned unknown "
"status code: %s", status)
state = None state = None
self._state = state self._state = state
self._device_state_attributes = attr
def alarm_disarm(self, code=None): def alarm_disarm(self, code=None):
"""Send disarm command.""" """Send disarm command."""

View File

@ -3,7 +3,7 @@
"name": "Totalconnect", "name": "Totalconnect",
"documentation": "https://www.home-assistant.io/components/totalconnect", "documentation": "https://www.home-assistant.io/components/totalconnect",
"requirements": [ "requirements": [
"total_connect_client==0.25" "total_connect_client==0.27"
], ],
"dependencies": [], "dependencies": [],
"codeowners": [] "codeowners": []

View File

@ -1755,7 +1755,7 @@ todoist-python==7.0.17
toonapilib==3.2.2 toonapilib==3.2.2
# homeassistant.components.totalconnect # homeassistant.components.totalconnect
total_connect_client==0.25 total_connect_client==0.27
# homeassistant.components.tplink_lte # homeassistant.components.tplink_lte
tp-connected==0.0.4 tp-connected==0.0.4