Flow based off multiple entities last changed

I would like a flow to be like follows: (any suggestions to make better would be greatly appreciated.

events: state “entity off for (blank time)” - node I can’t figure out “entity has been off for at least” - call service

This should satisfy “off for x minutes”:

That works for the first node… But it’s the second node I can’t figure out :pensive:

Ah, so when you setup your event:state node with a if state value, you should have 2 paths coming off the node, one is true, the other is false:

image

You would put your call service node on the True path (which is the top one). Your false path, you can either ignore or have another action to call when the statement is false (in this case, if the sensor is on).

So maybe I didn’t explain properly… Let me try to explain again to see there is a solution

event: state node - bedroom light - is on - for 5 minutes (true)
passes to
AND(trying to figure out which node and how): hallway light - is on - for 5 minutes (true)
passes to
call service node: then what ever I want to do

Ahhhh, gotcha. So, you want to check if both lights (or more) are on for more than 5 minutes and then take an action?

You could use the getEntities node to grab the lights and then check the last_updated property. When I get off work tonight, I can see if I can setup a Jsonata expression to check the last_updated date. I think, off the top of my head, it’s something like $now() - $toMillis(payload.last_updated), but I won’t have access to NodeRed to test that until later tonight.

Yes… exactly! Thank you so much!

[{"id":"eead6bd.bb40a98","type":"server-state-changed","z":"d4450f17.60952","name":"Light A","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.light_a","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"5","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":240,"y":500,"wires":[["129d7c27.f04e94"],[]]},{"id":"129d7c27.f04e94","type":"api-current-state","z":"d4450f17.60952","name":"Light B on?","server":"9405c3fe.d0a6c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.light_b","state_type":"str","state_location":"lightBpayload","override_payload":"msg","entity_location":"lightBdata","override_data":"msg","blockInputOverrides":true,"x":400,"y":500,"wires":[["f09b4963.0340a8"],[]]},{"id":"f09b4963.0340a8","type":"switch","z":"d4450f17.60952","name":"more than 5 minutes?","property":"lightBdata.timeSinceChangedMs","propertyType":"msg","rules":[{"t":"gte","v":"300000","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":500,"wires":[["a4802173.81b33"]]},{"id":"a4802173.81b33","type":"api-call-service","z":"d4450f17.60952","name":"Do stuff","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":790,"y":500,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","addon":true}]
1 Like

This was PERFECT, thank you! Is there a way to marked as solved?

1 Like

You are the creator of the thread so you should see it somewhere in the bottom right corner of every answer I believe, near the Like button.

I’m glad it worked