mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
add changed_by attribute to alarm control panel (#2737)
This commit is contained in:
parent
5ff9e59b79
commit
8568773e7d
@ -20,6 +20,7 @@ from homeassistant.helpers.entity_component import EntityComponent
|
|||||||
|
|
||||||
DOMAIN = 'alarm_control_panel'
|
DOMAIN = 'alarm_control_panel'
|
||||||
SCAN_INTERVAL = 30
|
SCAN_INTERVAL = 30
|
||||||
|
ATTR_CHANGED_BY = 'changed_by'
|
||||||
|
|
||||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||||
|
|
||||||
@ -124,6 +125,11 @@ class AlarmControlPanel(Entity):
|
|||||||
"""Regex for code format or None if no code is required."""
|
"""Regex for code format or None if no code is required."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def changed_by(self):
|
||||||
|
"""Last change triggered by."""
|
||||||
|
return None
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -145,5 +151,6 @@ class AlarmControlPanel(Entity):
|
|||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
state_attr = {
|
state_attr = {
|
||||||
ATTR_CODE_FORMAT: self.code_format,
|
ATTR_CODE_FORMAT: self.code_format,
|
||||||
|
ATTR_CHANGED_BY: self.changed_by
|
||||||
}
|
}
|
||||||
return state_attr
|
return state_attr
|
||||||
|
@ -37,6 +37,7 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
|||||||
self._id = device_id
|
self._id = device_id
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
self._digits = int(hub.config.get('code_digits', '4'))
|
self._digits = int(hub.config.get('code_digits', '4'))
|
||||||
|
self._changed_by = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -58,6 +59,11 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
|||||||
"""The code format as regex."""
|
"""The code format as regex."""
|
||||||
return '^\\d{%s}$' % self._digits
|
return '^\\d{%s}$' % self._digits
|
||||||
|
|
||||||
|
@property
|
||||||
|
def changed_by(self):
|
||||||
|
"""Last change triggered by."""
|
||||||
|
return self._changed_by
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update alarm status."""
|
"""Update alarm status."""
|
||||||
hub.update_alarms()
|
hub.update_alarms()
|
||||||
@ -72,6 +78,7 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
|||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
'Unknown alarm state %s',
|
'Unknown alarm state %s',
|
||||||
hub.alarm_status[self._id].status)
|
hub.alarm_status[self._id].status)
|
||||||
|
self._changed_by = hub.alarm_status[self._id].name
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user