mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add Vera last user and low battery attributes (#27043)
* Add in attributes to track when a user unlocks the lock with a PIN, and when the battery runs low. * Vera attributes for who entered PIN on lock, and low battery warning. * Changed last_user_id to use changed_by interface. * Bump pyvera version to 0.3.6; remove guard code for earlier pyvera versions. * Bump pyvera version to 0.3.6
This commit is contained in:
parent
7d2a8b8137
commit
ce2e80339c
@ -8,6 +8,9 @@ from . import VERA_CONTROLLER, VERA_DEVICES, VeraDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_LAST_USER_NAME = "changed_by_name"
|
||||
ATTR_LOW_BATTERY = "low_battery"
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Find and return Vera locks."""
|
||||
@ -44,6 +47,35 @@ class VeraLock(VeraDevice, LockDevice):
|
||||
"""Return true if device is on."""
|
||||
return self._state == STATE_LOCKED
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Who unlocked the lock and did a low battery alert fire.
|
||||
|
||||
Reports on the previous poll cycle.
|
||||
changed_by_name is a string like 'Bob'.
|
||||
low_battery is 1 if an alert fired, 0 otherwise.
|
||||
"""
|
||||
data = super().device_state_attributes
|
||||
|
||||
last_user = self.vera_device.get_last_user_alert()
|
||||
if last_user is not None:
|
||||
data[ATTR_LAST_USER_NAME] = last_user[1]
|
||||
|
||||
data[ATTR_LOW_BATTERY] = self.vera_device.get_low_battery_alert()
|
||||
return data
|
||||
|
||||
@property
|
||||
def changed_by(self):
|
||||
"""Who unlocked the lock.
|
||||
|
||||
Reports on the previous poll cycle.
|
||||
changed_by is an integer user ID.
|
||||
"""
|
||||
last_user = self.vera_device.get_last_user_alert()
|
||||
if last_user is not None:
|
||||
return last_user[0]
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
"""Update state by the Vera device callback."""
|
||||
self._state = (
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Vera",
|
||||
"documentation": "https://www.home-assistant.io/components/vera",
|
||||
"requirements": [
|
||||
"pyvera==0.3.4"
|
||||
"pyvera==0.3.6"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
|
@ -1625,7 +1625,7 @@ pyuptimerobot==0.0.5
|
||||
# pyuserinput==0.1.11
|
||||
|
||||
# homeassistant.components.vera
|
||||
pyvera==0.3.4
|
||||
pyvera==0.3.6
|
||||
|
||||
# homeassistant.components.vesync
|
||||
pyvesync==1.1.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user