Events
HassEvent: TypeAlias = Event[HassPayload[Any]]
module-attribute
Alias for Home Assistant events.
Event
dataclass
Bases: Generic[PayloadT]
Base event with strongly typed payload.
Source code in src/hassette/events/base.py
115 116 117 118 119 120 121 122 123 124 125 126 | |
topic: Topic | str
instance-attribute
Topic of the event.
payload: PayloadT
instance-attribute
The event payload.
EventPayload
dataclass
Bases: Generic[DataT]
Base payload with typed data.
Source code in src/hassette/events/base.py
17 18 19 20 21 22 23 24 25 26 27 28 | |
data: DataT
instance-attribute
The actual event data.
event_id: str = field(default='', kw_only=True)
class-attribute
instance-attribute
Unique identifier for this event. Subclasses override with a more specific default.
origin: str = field(default='UNKNOWN', kw_only=True)
class-attribute
instance-attribute
Origin of the event. Subclasses override with a concrete value.
HassContext
dataclass
Structure for the context of a Home Assistant event.
Source code in src/hassette/events/base.py
31 32 33 34 35 36 37 | |
HassettePayload
dataclass
Bases: EventPayload[DataT]
Hassette event payload with additional metadata.
Source code in src/hassette/events/base.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
data: DataT
instance-attribute
The actual event data.
event_id: str = field(default_factory=(lambda: str(uuid.uuid4())))
class-attribute
instance-attribute
Unique identifier for this payload instance (UUID4), generated at construction time.
The bus shares one payload instance with all matched listeners, so all handlers
for the same event see the same event_id.
time_fired: ZonedDateTime = field(default_factory=(lambda: ZonedDateTime.now('UTC')))
class-attribute
instance-attribute
The time the event was fired, defaulting to the current UTC time at construction.
origin: str = field(default='HASSETTE', init=False)
class-attribute
instance-attribute
Origin of the event, always 'HASSETTE' for framework-generated events.
HassPayload
dataclass
Bases: EventPayload[DataT]
Home Assistant event payload with additional metadata.
Source code in src/hassette/events/base.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
event_type: str
instance-attribute
Type of the event, e.g., 'state_changed', 'call_service', etc.
data: DataT
instance-attribute
The actual event data from Home Assistant.
origin: Literal['LOCAL', 'REMOTE']
instance-attribute
Origin of the event, either 'LOCAL' or 'REMOTE'.
time_fired: ZonedDateTime
instance-attribute
The time the event was fired.
context: HassContext
instance-attribute
The context of the event.
entity_id: str | None
property
Return the entity_id if present in the data.
domain: str | None
property
Return the domain if present in the data.
service: str | None
property
Return the service if present in the data.
AutomationTriggeredEvent
dataclass
Bases: Event[HassPayload[AutomationTriggeredPayload]]
Event representing an automation triggered in Home Assistant.
Source code in src/hassette/events/hass/hass.py
206 207 | |
CallServiceEvent
dataclass
Bases: Event[HassPayload[CallServicePayload]]
Event representing a call service in Home Assistant.
Source code in src/hassette/events/hass/hass.py
178 179 | |
ComponentLoadedEvent
dataclass
Bases: Event[HassPayload[ComponentLoadedPayload]]
Event representing a component loaded in Home Assistant.
Source code in src/hassette/events/hass/hass.py
182 183 | |
LogbookEntryEvent
dataclass
Bases: Event[HassPayload[LogbookEntryPayload]]
Event representing a logbook entry in Home Assistant.
Source code in src/hassette/events/hass/hass.py
194 195 | |
RawStateChangeEvent
dataclass
Bases: Event[HassPayload[RawStateChangePayload]]
Event representing a state change in Home Assistant, with raw state data.
Source code in src/hassette/events/hass/hass.py
174 175 | |
ScriptStartedEvent
dataclass
Bases: Event[HassPayload[ScriptStartedPayload]]
Event representing a script started in Home Assistant.
Source code in src/hassette/events/hass/hass.py
210 211 | |
ServiceRegisteredEvent
dataclass
Bases: Event[HassPayload[ServiceRegisteredPayload]]
Event representing a service registered in Home Assistant.
Source code in src/hassette/events/hass/hass.py
186 187 | |
ServiceRemovedEvent
dataclass
Bases: Event[HassPayload[ServiceRemovedPayload]]
Event representing a service removed in Home Assistant.
Source code in src/hassette/events/hass/hass.py
190 191 | |
UserAddedEvent
dataclass
Bases: Event[HassPayload[UserAddedPayload]]
Event representing a user added in Home Assistant.
Source code in src/hassette/events/hass/hass.py
198 199 | |
UserRemovedEvent
dataclass
Bases: Event[HassPayload[UserRemovedPayload]]
Event representing a user removed in Home Assistant.
Source code in src/hassette/events/hass/hass.py
202 203 | |
HassContextDict
Bases: TypedDict
Structure for the context of a state change event.
Source code in src/hassette/events/hass/raw.py
8 9 10 11 12 13 | |
HassEventDict
Bases: TypedDict
Structure for the state change event data.
Source code in src/hassette/events/hass/raw.py
33 34 35 36 37 38 39 40 | |
HassEventEnvelopeDict
Bases: TypedDict
The structure of what comes from Home Assistant's websocket API for state change events.
When turned into an Event, the event attribute is popped and used to create the event,
with type and id being discarded.
Source code in src/hassette/events/hass/raw.py
43 44 45 46 47 48 49 50 51 52 | |
HassStateDict
Bases: TypedDict
Structure for the state of an entity.
This structure is seen both in a state change event or by calling the HA API to get the state of an entity.
Source code in src/hassette/events/hass/raw.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
AppStateChangePayload
dataclass
Payload for app instance state change events.
Source code in src/hassette/events/hassette.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
ExecutionCompletedPayload
dataclass
Payload for a completed execution — handler invocation or scheduled job.
kind distinguishes the two: listener_id is set when kind == "handler",
job_id when kind == "job".
Source code in src/hassette/events/hassette.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
FileWatcherEventPayload
dataclass
Payload for file watcher events.
Source code in src/hassette/events/hassette.py
47 48 49 50 51 | |
HassetteAppStateEvent
dataclass
Bases: Event[HassettePayload[AppStateChangePayload]]
Event emitted when an app instance changes state.
Source code in src/hassette/events/hassette.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
HassetteExecutionCompletedEvent
dataclass
Bases: Event[HassettePayload[ExecutionCompletedPayload]]
Event emitted after a scheduled job execution is persisted to telemetry.
Source code in src/hassette/events/hassette.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
HassetteFileWatcherEvent
dataclass
Bases: Event[HassettePayload[FileWatcherEventPayload]]
Alias for file watcher events.
Source code in src/hassette/events/hassette.py
98 99 100 101 102 103 104 105 106 107 | |
HassetteServiceEvent
dataclass
Bases: Event[HassettePayload[ServiceStatusPayload]]
Alias for service status events.
Source code in src/hassette/events/hassette.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
HassetteSimpleEvent
dataclass
Bases: Event[HassettePayload[HassetteEmptyPayload]]
Alias for simple events with empty payload.
Source code in src/hassette/events/hassette.py
86 87 88 89 90 91 92 93 94 95 | |
ServiceStatusPayload
dataclass
Payload for service events.
Source code in src/hassette/events/hassette.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
retry_at: float | None = None
class-attribute
instance-attribute
Unix timestamp when the next restart will be attempted. Populated for EXHAUSTED_COOLING. None for EXHAUSTED_DEAD and all other statuses.
ready: bool = False
class-attribute
instance-attribute
Whether the service has signalled readiness at the time of this status event.
ready_phase: str | None = None
class-attribute
instance-attribute
Human-readable description of the current readiness phase, or None if not available.
create_event_from_hass(data: HassEventEnvelopeDict) -> Event
Create an Event from a dictionary.
Source code in src/hassette/events/hass/hass.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |