1 """Support for Vera locks."""
3 from __future__
import annotations
7 import pyvera
as veraApi
15 from .common
import ControllerData, get_controller_data
16 from .entity
import VeraEntity
18 ATTR_LAST_USER_NAME =
"changed_by_name"
19 ATTR_LOW_BATTERY =
"low_battery"
25 async_add_entities: AddEntitiesCallback,
27 """Set up the sensor config entry."""
32 for device
in controller_data.devices[Platform.LOCK]
39 """Representation of a Vera lock."""
42 self, vera_device: veraApi.VeraLock, controller_data: ControllerData
44 """Initialize the Vera device."""
45 VeraEntity.__init__(self, vera_device, controller_data)
48 def lock(self, **kwargs: Any) ->
None:
49 """Lock the device."""
50 self.vera_device.
lock()
53 def unlock(self, **kwargs: Any) ->
None:
54 """Unlock the device."""
60 """Who unlocked the lock and did a low battery alert fire.
62 Reports on the previous poll cycle.
63 changed_by_name is a string like 'Bob'.
64 low_battery is 1 if an alert fired, 0 otherwise.
66 data = super().extra_state_attributes
or {}
68 last_user = self.vera_device.get_last_user_alert()
69 if last_user
is not None:
70 data[ATTR_LAST_USER_NAME] = last_user[1]
72 data[ATTR_LOW_BATTERY] = self.vera_device.get_low_battery_alert()
77 """Who unlocked the lock.
79 Reports on the previous poll cycle.
80 changed_by is an integer user ID.
82 last_user = self.vera_device.get_last_user_alert()
83 if last_user
is not None:
88 """Update state by the Vera device callback."""
bool|None is_locked(self)
None __init__(self, veraApi.VeraLock vera_device, ControllerData controller_data)
str|None changed_by(self)
None lock(self, **Any kwargs)
None unlock(self, **Any kwargs)
dict[str, Any]|None extra_state_attributes(self)
ControllerData get_controller_data(HomeAssistant hass, ConfigEntry config_entry)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)