mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
add changed_by attribute to lock (#2766)
This commit is contained in:
parent
431f0fd236
commit
180a7ec295
@ -22,6 +22,7 @@ from homeassistant.components import group
|
||||
|
||||
DOMAIN = 'lock'
|
||||
SCAN_INTERVAL = 30
|
||||
ATTR_CHANGED_BY = 'changed_by'
|
||||
|
||||
GROUP_NAME_ALL_LOCKS = 'all locks'
|
||||
ENTITY_ID_ALL_LOCKS = group.ENTITY_ID_FORMAT.format('all_locks')
|
||||
@ -101,6 +102,11 @@ def setup(hass, config):
|
||||
class LockDevice(Entity):
|
||||
"""Representation of a lock."""
|
||||
|
||||
@property
|
||||
def changed_by(self):
|
||||
"""Last change triggered by."""
|
||||
return None
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
@property
|
||||
def code_format(self):
|
||||
@ -127,6 +133,7 @@ class LockDevice(Entity):
|
||||
return None
|
||||
state_attr = {
|
||||
ATTR_CODE_FORMAT: self.code_format,
|
||||
ATTR_CHANGED_BY: self.changed_by
|
||||
}
|
||||
return state_attr
|
||||
|
||||
|
@ -35,6 +35,7 @@ class VerisureDoorlock(LockDevice):
|
||||
self._id = device_id
|
||||
self._state = STATE_UNKNOWN
|
||||
self._digits = int(hub.config.get('code_digits', '4'))
|
||||
self._changed_by = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@ -51,6 +52,11 @@ class VerisureDoorlock(LockDevice):
|
||||
"""Return True if entity is available."""
|
||||
return hub.available
|
||||
|
||||
@property
|
||||
def changed_by(self):
|
||||
"""Last change triggered by."""
|
||||
return self._changed_by
|
||||
|
||||
@property
|
||||
def code_format(self):
|
||||
"""Return the required six digit code."""
|
||||
@ -68,6 +74,7 @@ class VerisureDoorlock(LockDevice):
|
||||
_LOGGER.error(
|
||||
'Unknown lock state %s',
|
||||
hub.lock_status[self._id].status)
|
||||
self._changed_by = hub.lock_status[self._id].name
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user