1 """LOQED lock integration for Home Assistant."""
3 from __future__
import annotations
13 from .
import LoqedDataCoordinator
14 from .const
import DOMAIN
15 from .entity
import LoqedEntity
17 WEBHOOK_API_ENDPOINT =
"/api/loqed/webhook"
19 _LOGGER = logging.getLogger(__name__)
23 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
25 """Set up the Loqed lock platform."""
26 coordinator = hass.data[DOMAIN][entry.entry_id]
32 """Representation of a loqed lock."""
34 _attr_supported_features = LockEntityFeature.OPEN
36 def __init__(self, coordinator: LoqedDataCoordinator) ->
None:
37 """Initialize the lock."""
39 self.
_lock_lock = coordinator.lock
45 """Return internal ID of last used key."""
46 return f
"KeyID {self._lock.last_key_id}"
50 """Return true if lock is locking."""
51 return self.
_lock_lock.bolt_state ==
"locking"
55 """Return true if lock is unlocking."""
56 return self.
_lock_lock.bolt_state ==
"unlocking"
60 """Return true if lock is jammed."""
61 return self.
_lock_lock.bolt_state ==
"motor_stall"
65 """Return true if lock is locked."""
66 return self.
_lock_lock.bolt_state
in [
"night_lock_remote",
"night_lock"]
73 """Unlock the lock."""
77 """Open the door latch."""
82 """Handle updated data from the coordinator."""
83 _LOGGER.debug(self.coordinator.data)
84 if "bolt_state" in self.coordinator.data:
85 self.
_lock_lock.updateState(self.coordinator.data[
"bolt_state"]).close()
None unlock(self, **Any kwargs)
None open(self, **Any kwargs)
None __init__(self, LoqedDataCoordinator coordinator)
bool|None is_locked(self)
None async_lock(self, **Any kwargs)
bool|None is_unlocking(self)
bool|None is_locking(self)
None _handle_coordinator_update(self)
None async_open(self, **Any kwargs)
None async_unlock(self, **Any kwargs)
bool|None is_jammed(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)