Hi, I have read umpteen articles on timers, but I’m still stuck after hours of fiddling & tweaking
I’m on OH 3.
Scenario: Detect when wash definitely finished. Trigger rule whenever the power consumption changes, as it will during the wash cycle. Rule checks if power is down and the virtual switch ‘WashStatus’ is still ON… if true cancels any running timer, create a new timer, wait for 90 sec after which check again if power still down and WashStatus OFF. If true, then wash definitely finished so set WashStatus to OFF and send Pushover message.
I tested using a table lamp with sequence; Initially OFF - ON - OFF for 30sec - ON - OFF permanently.
Initial ON produces correct ‘wash running message’ ok.
Problems/errors:
If I move the second countdown cancel/null block to OUTSIDE the timer braces, the ‘Wash done’ message and the WashStatus OFF occur after only ~50 sec. Looks like the timer held onto the previous 30 seconds instead of cleanly restarting…?
A total of FOUR ‘delay timer created’ logs show up and FOUR ‘wash done’ pushover messages eventually arrive!!
If I move the second countdown/null block to INSIDE the timer braces, as in the screen shot, the script refuses to run at all with the error ‘Cannot refer to the non-final variable countdown inside a lambda expression’. I have seen forum solutions saying this is because the timer variable hasn’t been declared as ‘global’.
Hence my other highlighted query on screen shot, it the timer actually global where I’ve typed it? When I tried to ‘shoehorn’ it in at the very top of the code, I got loads of ‘block indentation’ errors.
I’m truly demented by timers and all this chasing/cancelling/resetting… they are like ‘trying to mind mice at a cross roads’ as the Irish saying goes.
Many thanks in advance for your patience and any solutions/suggestions.
Denis