I had to do my own integration to my HVAC vendor's API, so I use a virtual thermostat on my C7 and have a rule that watches for changes to the virtual device. When the virtual thermostat settings are changed, the rule sends a http request to the API.
In the case that's causing an issue, I have a morning routine that is triggered by another a virtual switch turning on. That triggers several 'wake up' actions for lights and also changes both the heat set point and the cool set point of the virtual thermostat.
The rule I'm trying to troubleshoot has 4 triggers for virtual thermostat states: heat set point changes, cool set point changes, fan mode changes, or operation mode changes.
So each morning both the cool set point and heat set point change at the same time (or as close to the same time as can occur).
app:10162022-11-01 08:07:52.814infoTriggered: Cool setpoint of Thermostat(75.0) *changed* app:10162022-11-01 08:07:52.490infoTriggered: Heat setpoint of Thermostat(66.0) *changed*
I tried to prevent double activations by using a required condition of 'Private Boolean = true' and having the first step of the rule set the private boolean to 'false', but that is happening AFTER the double activation:
app:10162022-11-01 08:07:53.099infoAction: Set Private Boolean(false) False app:10162022-11-01 08:07:52.877infoAction: Set Private Boolean(true) False app:10162022-11-01 08:07:52.814infoTriggered: Cool setpoint of Thermostat(75.0) *changed* app:10162022-11-01 08:07:52.490infoTriggered: Heat setpoint of Thermostat(66.0) *changed*
The second trigger occurs before the first trigger can set the private boolean to false.
I'm also delaying the http call to the API by 5 seconds (cancelable) but the same thing happens there... the actions are following so close behind one another that the 'cancel delayed' actions for the second instance is called before the delayed action is set by the first instance.
I think I have a way to fix this, but just want to make sure there isn't a better way. What I was thinking of doing was having a rule with the four triggers that turns on a virtual switch. That virtual switch would be set for 'auto-off' after 1 second. Then I would use that virtual switch as a trigger to send the http request to the API. That way, no matter how many times the virtual switch rule gets triggered within that 1 second, the API call can't be re-triggered since the virtual switch will be saying (for those who get the Super Troopers reference) "I'm already turned on man! I can't turn on any further!"
That seems a little clunky, so I just wanted to check here first to see if there is a cleaner way to do this within the rule first.