Event Trigger State - From --> To...Help Needed



New to node Red so haven’t yet worked out how to do this…

I have an automation I setup which tracks where my iphone is using owntracks. When I leave the house it will turn off the light in the hallway if it is switched on. When I come home and if its after the sun has gone down the light will turn on.

Problem I am facing is that I am using an events: state node which is watching my iphone for state changes. The light is turning on and off as it should be. I also have a push notification setup which tells me that the event has triggered.

Every 5 minutes or so or when owntracks pushes a new location to HA, Node Red picks up on it and i’m getting a “Left Home” notification each time. So it seems that even though i’m already away from home, when a new location update is pushed to HA the “AWAY” status is updated as well to “AWAY” again, even if its already set to away. Node red seems to pick up on this change and keeps triggering the automation.

Is there a way to setup an event trigger that is set to trigger if my iphone state goes from “home” to “away” then that will stop it from constantly firing? That’s how I used to have it setup with HA automation’s, but moving to node red I haven’t worked out how to do this?

Can anyone help?


yes there is a HA trigger node in which you can set the “previous” and “current” state … it will only trigger when it changed according your setting. I can share a mini flow when I’m back home … but its very easy to find :wink:

Alternatively you can use a RBE node after location event. This will only let pass when your stat has changed!


I would like to see the trigger state node as an example.

It seems very power but I just don’t truly appreciate it yet.

In the info panel it has an example of how to test the trigger with creating an input. I would like to see an example of that if anyone has done it.


It depends, what exactly are you trying to acomplish?


I got to this node by reading about functions and switches to send only changes states though a node.

I have been playing with it, but am tryting to lean by seeing how others do use it.

More specificly I am trying to see how to do this (from the info panel)

NOTE: To test automation without having to manually change state in home assistant send an input payload as an object which contains entity_id , new_state , and old_state properties. This will trigger the node as if the event came from home assistant.


This is mine for presence detection.

The State node will only allow it to continue onto the next step if the payload goes from “home” to “not_home” or “not_home” to “home”


Thanks for your example, I needed this!