Wait until state changes?

Hi! This week I got my Z-Stick 7 and finally managed to get all my Nano Shutters (motor blinds controllers) working.

I have three blinds next to each other and I like them to open sequentially, not all together. In SmartThings/WebCoRE I had to calculate the travel time it took each motor to reach its position, because the devices took a long time to report their status after a change.

Now that I’m running everything locally, it’s incredibly fast. So even though I had already migrated the old automation from WebCoRE to Node-RED, I am thinking of simplifying it by using a “wait until” node.

I created a virtual light called “All Blinds”, when that’s turned on, this flow should get the brightness level and send it to one motor blind, then wait until that device reports back and send the same command to the next motor blind and so on.

I’m seeing that if I create a Current State node with one blind and change the blind externally, this node won’t react.
But if I create an Events State node, this one reacts to the blind position change.
The blinds won’t report when they are moving or stopped, they just report open/close states and state changes with the new position after the motor has stopped.

I don’t need to actually check the final position, I just need a node that pauses until the device reports a state change, no matter the content of the state change.

Here’s a simplified version so I don’t bother you with the whole flow, (which is currently a bit of a mess):

[{"id":"7b88d7c9c949b6cb","type":"api-call-service","z":"4ab138e08861c66a","name":"","server":"8a86b0cc.b2bac","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["{{device}}"],"data":"{\"position\":data.new_state.attributes.brightness}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":330,"y":720,"wires":[["7f0a535a1e539c54"]]},{"id":"7f0a535a1e539c54","type":"ha-wait-until","z":"4ab138e08861c66a","name":"","server":"8a86b0cc.b2bac","version":2,"outputs":1,"entityId":"{{device}}","entityIdFilterType":"exact","property":"","comparator":"is","value":"","valueType":"str","timeout":"0","timeoutType":"num","timeoutUnits":"seconds","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":540,"y":720,"wires":[["c4086afd1766f299"]]},{"id":"56de8afe8e3d041b","type":"inject","z":"4ab138e08861c66a","name":"90","props":[{"p":"payload"},{"p":"device","v":"cover.ns1_living","vt":"str"},{"p":"data.new_state.attributes.brightness","v":"90","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":700,"wires":[["7b88d7c9c949b6cb"]]},{"id":"c4086afd1766f299","type":"debug","z":"4ab138e08861c66a","name":"debug 57","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":720,"wires":[]},{"id":"51fe9ceced7ff76a","type":"inject","z":"4ab138e08861c66a","name":"85","props":[{"p":"payload"},{"p":"device","v":"cover.ns1_living","vt":"str"},{"p":"data.new_state.attributes.brightness","v":"85","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":740,"wires":[["7b88d7c9c949b6cb"]]},{"id":"8a86b0cc.b2bac","type":"server","name":"Home Assistant R","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Can anyone tell me what would do the trick to make the Wait Until node work? Any help is appreciated!

Thanks,
Rodrigo

The current state node is basically the equivalent of your old ‘device IS’ condition from WebCoRE whereas the Events state node is the ‘device CHANGES to’ equivalent. So if you’re waiting for the device to be a certain state you’d wait on that device to fire that event and respond when it does…

1 Like

Thanks @NathanCu for your reply.
Yes, I am starting to understand that part. But I have a specific situation here which in other cases is easily solved by using the Wait Until node.
I tried to use this same node here and for some reason it’s not working, and I don’t know how to configure so that it reacts to the event reported by my motor blind!
Do you have any suggestions?

R.

Ok so I found one solution that is working for the moment, waiting until the last_updates value becomes NOT zero is working:

R.