Skip to content

Commit

Permalink
fix: ignore state_changed event if old_state is null
Browse files Browse the repository at this point in the history
* reloading of yaml files now triggers state_changed events
* only emit these events to the events:all node

Fixes #266
  • Loading branch information
zachowj committed Sep 26, 2020
1 parent 358c909 commit 6f0a8b5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ha-websocket.js
Expand Up @@ -285,6 +285,15 @@ class HaWebsocket extends EventEmitter {
this.states[emitEvent.entity_id] = emitEvent.event.new_state;
}

// If old_state is null the state_changed was fired due to reloading of yaml files only send to events:all node
if (
emitEvent.event_type === 'state_changed' &&
emitEvent.event.old_state !== null
) {
this.emit('ha_events:all', emitEvent);
return;
}

// Emit on the event type channel
if (emitEvent.event_type) {
this.emit(`ha_events:${msg.event_type}`, emitEvent);
Expand Down

0 comments on commit 6f0a8b5

Please sign in to comment.