Beginner question: motion sensor and counters does not work as expected

Have a piston like this:

  • IF motion changes to active THEN
    • Set number variable {@motion} = {@motion} + 1
    • Wait 20 minutes
    • Set number variable {@motion} = {@motion} - 1

After a day I now have 13 running pistons, and {@motion} is 104.

Is there something that I do not understand?

Post here.

I’m guessing that the pistons are hitting the limit of the number of timers a smart app can initiate if each motion starts a 20 minute timer.

What exactly are you expecting it to do? Remain at zero?

Are you trying to count the motion triggers?

Set a variable number to control something else during the 20 minutes?

Whenever the piston triggers again, the action automatically overrides the pending tasks (ie decrease the var). You may want to set the override scope to None for that action so that all scheduled decreases do eventually happen…

Wha are you trying to achieve though? There may be other (better) ways…

Ady, is there a timer limit an app can start? I don’t remember where I saw it or maybe I imagined it from reading all the posts here lol.

Ah, thanks. If there is a maximum limit on timers that can be the reason.

I would like to implement conditions in other pistons to act when the time since the last (of a set of) motion sensors turned active exeeds 20 minutes.

Like, if I enter the room 15:00 and leaves immediately, and enters again 15:15 and leaves 15:18, I can turn off the light not before 15:35. It is important that the lights do not turn off at 15:20.

To do this I have a piston that says:

  • IF {@motion} drops to 0 THEN turn off the light.

Maybe there is a simpler way to achive this?

I saw that thread, but I felt it was very difficult to get track of the question and answers when they are mixed within a single thread. What is the reason why you want it that way?

I just thought that as you are having a problem with a piston and you are looking for peer assistance with the issue, then that was the appropriate place to put it.
Please feel free to put your query where you wish.

Ah, disabling current piston when re-running again. I did not know that. It explains everything.

However see my other response here with a description of what I am trying to achieve…

@andreassolberg It should work if you set the TOS to None on all actions that alter the variable (increase, wait, decrease).

I would do it differently though. Set a global time variable to $now + 20 minutes. No need to wait and decrease anymore (lighter on resources too). Then the lights off piston should compare the time larger than the global variable…

@eibyer any SmartApp has a physical limit of 4 timers. A CoRE piston never uses more than two of the four available slots. You can have unlimited waits but watch for the overrides. By default, any action that runs will automatically cancel any timers previously set by the same action. Setting TOS to None will fix that, but you run the risk of overschedulling - get the piston to run so often that it hits the 60 runs per minute limit.