1 """Support for Motionblinds using their WLAN API."""
3 from __future__
import annotations
5 from motionblinds
import DEVICE_TYPES_GATEWAY, DEVICE_TYPES_WIFI, MotionGateway
6 from motionblinds.motion_blinds
import MotionBlind
20 UPDATE_INTERVAL_MOVING,
21 UPDATE_INTERVAL_MOVING_WIFI,
23 from .coordinator
import DataUpdateCoordinatorMotionBlinds
24 from .gateway
import device_name
28 """Representation of a Motionblind entity."""
30 _attr_has_entity_name =
True
34 coordinator: DataUpdateCoordinatorMotionBlinds,
35 blind: MotionGateway | MotionBlind,
37 """Initialize the entity."""
46 if blind.device_type
in DEVICE_TYPES_WIFI:
51 if blind.device_type
in DEVICE_TYPES_GATEWAY:
54 gateway = blind._gateway
55 if gateway.firmware
is not None:
56 sw_version = f
"{gateway.firmware}, protocol: {gateway.protocol}"
58 sw_version = f
"Protocol: {gateway.protocol}"
60 if blind.device_type
in DEVICE_TYPES_GATEWAY:
62 connections={(dr.CONNECTION_NETWORK_MAC, blind.mac)},
63 identifiers={(DOMAIN, blind.mac)},
64 manufacturer=MANUFACTURER,
65 name=DEFAULT_GATEWAY_NAME,
67 sw_version=sw_version,
69 elif blind.device_type
in DEVICE_TYPES_WIFI:
71 connections={(dr.CONNECTION_NETWORK_MAC, blind.mac)},
72 identifiers={(DOMAIN, blind.mac)},
73 manufacturer=MANUFACTURER,
74 model=blind.blind_type,
76 sw_version=sw_version,
77 hw_version=blind.wireless_name,
81 identifiers={(DOMAIN, blind.mac)},
82 manufacturer=MANUFACTURER,
83 model=blind.blind_type,
85 via_device=(DOMAIN, blind._gateway.mac),
86 hw_version=blind.wireless_name,
91 """Return True if entity is available."""
92 if self.coordinator.data
is None:
95 gateway_available = self.coordinator.data[KEY_GATEWAY][ATTR_AVAILABLE]
96 if not gateway_available
or self.
_blind_blind.device_type
in DEVICE_TYPES_GATEWAY:
97 return gateway_available
99 return self.coordinator.data[self.
_blind_blind.mac][ATTR_AVAILABLE]
102 """Subscribe to multicast pushes and register signal handler."""
103 self.
_blind_blind.Register_callback(self.unique_id, self.schedule_update_ha_state)
107 """Unsubscribe when removed."""
108 self.
_blind_blind.Remove_callback(self.unique_id)
112 """Request a state update from the blind at a scheduled point in time."""
119 await self.
hasshass.async_add_executor_job(self.
_blind_blind.Update_trigger)
124 self.
_blind_blind.position == prev_position
138 """Request the position of the blind every self._update_interval_moving seconds until it stops moving."""
143 if self.
_blind_blind.position
is None:
None async_request_position_till_stop(self, int|None delay=None)
None __init__(self, DataUpdateCoordinatorMotionBlinds coordinator, MotionGateway|MotionBlind blind)
None async_scheduled_update_request(self, *_)
None async_will_remove_from_hass(self)
None async_added_to_hass(self)
None async_update_listeners(self)
CALLBACK_TYPE async_call_later(HomeAssistant hass, float|timedelta delay, HassJob[[datetime], Coroutine[Any, Any, None]|None]|Callable[[datetime], Coroutine[Any, Any, None]|None] action)