Trigger State running when not expected

Hi all
New to HA and Node Red but trying to learn from all the great content out there including this site…thanks to all those that have helped with without even knowing it!!

Ok so what I am trying to do is to put together an automation based on my device tracker. Have read many others doing similar or exactly as this but it dont seem want to work for me.

I want to detect my presence, if home the set Darren is home boolean to true. If my device trackers reports not_home then to check what the previous state was. If it was home then to set my Darren is not home boolean to true. However if it detects my previous state was anything other then home then to ignore. Why am i doing this, well i have many zones created and i wont want automations triggered further down the line if i am driving through zones.

It works in part…as you can see below

the problem I have is that the trigger state node seems to kick off by itself instead of only being triggered by a not_home payload from the first node. check the timestamps… I was home for the duration so why does the trigger node state kick off?

Here is my trigger state node details

and finally proof that my device was home all the time

I have spent days looking at whats wrong here but cant figure it out. I also tried ditching the trigger state node and put a switch node but that didnt trigger anything :frowning:

Would appreciate ANY help at all, its likely to be something really simple but cant see the woods for the trees now.

thank you
Darren.

Hi,

Firstly I think you need to get out more :slight_smile:

More seriously, can’t sit back and let a man struggle … isn’t this what you’re trying to achieve ?

[{"id":"13014915.51f287","type":"trigger-state","z":"2f0ea9da.39cca6","name":"","server":"c0171960.d12c88","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"device_tracker.life360_darren_scott","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":310,"y":460,"wires":[["1c89cfe0.1c5c2"],[]]},{"id":"1c89cfe0.1c5c2","type":"switch","z":"2f0ea9da.39cca6","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"not_home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":460,"wires":[["4a3d7fe1.298f5"],["b31a225c.45d74"]]},{"id":"4a3d7fe1.298f5","type":"api-call-service","z":"2f0ea9da.39cca6","name":"","server":"c0171960.d12c88","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"darrens_entity","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":420,"wires":[[]]},{"id":"b31a225c.45d74","type":"api-call-service","z":"2f0ea9da.39cca6","name":"","server":"c0171960.d12c88","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"darrens_entity","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":500,"wires":[[]]},{"id":"c0171960.d12c88","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The flow provided should work which you can import but you will need to update the entity ids

Good luck

Thanks very much for your help…a few questions if you dont mind.

The reason i was looking to compare against previous state (from the device tracker) is that i have multiple zones configured. If i drive from one zone to another it will trigger the not_home again and the resulting automations down stream. I only want to kick off the automation when we leave the home zone into any other zone.

I was using an event state node to start the process, this was only initiating the flow when it detected a change in state, the trigger state node however seems to run persistently…this again would initiate the resulting automations unnecessarily.

My ideal would be as follows

4 family members, when a family member detection state is changed to not home it sets that family member away boolean to true. It then looks to see if the family member whom changed was previously home…if so then check the next member, if they were not_home check the next…and so on. End result is that if everyone is not_home then it sets house is empty boolean to true. Of course in that flow if it detects anyone is home, then the house is empty boolean is set to False.

So the current flow based on your feedback and help now looks like this

A couple of issues:

  1. Not checking if the previous state was home, therefore false execution of flow resulting in unwanted ios notifications

  2. Trigger state runs all the time, should I just change these to event state nodes?

Again, massive thank you for the time you have taken to help me so far.
Darren.

Looking at that flow… It seems you reinvented the HA group.

My advice is to add everyone in a group and you will have a family home/away.

thanks for that, will take a look at how that works. Any advice on not triggering if my previous state was another zone other than home?..only want the downstream automation when the last person leaves the house and not move from one zone to another (unless its home to not_home)…probably super simple but been looking at this too long to make sense now