1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-13 17:44:45 +01:00
Files
core/homeassistant/components/valve/trigger.py
T

27 lines
784 B
Python

"""Provides triggers for valves."""
from homeassistant.core import HomeAssistant
from homeassistant.helpers.automation import DomainSpec
from homeassistant.helpers.trigger import Trigger, make_entity_transition_trigger
from . import ATTR_IS_CLOSED, DOMAIN
VALVE_DOMAIN_SPECS: dict[str, DomainSpec] = {
DOMAIN: DomainSpec(value_source=ATTR_IS_CLOSED),
}
TRIGGERS: dict[str, type[Trigger]] = {
"closed": make_entity_transition_trigger(
VALVE_DOMAIN_SPECS, from_states={False}, to_states={True}
),
"opened": make_entity_transition_trigger(
VALVE_DOMAIN_SPECS, from_states={True}, to_states={False}
),
}
async def async_get_triggers(hass: HomeAssistant) -> dict[str, type[Trigger]]:
"""Return the triggers for valves."""
return TRIGGERS