How to cycle though scenes, with a smart switch

Hi there.

I have been trying to rack my brains trying to work out how to do the following in my kitchen.

I have five active light scenes set up in my kitchen:

Scene 1, Scene 2, etc.

I also have a 4-button Styrbar - I have two buttons unused (the down button, right).

Here is what I am trying to do - pressing the right button will turn on the last scene that was selected and pressing right will cycle forwards through the scenes continuously.

E.g. 1, 2, 3, 4, 5, 1, 2 etc.

Pressing down will then turn of all the lights (scene 6),

Any advice with this would be much appreciated.

You need a way to keep tabs on what scene is active.
This can either be done in a helper in HA or by context data in NR.
A helper in HA is the easier one, because you can just use service calls to set the helper.

Context data in NR is maybe a bit trickier at first, but it opens up for another dimension of possibilities in NR once you can store data from run to run.
https://nodered.org/docs/user-guide/context

1 Like

Thanks Wally.

I have a read of the link a good couple of times and I really am struggling to get my heard round this.

Sorry to be a pain but could you perhaps point me in the direction of a diagram, similar to what I am trying to do?

[{"id":"832c35ec0388a3b7","type":"function","z":"be03f9025a1f137a","name":"Extract context data","func":"var scene = flow.get(\"activeScene\") || 1; // get the stored value, If it is first run, then value do not exist, so sets it to 1.\nflow.set(\"activeScene\", scene);\nmsg.scene = scene;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":715,"y":885,"wires":[["e34e82938684e380"]]},{"id":"36a15c4ed33a9148","type":"inject","z":"be03f9025a1f137a","name":"Get value","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":495,"y":885,"wires":[["832c35ec0388a3b7"]]},{"id":"e0679d893ed7c1ba","type":"inject","z":"be03f9025a1f137a","name":"Increment value","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":515,"y":930,"wires":[["3259526740e1d1ef"]]},{"id":"3259526740e1d1ef","type":"function","z":"be03f9025a1f137a","name":"Manipulate context data","func":"var scene = flow.get(\"activeScene\") || 1; // get the stored value, If it is first run, then value do not exist, so sets it to 1.\nscene++;\nif (scene>6) {\n    scene=1;\n}\nflow.set(\"activeScene\",scene);\nmsg.scene = scene;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":725,"y":930,"wires":[["38d597b19e48eb70"]]},{"id":"e34e82938684e380","type":"debug","z":"be03f9025a1f137a","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":885,"wires":[]},{"id":"38d597b19e48eb70","type":"debug","z":"be03f9025a1f137a","name":"debug 21","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":930,"wires":[]}]

I figured out with help from this video

I made the top of an insteon switch switch 3 scenes. to use insteon switchlinc I included commands in the scenes to set my dimmer to 99% so I can turn it β€œon” again, triggering the next scene. I included a command to reset the drop down helper to the 1st preset on my off scene

1 Like