diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index 1986da20e94..95db9d2b33a 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -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 diff --git a/homeassistant/components/lock/verisure.py b/homeassistant/components/lock/verisure.py index c9f18c5533e..fe7a9eeaf5a 100644 --- a/homeassistant/components/lock/verisure.py +++ b/homeassistant/components/lock/verisure.py @@ -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):