Skip to content

Commit

Permalink
fix(events-state): cast state before setting new/old state
Browse files Browse the repository at this point in the history
Closes #299
  • Loading branch information
zachowj committed Dec 5, 2020
1 parent 08a1d11 commit f49fd82
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nodes/events-state-changed/events-state-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ module.exports = function (RED) {
const entityId = eventMessage.entity_id;
const oldEntity = selectn('event.old_state', eventMessage);
const newEntity = selectn('event.new_state', eventMessage);
const oldState = oldEntity ? oldEntity.state : undefined;
const newState = newEntity ? newEntity.state : undefined;

// Convert and save original state if needed
this.castState(oldEntity, config.state_type);
this.castState(newEntity, config.state_type);
const oldState = oldEntity ? oldEntity.state : undefined;
const newState = newEntity ? newEntity.state : undefined;

// Output only on state change
if (
Expand Down

0 comments on commit f49fd82

Please sign in to comment.