Need help creating a sequantial action for opening or closing blinds

Hi everyone, I’m really new in Hass and Node Red, trying to learn and adapt to this platform in order to migrate from ST/Webcore. I’ve been following some tutorials and I think I’ve covered some of the basics, but I need help trying to recreate one of my nicest goals I had reached. I’m really eager to learn :slight_smile:

I have three blinds at home, and when I arrive they open sequentially, first the living room (1), then the bathroom (2) and finally the bedroom (3).
When I leave, they close in the opossite order, (3, 2, 1). Also a couple of hours after sunset, the bedroom and bathroom close (3, 2).

I was able to program this with one piston that would receive attributes from other pistons, calculate the time between sending each action and use a for loop to make the whole thing sequential.
In these attributes I sent from other pistons (pistons activated by simulated switches and a global dimmer switch), I would send the names of the blinds I wanted to activate, in the order I wanted them to be actioned, and the percentage I wanted them to be set at.
So when I left home, the automated blinds piston would receive something like “bedroom, bathroom, livingroom, 0” and when I arrived it would receive “livingroom, bathroom, bedroom, 100”.

I’d be grateful if anyone could help me create a similar automation in Node Red.

My biggest questions are:

  • Is it possible for a sequence to trigger another sequence and send these “attributes” along?
  • Is it possible to make a call node send a command to a device name that is stored in a variable or something similar? Instead of creating a node with the device I want to be actioned, I would like the node to grab that device name from a variable that was set prior to starting the sequence.
  • How do I stop a flow or a sequence from happening? Let’s say I have three actions programmed with 20 seconds between each one, and I suddenly want them to stop. What would be the best way to program this?

Thanks to everyone! All helpful comments are appreciated :smiley:
Rodrigo

What is determining the start of each subsequent shade, time? position? If it’s time you can use a delay node.

If it is positional, then multiple triggers set to trigger when another blind hits a certain point.

For saving and sending variables see working with context.

All states of entities are readily available in NR without needing to first save it as a variable using jsonata statements. There is a cookbook with examples of different types of flows in NR

1 Like

Hi @Mikefila thanks for your reply! :slight_smile:

In my ST setup, when the blinds motor stopped, it would take too long for the device to report its ending position, and it wasn’t easy to set WebCore to wait for something to happen. So instead I used an expression to calculate the time between the start and ending positions (the whole time it would take from 100% to 0% would be 22 seconds, so if it was doing 0 to 50 it would set th delay to 12 seconds).

Here in HA I think I’ll be able to use the Wait node so it waits until the last blind reaches its desired position and then goes with the next device.

The thing here is that sometimes I will want only two devices to be actioned, not always three. I think I need a for loop that reads the devices from a list. That’s my biggest clue right now, I need to create a button that sets a list with devices, and then a loop that counts the devices in that list and sets it one by one.

I’ll also anwer my own previous questions now that I have read more, to see if anyone has any comments:

The solution I found for this is to use Link In and Link Out nodes, which can be used in the same flow or between flows.

I found I can use a change node to set msg.entity to a device name and then on the call service node I just write {{entity}} in the Entity field for it to take the device name in the msg.entity variable.

I found a tutorial that used a msg.reset linked to each wait node so they would stop working if the reset node was activated.

Thanks,
Rodrigo

Ok, so I’ve been testing some more things and I got to a functional sequence.

