Now i wounder how do i make a node that triggers something only when all 3 input_select is set to “away” and nothing else? Maybe i have to use the function node and have some code in it?
Yes, a function node would work another possible solution is to use a trigger-state node with a regex for the entity id, ^input_boolean\.(first_enitity_id|second_enitity_id|third_enitity_id)$ and then make three constraints based on entity_id to see if state equals away.
This is where a ‘boolean AND node’ would have been useful – if there’s a good one out there ('m using node-red-contrib-boolean-logic but I have to convert HA states to boolean using a function node).
This is my old flow using a subflow which I called “Anyone Home?”. Each state node halts if ‘home’ or ‘on’. I then use an input_boolean to store if home is occupied.
Then it will not halt on the states “Just Arrived” and Just Left"
(Im sorry but i guess i left those states out in previous posts)
But maybe it’s possible to put Home|Just Arrived|Just Left in the “Halt if” box?
@Kermit, yes for sure. Hopefully as folks get the hang of NR, they get to use more advanced features like javascript on the function node, json, and regex on your case. Your inputs are great though – I learn a lot from them as well.
Wow, that node is super useful for making automations for home assistant, i hope someone clone that one and include it in the “node-red-contrib-home-assistant-websocket” package.
I had to add a “current state” so they all would be triggered when any of the input_select was changed, otherwise the “AND node” would only have the value from the input select that was changed at that moment, and no values from the other input selects.
If you have 2 persons on “away” and one on “home” and you restart or just press deploy in node red
the “AND node” wont go to TRUE when person nr 3 goes to “away” (not untill all 3 inputs have made a change to either away or extended away, if i dont use the “current state” to read the state from all 3 whenever any input select is triggered.
So as long as you dont press deploy or restart it might work without the “current state”.
But im always tinkering on my main system so i will most likely have it “out of sync” from restarts or deploys.