1 """Support for Freedompro lock."""
6 from pyfreedompro
import put_state
17 from .const
import DOMAIN
18 from .coordinator
import FreedomproDataUpdateCoordinator
22 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
24 """Set up Freedompro lock."""
25 api_key: str = entry.data[CONF_API_KEY]
26 coordinator: FreedomproDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
28 Device(hass, api_key, device, coordinator)
29 for device
in coordinator.data
30 if device[
"type"] ==
"lock"
35 """Representation of a Freedompro lock."""
37 _attr_has_entity_name =
True
44 device: dict[str, Any],
45 coordinator: FreedomproDataUpdateCoordinator,
47 """Initialize the Freedompro lock."""
53 self.
_type_type = device[
"type"]
57 (DOMAIN, device[
"uid"]),
59 manufacturer=
"Freedompro",
60 model=self.
_type_type,
66 """Handle updated data from the coordinator."""
70 for device
in self.coordinator.data
71 if device[
"uid"] == self.
unique_idunique_id
75 if device
is not None and "state" in device:
76 state = device[
"state"]
78 if state[
"lock"] == 1:
85 """When entity is added to hass."""
90 """Async function to lock the lock."""
101 """Async function to unlock the lock."""
102 payload = {
"lock": 0}
None _handle_coordinator_update(self)
None async_lock(self, **Any kwargs)
None async_unlock(self, **Any kwargs)
None __init__(self, HomeAssistant hass, str api_key, dict[str, Any] device, FreedomproDataUpdateCoordinator coordinator)
None async_added_to_hass(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)