In a rule I would like to start an independant timer at a certain event. What I mean by independant is that if that event occures, the timer should start, regardless of what happens in the rule thereafter. The rule might complete its' actions and exit, but the timer should still be running. If and when the rule engages again, the rule should be able to consult the timer to se how long time has progressed since it started. And finally, after a given time, the rule should be able to perform an action based on the timer. Is that possible?
Thank you for your swift reply. Yes, the timer should then reset.
In addition to the desired functionality I mentioned above, the timer, if and while running, should also be able to act as an override function in the rule. I.e. as long as the timer is running, some parts of the rule should not engage/change. When the time is up, the rule goes back to normal.
I know you've explained technically what you are wanting to achieve, but I think it may also help to explain what situation you are trying to automate, i.e. what do you want to use this rule for?
I am building a thermostat in Rule Machine for my air-to-air heater, which you @sburke781 have been kind to help me with before. The general theme of this thermostat is centred around conditions governed mainly by, but not exclusively, various scenarios of inside and outside temperature.
A context to this question is that the rule I have built is too big for rule machine and while struggling to learn to create an app using Groovy, I have started to contemplate breaking up the rule in several rules and having a main script call smaller rules. Thinking in these terms of a 'modular rule' I became curious as to if it would be possible to have a timer in separate rule to call in general and for instance in the situation below.
Before going any further, I should say that there are alternative solutions/workarounds to the situation by using other sensor values, but in essence the scenario is as follows.
The rule works fine until it starts to rain. When it rains some situations that would normally render the heat pump to turn off, should now instead turn the heat pump on, supplying heat. The situation where the timer comes in is when it stops raining. When the rain stops the thermostat will act as if it has never rained. But I want to keep heating indoors for a period of time after the rain has stopped. One way of doing that would be to set a timer to start when the rain stops. During this time the thermostat should in principal act as if it was still raining.
For that scenario you may want to keep or reference an indicator of whether it is raining, then have your rule use a sticky trigger, i.e. it stops raining and stays that way for X minutes. This could be used to turn the heating off. I believe if it started raining again the trigger would not fire, leaving the heating for a bit longer, essentially resetting the timer.
Thanks @sburke781 ! That would do the trick And yes, I have two variables, one that keeps track of if it is currently raining and one that keeps track of if it has rained within the last hour. I could keep track of one of those.