1 """Support for Tasmota covers."""
3 from __future__
import annotations
7 from hatasmota
import const
as tasmota_const, shutter
as tasmota_shutter
8 from hatasmota.entity
import TasmotaEntity
as HATasmotaEntity
9 from hatasmota.models
import DiscoveryHashType
14 DOMAIN
as COVER_DOMAIN,
23 from .const
import DATA_REMOVE_DISCOVER_COMPONENT
24 from .discovery
import TASMOTA_DISCOVERY_ENTITY_NEW
25 from .entity
import TasmotaAvailability, TasmotaDiscoveryUpdate
30 config_entry: ConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up Tasmota cover dynamically through discovery."""
37 tasmota_entity: HATasmotaEntity, discovery_hash: DiscoveryHashType
39 """Discover and add a Tasmota cover."""
41 [
TasmotaCover(tasmota_entity=tasmota_entity, discovery_hash=discovery_hash)]
44 hass.data[DATA_REMOVE_DISCOVER_COMPONENT.format(COVER_DOMAIN)] = (
47 TASMOTA_DISCOVERY_ENTITY_NEW.format(COVER_DOMAIN),
55 TasmotaDiscoveryUpdate,
58 """Representation of a Tasmota cover."""
60 _tasmota_entity: tasmota_shutter.TasmotaShutter
63 """Initialize the Tasmota cover."""
65 self.
_position_position: int |
None =
None
73 CoverEntityFeature.OPEN
74 | CoverEntityFeature.CLOSE
75 | CoverEntityFeature.STOP
76 | CoverEntityFeature.SET_POSITION
80 CoverEntityFeature.OPEN_TILT
81 | CoverEntityFeature.CLOSE_TILT
82 | CoverEntityFeature.STOP_TILT
83 | CoverEntityFeature.SET_TILT_POSITION
87 """Subscribe to MQTT events."""
93 """Handle state updates."""
101 """Return current position of cover.
103 None is unknown, 0 is closed, 100 is fully open.
109 """Return current tilt position of cover.
111 None is unknown, 0 is closed, 100 is fully open.
117 """Return if the cover is opening or not."""
118 return self.
_direction_direction == tasmota_const.SHUTTER_DIRECTION_UP
122 """Return if the cover is closing or not."""
123 return self.
_direction_direction == tasmota_const.SHUTTER_DIRECTION_DOWN
127 """Return if the cover is closed or not."""
133 """Open the cover."""
141 """Move the cover to a specific position."""
142 position = kwargs[ATTR_POSITION]
146 """Stop the cover."""
150 """Open the cover tilt."""
154 """Close cover tilt."""
158 """Move the cover tilt to a specific position."""
159 tilt = kwargs[ATTR_TILT_POSITION]
163 """Stop the cover tilt."""
current_cover_tilt_position
None async_stop_cover(self, **Any kwargs)
None async_set_cover_tilt_position(self, **Any kwargs)
None __init__(self, **Any kwds)
None async_close_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_close_cover_tilt(self, **Any kwargs)
bool|None is_closed(self)
None async_stop_cover_tilt(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_added_to_hass(self)
None cover_state_updated(self, bool state, **Any kwargs)
None async_open_cover_tilt(self, **Any kwargs)
None async_write_ha_state(self)
None async_discover(DiscoveryInfo discovery_info)
None open(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)