1 """Support for Freedompro cover."""
6 from pyfreedompro
import put_state
22 from .const
import DOMAIN
23 from .coordinator
import FreedomproDataUpdateCoordinator
26 "windowCovering": CoverDeviceClass.BLIND,
27 "gate": CoverDeviceClass.GATE,
28 "garageDoor": CoverDeviceClass.GARAGE,
29 "door": CoverDeviceClass.DOOR,
30 "window": CoverDeviceClass.WINDOW,
33 SUPPORTED_SENSORS = {
"windowCovering",
"gate",
"garageDoor",
"door",
"window"}
37 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
39 """Set up Freedompro cover."""
40 api_key: str = entry.data[CONF_API_KEY]
41 coordinator: FreedomproDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
43 Device(hass, api_key, device, coordinator)
44 for device
in coordinator.data
45 if device[
"type"]
in SUPPORTED_SENSORS
50 """Representation of a Freedompro cover."""
52 _attr_has_entity_name =
True
54 _attr_current_cover_position = 0
55 _attr_is_closed =
True
56 _attr_supported_features = (
57 CoverEntityFeature.CLOSE
58 | CoverEntityFeature.OPEN
59 | CoverEntityFeature.SET_POSITION
66 device: dict[str, Any],
67 coordinator: FreedomproDataUpdateCoordinator,
69 """Initialize the Freedompro cover."""
71 self.
_session_session = aiohttp_client.async_get_clientsession(hass)
76 (DOMAIN, device[
"uid"]),
78 manufacturer=
"Freedompro",
86 """Handle updated data from the coordinator."""
90 for device
in self.coordinator.data
91 if device[
"uid"] == self.
unique_idunique_id
95 if device
is not None and "state" in device:
96 state = device[
"state"]
97 if "position" in state:
106 """When entity is added to hass."""
111 """Open the cover."""
115 """Close the cover."""
119 """Async function to set position to cover."""
120 payload = {
"position": kwargs[ATTR_POSITION]}
None async_set_cover_position(self, **Any kwargs)
None _handle_coordinator_update(self)
int _attr_current_cover_position
None async_added_to_hass(self)
_attr_current_cover_position
None __init__(self, HomeAssistant hass, str api_key, dict[str, Any] device, FreedomproDataUpdateCoordinator coordinator)
None async_set_cover_position(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)