mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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'
|
DOMAIN = 'lock'
|
||||||
SCAN_INTERVAL = 30
|
SCAN_INTERVAL = 30
|
||||||
|
ATTR_CHANGED_BY = 'changed_by'
|
||||||
|
|
||||||
GROUP_NAME_ALL_LOCKS = 'all locks'
|
GROUP_NAME_ALL_LOCKS = 'all locks'
|
||||||
ENTITY_ID_ALL_LOCKS = group.ENTITY_ID_FORMAT.format('all_locks')
|
ENTITY_ID_ALL_LOCKS = group.ENTITY_ID_FORMAT.format('all_locks')
|
||||||
@ -101,6 +102,11 @@ def setup(hass, config):
|
|||||||
class LockDevice(Entity):
|
class LockDevice(Entity):
|
||||||
"""Representation of a lock."""
|
"""Representation of a lock."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def changed_by(self):
|
||||||
|
"""Last change triggered by."""
|
||||||
|
return None
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
@ -127,6 +133,7 @@ class LockDevice(Entity):
|
|||||||
return None
|
return None
|
||||||
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
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class VerisureDoorlock(LockDevice):
|
|||||||
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):
|
||||||
@ -51,6 +52,11 @@ class VerisureDoorlock(LockDevice):
|
|||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return hub.available
|
return hub.available
|
||||||
|
|
||||||
|
@property
|
||||||
|
def changed_by(self):
|
||||||
|
"""Last change triggered by."""
|
||||||
|
return self._changed_by
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
"""Return the required six digit code."""
|
"""Return the required six digit code."""
|
||||||
@ -68,6 +74,7 @@ class VerisureDoorlock(LockDevice):
|
|||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
'Unknown lock state %s',
|
'Unknown lock state %s',
|
||||||
hub.lock_status[self._id].status)
|
hub.lock_status[self._id].status)
|
||||||
|
self._changed_by = hub.lock_status[self._id].name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_locked(self):
|
def is_locked(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user