1 """Support for Modbus covers."""
3 from __future__
import annotations
5 from datetime
import datetime
19 CALL_TYPE_WRITE_REGISTER,
25 CONF_STATUS_REGISTER_TYPE,
27 from .entity
import BasePlatform
28 from .modbus
import ModbusHub
36 async_add_entities: AddEntitiesCallback,
37 discovery_info: DiscoveryInfoType |
None =
None,
39 """Read configuration and create Modbus cover."""
40 if discovery_info
is None:
44 for cover
in discovery_info[CONF_COVERS]:
45 hub: ModbusHub =
get_hub(hass, discovery_info[CONF_NAME])
52 """Representation of a Modbus cover."""
54 _attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
60 config: dict[str, Any],
62 """Initialize the modbus cover."""
88 self.
_write_type_write_type = CALL_TYPE_WRITE_REGISTER
95 """Handle entity which will be added."""
103 STATE_UNAVAILABLE:
None,
109 """Convert received value to HA state."""
116 result = await self.
_hub_hub.async_pb_call(
124 result = await self.
_hub_hub.async_pb_call(
131 """Update the state of the cover."""
134 result = await self.
_hub_hub.async_pb_call(
None __init__(self, HomeAssistant hass, ModbusHub hub, dict[str, Any] config)
None async_close_cover(self, **Any kwargs)
None async_added_to_hass(self)
None async_open_cover(self, **Any kwargs)
None async_update(self, datetime|None now=None)
None _set_attr_state(self, str|bool|int value)
None async_write_ha_state(self)
State|None async_get_last_state(self)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
ModbusHub get_hub(HomeAssistant hass, str name)