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?
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
Alternatively you can use a RBE node after location event. This will only let pass when your stat has changed!
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.
I realize that this thread is three months old, but what if you have zones created and trigger based on the change from work to not_home? I have several zones, work, bart, that I would like to trigger activities at home.
In NodeRed I can see it change to and from home, not_home, work and bart. But the trigger:state isn’t allowing me to use the work and bart constraints as the previous state. I have tried with the device_tracker and the person.xxxx entity. thoughts?
Sorry, never received a notification that you replied…
Did you assign a device to a person? System - > Persons (Add persons)
I have only one device under each person to track.
You can use this in the developer tools -> template to see if it works:
You can also use person.yournamehere and see what it provides.
{% if is_state("device_tracker.paulus", "home") and
is_state("device_tracker.anne_therese", "home") -%}
You are both home, you silly
{%- else -%}
Anne Therese is at {{ states("device_tracker.anne_therese") }}
Paulus is at {{ states("device_tracker.paulus") }}
{%- endif %}