-
-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathhelpers.ts
More file actions
22 lines (19 loc) · 738 Bytes
/
Copy pathhelpers.ts
File metadata and controls
22 lines (19 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { HaEvent } from '../../homeAssistant';
import HomeAssistant from '../../homeAssistant/HomeAssistant';
import { HassStateChangedEvent } from '../../types/home-assistant';
export function createStateChangeEvents(homeAssistant: HomeAssistant) {
const entities = homeAssistant.websocket.getStatesReadOnly();
const events: HassStateChangedEvent[] = [];
for (const entityId in entities) {
events.push({
event_type: HaEvent.StateChanged,
entity_id: entityId,
event: {
entity_id: entityId,
old_state: entities[entityId],
new_state: entities[entityId],
},
} as HassStateChangedEvent);
}
return events;
}