Cycle through outputs

Hi,

I am trying to program the below scenario which in essence fires a different output every time a button is pressed, in a loop - the purpose is for scene selection with a Shelly device.

Button press 1 (this is a shelly button press) = Scene 1
Button press 2 = scene 2
3 = scene 3
4 = scene 4
loop returns to the top and the next button press = Scene 1

The idea is that node red holds the logic and record as to which scene was selected last. I am not overly concerned about reboots etc, just need this logic.

Any ideas?

Thanks.

Have you looked at context saving? Button press one context.set('button',1) button press two Button = context.get('button') + 1 and so on?

The easiest way is to store the 'scene' into a variable and compare against it.

gerry was quicker.

You could easily adapt this to output "Scene x" instead of colours:

Thanks,

The shelly device sends an MQTT command which is the same trigger each time. What this trigger needs to do is ramp up / step through outputs that are then connected to actions/light outputs.

I need to create a way to recall a scene (or whatever it may be) and store this.

I am not sure where to start on a function node.

Thanks.

Google for context.set as a start. Try to program a function node and if you get stuck come back for help, we'll be around