1 """Valve support for switch entities."""
3 from __future__
import annotations
9 DOMAIN
as VALVE_DOMAIN,
25 from .const
import CONF_INVERT
26 from .entity
import BaseInvertableEntity
31 config_entry: ConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Initialize Valve 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 Valve."""
57 _attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE
58 _attr_reports_position =
False
62 await self.
hasshass.services.async_call(
64 SERVICE_TURN_OFF
if self.
_invert_state_invert_state
else SERVICE_TURN_ON,
72 await self.
hasshass.services.async_call(
74 SERVICE_TURN_ON
if self.
_invert_state_invert_state
else SERVICE_TURN_OFF,
82 self, event: Event[EventStateChangedData] |
None =
None
84 """Handle child updates."""
None async_close_valve(self, **Any kwargs)
None async_state_changed_listener(self, Event[EventStateChangedData]|None event=None)
None async_open_valve(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)