1 """Cover support for switch entities."""
3 from __future__
import annotations
8 DOMAIN
as COVER_DOMAIN,
25 from .const
import CONF_INVERT
26 from .entity
import BaseInvertableEntity
31 config_entry: ConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Initialize Cover Switch config entry."""
35 registry = er.async_get(hass)
36 entity_id = er.async_validate_entity_id(
37 registry, config_entry.options[CONF_ENTITY_ID]
46 config_entry.options[CONF_INVERT],
48 config_entry.entry_id,
55 """Represents a Switch as a Cover."""
57 _attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
61 await self.
hasshass.services.async_call(
63 SERVICE_TURN_OFF
if self.
_invert_state_invert_state
else SERVICE_TURN_ON,
71 await self.
hasshass.services.async_call(
73 SERVICE_TURN_ON
if self.
_invert_state_invert_state
else SERVICE_TURN_OFF,
81 self, event: Event[EventStateChangedData] |
None =
None
83 """Handle child updates."""
None async_open_cover(self, **Any kwargs)
None async_state_changed_listener(self, Event[EventStateChangedData]|None event=None)
None async_close_cover(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)