I’m setting up some rules with a variable delay. Each time the rule is run it increments a counter. I wait a time interval based on this counter with a base of 30 seconds. A count of 1 would be 30 seconds, 2 would be 33 seconds, 3 is 36, and so on. The math would look like this:
You are correct. It should be 1 not x. Otherwise that’s how the code evaluates.
I could simplify it by not being OCD about the numbers.
It is easy in code but feels messy in RM. It might morph into an app but for now I’m leaving this part in RM. I’m reworking some core automation and still getting a handle on all the moving parts.
I have moved the motion event and resulting calculation into my core app. I wasn’t ready for that yet but it went better than expected. Now the RM piece is just a widget that handles the delayed and cancelable pieces.
In this picture the motion sensor has been triggered 7 times. This results in the lights remaining on for 9 minutes and 36 seconds if the sensor doesn’t get tripped again.
The counter cools down by 1 every 6 minutes. It caps out at 40 which will give an on time of 5x the base duration (6 minutes in this example).
These numbers need to be adjusted. Previously the duration was static and would vary based on time of day (morning: 180 seconds, day: 300, evening: 240, night:180). I see that 6 minutes should have been 5. Now that I have some logic in there I’ll play with the formula and values.
This started out as a rewrite of the color temp and dimmer level logic. I wasn’t quite ready to tackle the triggers but what ya gonna do?