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:
parent
673290d2e1
commit
12d59797a7
3 changed files with 23 additions and 5 deletions
|
@ -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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue