Skip to content

Commit

Permalink
fix(trigger-state): Attribute of other entity undefined in trigger
Browse files Browse the repository at this point in the history
Closes #148
  • Loading branch information
zachowj committed Aug 17, 2019
1 parent 5125821 commit a45366f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions nodes/trigger-state/trigger-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,23 @@ module.exports = function(RED) {
? this.nodeConfig.entityid
: constraint.targetValue;

if (isTargetThisEntity) {
targetData.state = triggerEvent;
} else {
const state = await this.nodeConfig.server.homeAssistant.getStates(
targetData.entityid
targetData.state = isTargetThisEntity
? triggerEvent
: await this.nodeConfig.server.homeAssistant.getStates(
targetData.entityid
);

// TODO: Deprecated, remove at a later date
if (
!isTargetThisEntity &&
constraint.propertyValue.startsWith('new_state.')
) {
this.warn(
'DEPRECATED: new_state is no longer needed to access properties of this entity. The ability to do so will be removed in the future',
{}
);
targetData.state = {
new_state: state
new_state: targetData.state
};
}
} catch (e) {
Expand Down

0 comments on commit a45366f

Please sign in to comment.