Create click-counting scenes

To optimize a simple Sonoff button with 3 functions (single click, double click and long press) I had already set up a series of scenes controlling lights and increasing their brightness with successive single clicks.

However in the bedroom at night, it’s not very nice to have to go all the way to max brightness before returning to off.

So to keep multiple brightness levels on the single click I thought Gladys should be able to count them.

Ok so, go to the MQTT integration > new device > feature: integer counter…

Now I need to ask Gladys to monitor a single click followed or not by another to execute an action

I therefore have a first scene :

Trigger: single button click (value 1)

Retrieve counter state

Continue if counter = 0

  1. and 4.
    Set device counter = 1
    Wait 1500 ms


Retrieve counter state

Continue if counter = 1

detail: variable selection

Run appropriate scene
Set device counter = 0


Other scenes can then follow by adding 1 except on the last line

However it doesn’t work! And I don’t understand why?

Add an action before step 4 to retrieve the counter state.

Include screenshots to explain.
That will help others create a similar scene.

Correction: I updated it, it was an omission in the post but it was present in the scene

Post edited with screenshot: OK!

If it ever ends up working…

It’s stupid, but in my head it worked fine!

In part 3, aren’t you setting a value for your counter?

Indeed, in my capture there isn’t one and, strangely, when I re-added one it was impossible to save the scene with an error message.

In any case, I did have one during my previous tests

I recreated a complete one starting from a blank scene…

Still no result…

Unfortunately I can’t display the counter on a dashboard to debug…

I figured the counter’s initial value might be the issue, so I created a scene to reset the counter to 0, but it’s still no better.

Send yourself Telegram messages with the counter value at each step

1 Like

When I want to insert the variable with « {{ » I’m not prompted to select anything, unlike in the tutorial by @pierre-gilles Envoyer un message | Gladys Assistant.

Could the problem lie in retrieving the variable?

I just tried it, it works well

The suggestion appears after I put a space after the 2 curly braces.

I may not have put the space…

If I have the time, I’ll try to reproduce your scene at my place tonight or tomorrow.

1 Like

Mea culpa for sending the variable — you need to include the space and it works on its own !

Also, it would be good to indicate this need for a space in the short explanatory text (see copy above)

I’ll include notifications for every change on the counter to see what’s happening…

I’ll get back to you this weekend at the latest.

If this can help you, actually your scene is stuck at step 2 because your counter doesn’t contain any value.
I tested by sending a Telegram message and here is the result

image

In the scene I just inserted an action Send a message to check the counter value

You need to initialize your counter to 0 once for this to work.
To do that you can create a scene with just a Control a device action and set your counter to 0 and use the start button to run your scene once.
@pierre-gilles could we have a way to initialize a fake MQTT device with a value when it is created?

So your scene may still be stuck afterwards — that’s the case for me.
Testing the integer counter « equal to 0 » or « equal to 1 » does not work! I’m forced to test with « less than or equal » or with « greater than or equal »

I set « less than or equal to 0 » and then « greater than or equal to 1 » and the scene runs completely


@pierre-gilles is it normal that you cannot test equality on an integer counter in the Continue only if action?

I had also thought about the initialization…

In any case, a big thank you to you @_Will_71 for looking into my problem…

I’ll look into refining the logical operators of this series of scenes by avoiding the 'equal to ’

Besides, we agree that an integer counter means that the values are natural integers?

I don’t understand the 20:44…

At 20:44, sorry, I should have deleted it — it’s just the time the Telegram message was received.

Sorry for the stupid thing I just wrote at 20:44

I hadn’t seen your reply when I was talking about my stupidity…

But I had just tested:

And so had just understood about the timestamp…

But I do get a response for the scene’s initial 0

By replacing my first absolute equality check with:

I do get a return up to the second absolute equality test…

So that’s indeed the source of my troubles