[{"id":"bca80967f4f1a957","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"0987493507089543","type":"server-state-changed","z":"bca80967f4f1a957","name":"All Blinds Switch On","server":"8a86b0cc.b2bac","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.all_blinds","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":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":60,"wires":[["24c0a6fe3c245216"],["5fe5f814443b0b89"]]},{"id":"650d88ad7aefa937","type":"function","z":"bca80967f4f1a957","name":"currentLevel vs targetLevel abs difference Delay","func":"msg.delay=(Math.abs(msg.currentLevel.attributes.brightness - msg.targetLevel));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":260,"wires":[["a6bb553dce7a4691"]]},{"id":"cf07bee13747fe24","type":"api-current-state","z":"bca80967f4f1a957","name":"Get targetDevice currentLevel","server":"8a86b0cc.b2bac","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{device}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"currentLevel","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":210,"y":220,"wires":[["650d88ad7aefa937","05b27f5b2c0a3c44"]]},{"id":"a6bb553dce7a4691","type":"range","z":"bca80967f4f1a957","minin":"1","maxin":"252","minout":"1","maxout":"24000","action":"scale","round":true,"property":"delay","name":"Delay 255 to 24000ms","x":180,"y":300,"wires":[["250e9a6fb1d0259a"]]},{"id":"1eea5e19604c24cd","type":"delay","z":"bca80967f4f1a957","name":"Delay","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":590,"y":260,"wires":[["3476e20331054d5e","cca2ac9d8bb39317"]]},{"id":"250e9a6fb1d0259a","type":"api-call-service","z":"bca80967f4f1a957","name":"Set targetDevice at targetLevel","server":"8a86b0cc.b2bac","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{device}}"],"data":"{\"brightness\":msg.targetLevel}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":210,"y":340,"wires":[["1eea5e19604c24cd"]]},{"id":"3476e20331054d5e","type":"debug","z":"bca80967f4f1a957","name":"complete message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":220,"wires":[]},{"id":"5a687bedce84df5a","type":"inject","z":"bca80967f4f1a957","name":"Start","props":[{"p":"device","v":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","vt":"json"},{"p":"targetLevel","v":"90","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":120,"wires":[["a8fe252cc5626978"]]},{"id":"90475f454f2542da","type":"function","z":"bca80967f4f1a957","name":"for each item","func":"if (msg.items == undefined) msg.items = msg.device;\nif (msg.i == undefined) msg.i = 0;\nmsg.device = msg.items[msg.i];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":140,"wires":[["cf07bee13747fe24"]]},{"id":"cca2ac9d8bb39317","type":"function","z":"bca80967f4f1a957","name":"msg.i +1","func":"if((msg.i +=1) < 3)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":400,"wires":[["90475f454f2542da"]]},{"id":"05b27f5b2c0a3c44","type":"debug","z":"bca80967f4f1a957","name":"currentLevel debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"currentLevel.attributes.brightness","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":180,"wires":[]},{"id":"5fe5f814443b0b89","type":"change","z":"bca80967f4f1a957","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":160,"wires":[["1eea5e19604c24cd"]]},{"id":"bf556889f7ea034e","type":"inject","z":"bca80967f4f1a957","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":160,"wires":[["5fe5f814443b0b89"]]},{"id":"a8fe252cc5626978","type":"range","z":"bca80967f4f1a957","minin":"1","maxin":"100","minout":"1","maxout":"252","action":"scale","round":true,"property":"targetLevel","name":"targetLevel 100 to 252","x":320,"y":120,"wires":[["90475f454f2542da"]]},{"id":"35f6c3d243754680","type":"change","z":"bca80967f4f1a957","name":"All Blinds Level to targetLevel, string","rules":[{"t":"set","p":"device","pt":"msg","to":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","tot":"json"},{"t":"set","p":"targetLevel","pt":"msg","to":"targetLevel.attributes.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":60,"wires":[["3476e20331054d5e","90475f454f2542da","5b8047a9b95f062b"]]},{"id":"24c0a6fe3c245216","type":"api-current-state","z":"bca80967f4f1a957","name":"Get All Blinds Level","server":"8a86b0cc.b2bac","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.all_blinds","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"targetLevel","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":350,"y":60,"wires":[["35f6c3d243754680","5b8047a9b95f062b"]]},{"id":"5b8047a9b95f062b","type":"debug","z":"bca80967f4f1a957","name":"complete message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":140,"wires":[]},{"id":"8a86b0cc.b2bac","type":"server","name":"Home Assistant","addon":true}]

I was able to link my “All Blinds” dimmer (the one that is activated for opening the blinds) to this sequence, it creates an array of the three devices (in the order I want them to be opened) and activates one by one.
The purpose of this “All Blinds” dimmer switch is to turn it on to 100% when I want the blinds to be opened fully, but when the sequence ends and all the blinds are open, I want this switch to be turned off. So if I want the blinds to be at 50%, I’ll then set it to 50% and it will start the sequence again.

What’s the best method to have this switch turned off after the sequence ends?

I copied the “for each item” and “msg.i +1” functions from a video so I don’t understand it fully, and I’m having an issue: It expects to have 3 items in the array and always repeat 3 times. If I send a list of only 2 blinds it will work and then return an error. Can anyone help me get the script right so it identifies the amount of times it has to loop based on the amount of items in the list

Thanks!
Rodrigo

EDIT: Forgot to mention that the reason why I didn’t use the “Wait for” node is because these controllers aren’t precise at reporting the final position, and sometimes they get “stuck” in a previous value (not the physical position itself which always reaches its desired place, but sometimes the final value doesn’t match).

Before i dive into this - can i mention a couple of things

  1. Use link nodes on your flow - to stop all the wires going all over the place - Link in and link out can be used on the same page - makes it much easier to debug.

  2. Why do you blinds have to operate in a sequential fashion ? Why can’t each one just be used and actioned as a seperate entity and you call them as and when you see fit ?

  3. Personally i would create a flow for each blind and just provide a link in node to them so you could fire them all off from a single action (if thats what you want).

Craig

1 Like

Hi @craigcurtin, thanks for your recommendations.

  1. Yes, I have seen link in and link out nodes and I’m definitely going to use them.

  2. It’s just an idea I liked, trying to achieve it helped me learn a lot when I was starting in WebCoRE, and it’s already doing its magic in Node-RED too :slight_smile: Anyway, they don’t “have” to always work this way. I like them to work sequentially when I arrive home (1,2,3), and when I leave (3,2,1) it serves the purpose of indicating me that the blinds are closing, without actually darkening the place where I’m still at (the living room, I’m probably still getting my things to go out). They can still be controlled separately from each of their controls. I also have remotes to set each one of them to different positions.

  3. I don’t know why I would need a separate flow for each blind. Here I was able to create a single flow that can set the order in which the blinds sequence operates, and if I ever want to change something, I only change it once. If I created a flow for each blind I would need to edit them separately if I ever want to change them. Is there any problem of doing it this way?

Thanks,
Rodrigo

The problems with doing it this way is that any change you make effects all 3 blinds rather than a single blind, it also (as a newbie) makes it much more complex for you to track the interaction etc.

At the very least i would start out seperating out the logic for each blind on the one page, then set each of them up as a group of nodes on the page so you can see what relates to what etc.

Craig

1 Like

OK trying to follow the logic of what you are coding here ?

In summary i think

  1. You want to capture the current state of each blind - in case they are not currently completely opened or completely closed ?

  2. You want to then adjust them by X amount being based on a slider/dimmer value that will be set in the dashboard ?

  3. You can not rely on feedback from the motors to ascertain the position so you do this by guessing based on elapsed time ?

I personally would build this up one blind at a time (which would get rid of your msg.i code - which is a horrible way of doing a loop)

In terms of knowing how many objects (blinds) are going to be moved - you have to reference this from the dashboard and how many sliders you select - how are you doing this ? If i was doing it purely in Node Red and its dashboard i would have a Radio button along the lines of - treat all blinds as one - with an on/off action. How have you done this ?

I would suggest you would be better of using some flow variables to record the starting state etc

Have you seen these videos ?

Craig

1 Like

Nothing here is really tested but should give you some ideas. Ask any questions you might have. Normally I would use a function node for the queue system but I tried it without. The queue node is from the package node-red-contrib-queue-gate my first time using it might be something better out there.

[{"id":"9cbfa8fd38e0243c","type":"server-state-changed","z":"fe6c4832f544cee0","name":"All Blinds Switch On","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.all_blinds","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":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"targetLevel","propertyType":"msg","value":"$entity().attributes.brightness","valueType":"jsonata"},{"property":"payload","propertyType":"msg","value":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","valueType":"jsonata"}],"x":106,"y":368,"wires":[["ad80ea9fc02e880a"],["37f7054f71b93f31"]]},{"id":"3070690827e61cdd","type":"delay","z":"fe6c4832f544cee0","name":"Delay","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":930,"y":512,"wires":[["0d0abac9af2a1050"]]},{"id":"b6cc548004100eac","type":"api-call-service","z":"fe6c4832f544cee0","name":"Set targetDevice at targetLevel","server":"","version":5,"debugenabled":true,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{payload}}"],"data":"{\"brightness\": targetLevel}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":512,"wires":[["bf98248a1647647e"]]},{"id":"0a14685263eaaa52","type":"inject","z":"fe6c4832f544cee0","name":"Start","props":[{"p":"payload"},{"p":"targetLevel","v":"90","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","payloadType":"json","x":142,"y":416,"wires":[["1346723831fcefe5"]]},{"id":"37f7054f71b93f31","type":"change","z":"fe6c4832f544cee0","name":"reset delay & queue","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"reset","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":464,"wires":[["3070690827e61cdd","c54e919c.18d7f"]]},{"id":"68afca9581e41939","type":"inject","z":"fe6c4832f544cee0","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":146,"y":464,"wires":[["37f7054f71b93f31"]]},{"id":"1346723831fcefe5","type":"range","z":"fe6c4832f544cee0","minin":"1","maxin":"100","minout":"1","maxout":"252","action":"scale","round":true,"property":"targetLevel","name":"targetLevel 100 to 252","x":340,"y":416,"wires":[["ad80ea9fc02e880a"]]},{"id":"c54e919c.18d7f","type":"q-gate","z":"fe6c4832f544cee0","name":"queue","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"0","keepNewest":false,"qToggle":false,"persist":false,"x":802,"y":368,"wires":[["c79ad7ce2b60bdb2"]]},{"id":"ad80ea9fc02e880a","type":"split","z":"fe6c4832f544cee0","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":290,"y":368,"wires":[["c54e919c.18d7f","7e5d17efb80a04c8"]]},{"id":"7e5d17efb80a04c8","type":"trigger","z":"fe6c4832f544cee0","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"100","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":464,"y":320,"wires":[["98b047c1578fcf2a"]]},{"id":"98b047c1578fcf2a","type":"change","z":"fe6c4832f544cee0","name":"trigger queue","rules":[{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":662,"y":320,"wires":[["c54e919c.18d7f"]]},{"id":"c79ad7ce2b60bdb2","type":"link call","z":"fe6c4832f544cee0","name":"blind controller","links":["08448c25db1ca5f8"],"linkType":"static","timeout":"60","x":972,"y":368,"wires":[["98b047c1578fcf2a"]]},{"id":"0d0abac9af2a1050","type":"link out","z":"fe6c4832f544cee0","name":"link out 1","mode":"return","links":[],"x":1025,"y":512,"wires":[]},{"id":"08448c25db1ca5f8","type":"link in","z":"fe6c4832f544cee0","name":"blind controller","links":[],"x":112,"y":512,"wires":[["b6cc548004100eac"]],"l":true},{"id":"bf98248a1647647e","type":"api-current-state","z":"fe6c4832f544cee0","name":"set delay","server":"","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{payload}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"delay","propertyType":"msg","value":"$abs($entity().attributes.brightness - targetLevel)","valueType":"jsonata"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":580,"y":512,"wires":[["7ea6b7a8bb34e828"]]},{"id":"7ea6b7a8bb34e828","type":"range","z":"fe6c4832f544cee0","minin":"1","maxin":"252","minout":"1","maxout":"24000","action":"scale","round":true,"property":"delay","name":"Delay 255 to 24000ms","x":764,"y":512,"wires":[["3070690827e61cdd"]]}]
1 Like

Thanks Craig!

Yes I have! A couple of times. I saw that one and a couple more from The Hook Up (actually I got the Reset idea from that same creator) then some from Home Sight, also some from DrZzs. And many more!

The final intention of this is to set all the blinds at the same level. Most of the times, that level is 100% open or 100% closed (off). Sometimes I may set a different level, let’s say 50% to have them all at half their position.
I only want to capture the state to calculate the amount of time is needed before each blind is activated.

Not necessarily in the dashboard. Most of the times I operate this “all blinds” switch by other automations (leaving and arriving home, nighttime, going to sleep, waking up) and sometimes by voice. But yes, sometimes I could go to the app and set the value manually there from a slider.

Exactly. They have a delay and also sometimes don’t report their final position, or they take a long time to update it, so I guesss the time it will take for them to open or close by doing a math operation (here in NR it’s easier with the Range node).

I currently use a Simulated Switch that comes from SmartThings, and I’m running HA on a PC with VirtualBox. I am waiting to get a Home Assistant Yellow and a CM4 (I live in Argentina and these things take a long time to arrive due to customs delays) to get rid of ST.
My plan is to have something similar to a Simulated Switch (I know there are “helpers” in HA, I created some but didn’t find one that works as a dimmer switch, what do you recommend?). Anyway, it’s only one slider for opening the blinds.

For closing the blinds (which go in 3, 2, 1 order), I intend to have two switches: Evening Blinds (which closes blinds 3 and 2, and leaves 1 open) and Night Blinds (which closes 3, 2, 1).

In the current sequence I created, I can set another inputs from these “Evening Blinds” and “Night Blinds” simulated switches and set them to send the array in a different order.

Of course I will always be able to operate the blinds separately, I don’t need an automation for that because the controller does it on its own (when I first bought it, it didn’t work this way, it only had “open”, “close” and “stop” commands, but fortunately they have been updated to a dimmer switch).

Cheers,
Rodrigo

Hi @Kermit thanks for your help!

I really liked this proposal, you’re simplifying some of the things I did by merging the functions inside the node’s properties.
It is kind of working: When I turn on All Blinds switch, it activates the three blinds in order, but separating the actions only by less than a second.

I see that the set delay node outputs 0 as the msg.delay, I could verify that the function inside this node was failing to get the entitie’s brightness ($abs($entity().attributes.brightness - targetLevel) so I created the msg.currentLevel again and got it from there, but all in the same node, and now it’s functioning properly.

I’m still interested on how to get the curren’t device’s level without having to create a msg variable, so let’s find out what was failing about $abs($entity().attributes.brightness - targetLevel).

The question that remains unanswered is how to set the last action to turn off the “All Blinds” switch when the sequence is over. I imagine adding the light.all_blinds item at the end of the list, and a switch node that links to a call service node that turns off that switch. I’ll test that later.

Thanks again,
Rodrigo

This might have been an error with the order of operations.

[{"id":"9cbfa8fd38e0243c","type":"server-state-changed","z":"fe6c4832f544cee0","name":"All Blinds Switch On","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.all_blinds","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":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"targetLevel","propertyType":"msg","value":"$entity().attributes.brightness","valueType":"jsonata"},{"property":"payload","propertyType":"msg","value":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","valueType":"jsonata"}],"x":106,"y":368,"wires":[["3a269a06e641f6c8"],["37f7054f71b93f31"]]},{"id":"3070690827e61cdd","type":"delay","z":"fe6c4832f544cee0","name":"Delay","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":930,"y":512,"wires":[["0d0abac9af2a1050"]]},{"id":"0a14685263eaaa52","type":"inject","z":"fe6c4832f544cee0","name":"Start","props":[{"p":"payload"},{"p":"targetLevel","v":"90","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"light.1_living\", \"light.2_bathroom\", \"light.3_bedroom\"]","payloadType":"json","x":142,"y":416,"wires":[["1346723831fcefe5"]]},{"id":"37f7054f71b93f31","type":"change","z":"fe6c4832f544cee0","name":"reset delay & queue","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":464,"wires":[["3070690827e61cdd","3a269a06e641f6c8"]]},{"id":"68afca9581e41939","type":"inject","z":"fe6c4832f544cee0","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":146,"y":464,"wires":[["37f7054f71b93f31"]]},{"id":"1346723831fcefe5","type":"range","z":"fe6c4832f544cee0","minin":"1","maxin":"100","minout":"1","maxout":"252","action":"scale","round":true,"property":"targetLevel","name":"targetLevel 100 to 252","x":340,"y":416,"wires":[["3a269a06e641f6c8"]]},{"id":"c79ad7ce2b60bdb2","type":"link call","z":"fe6c4832f544cee0","name":"blind controller","links":["08448c25db1ca5f8"],"linkType":"static","timeout":"60","x":720,"y":368,"wires":[["3a269a06e641f6c8"]]},{"id":"0d0abac9af2a1050","type":"link out","z":"fe6c4832f544cee0","name":"link out 1","mode":"return","links":[],"x":1025,"y":512,"wires":[]},{"id":"08448c25db1ca5f8","type":"link in","z":"fe6c4832f544cee0","name":"blind controller","links":[],"x":112,"y":512,"wires":[["bf98248a1647647e"]],"l":true},{"id":"bf98248a1647647e","type":"api-current-state","z":"fe6c4832f544cee0","name":"set delay","server":"","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{payload}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"delay","propertyType":"msg","value":"$abs($entity().attributes.brightness - targetLevel)","valueType":"jsonata"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":300,"y":512,"wires":[["7ea6b7a8bb34e828"]]},{"id":"7ea6b7a8bb34e828","type":"range","z":"fe6c4832f544cee0","minin":"1","maxin":"252","minout":"1","maxout":"24000","action":"scale","round":true,"property":"delay","name":"Delay 255 to 24000ms","x":484,"y":512,"wires":[["b6cc548004100eac"]]},{"id":"3a269a06e641f6c8","type":"function","z":"fe6c4832f544cee0","name":"queue","func":"if(msg.reset) {\n    context.set(\"blinds\", null);\n    node.status(\"empty\");\n    return;\n}\n\nif(!msg.next) {\n    context.set(\"blinds\", msg.payload);\n}\n\nconst blinds = context.get(\"blinds\") ?? [];\n\nif (blinds.length === 0) {\n    return [null, {}];\n}\n\nmsg.next = true;\nmsg.payload = blinds.shift();\ncontext.set(\"blinds\", blinds);\nnode.status(blinds.join(\", \"));\n\n\n\nreturn msg;\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":558,"y":368,"wires":[["c79ad7ce2b60bdb2"],["1664c3e2a56bc6af"]]},{"id":"b6cc548004100eac","type":"api-call-service","z":"fe6c4832f544cee0","name":"Set targetDevice at targetLevel","server":"","version":5,"debugenabled":true,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{payload}}"],"data":"{\"brightness\": targetLevel}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":734,"y":512,"wires":[["3070690827e61cdd"]]},{"id":"1664c3e2a56bc6af","type":"api-call-service","z":"fe6c4832f544cee0","name":"turn off switch","server":"","version":5,"debugenabled":true,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.all_blinds"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":720,"y":416,"wires":[[]]}]
1 Like

Hi everyone, thank you very much for your help. I’ll be halting the development of this sequence until I get my hands on a HA Yellow hub, because I encountered some issues related specifically to my current SmartThings integration.
You’ve been really helpful, I decided to migrate to HA after this test, so I’ll probably come back with news in a month or so.

Rodrigo

1 Like