Improve typing of state event helpers (#120639)

This commit is contained in:
Erik Montnemery
2024-06-27 13:08:19 +02:00
committed by GitHub
parent 54a5a3e3fb
commit a165064e9d
2 changed files with 15 additions and 10 deletions

View File

@@ -158,26 +158,29 @@ class ConfigSource(enum.StrEnum):
YAML = "yaml"
class EventStateChangedData(TypedDict):
class EventStateEventData(TypedDict):
"""Base class for EVENT_STATE_CHANGED and EVENT_STATE_CHANGED data."""
entity_id: str
new_state: State | None
class EventStateChangedData(EventStateEventData):
"""EVENT_STATE_CHANGED data.
A state changed event is fired when on state write when the state is changed.
"""
entity_id: str
old_state: State | None
new_state: State | None
class EventStateReportedData(TypedDict):
class EventStateReportedData(EventStateEventData):
"""EVENT_STATE_REPORTED data.
A state reported event is fired when on state write when the state is unchanged.
"""
entity_id: str
old_last_reported: datetime.datetime
new_state: State | None
# SOURCE_* are deprecated as of Home Assistant 2022.2, use ConfigSource instead