Skip to content

Commit

Permalink
refactor(trigger-state): Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Oct 5, 2023
1 parent 1fb3a4f commit 45351a0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/nodes/trigger-state/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { HassEntities } from 'home-assistant-js-websocket';

import { HaEvent } from '../../homeAssistant';
import HomeAssistant from '../../homeAssistant/HomeAssistant';
import { HassStateChangedEvent } from '../../types/home-assistant';

export function createStateChangeEvents(
homeAssistant: HomeAssistant,
entities?: HassEntities
) {
entities ??= homeAssistant.websocket.getStates();
export function createStateChangeEvents(homeAssistant: HomeAssistant) {
const entities = homeAssistant.websocket.getStates();

const events = [];
const events: HassStateChangedEvent[] = [];
for (const entityId in entities) {
events.push({
event_type: HaEvent.StateChanged,
Expand All @@ -19,7 +15,7 @@ export function createStateChangeEvents(
old_state: entities[entityId],
new_state: entities[entityId],
},
});
} as HassStateChangedEvent);
}

return events;
Expand Down

0 comments on commit 45351a0

Please sign in to comment.