Virtual Switch in Condition

Hi all,
I have created a simple RM routine that turns on an air conditioner if a given room gets too hot, and turns it off once it's cool. See attached. To toggle this automation on and off, I created a virtual switch that I used in the conditions for the temperature automations. The temperature triggers work great, however, it is running regardless of the switch state. Could really use some help here, I'm sure it's basic user error :slight_smile: Thanks!

Your only action is to turn it on as you don't use any conditions to turn it off.

What is the trigger you have set for the rule to run?

I gather what you want to do is turn on the air con if the temperature is >68 and then cool the room to a certain temperature. Is this right?

1 Like

Hi, thanks for jumping on this for me! You're correct. I have a separate rule to turn it off if temperature becomes < 66. Below is a better picture of the turn on rule.

You don't need a second rule just add in after turning it on wait for the temperature to become something like 65 and then turn off.
You will want the off temperature to be a bit below the trigger to stop the rule constantly turning on and off.

Like so? Thank you for helping me fix my poor rule structure lol. i still don't know why the virtual switch condition fails though...

You need to use wait for event not an if statement.
This will immediately check to see if the temp is less than 66 and it won't be so will never turn off.
The wait will in effect pause the rule until the temp equals 66 then turn off.

The virtual switch condition doesn't work because you aren't using it anywhere in the rule.

Alright, I think I have this working nicely. Thank you so much for your time and patience. Below is the rule, and it's performing as expected. Do let me know if you see anything I can improve or debug here.

I get what you are doing now.

You would need to add an end if after the first if statement. Also should be wait for event as this is less taxing on the hub.

However I would do it this way

IF Auto Air Conditioning is off then
exit rule
On: Bedroom Air Conditioner
Wait for Event Temp <66
Off: Bedroom Air Conditioner

You could encase the "Off: Bedroom Air Conditioner" in the same if statement you already have if you want it as an override to keep the air conditioner on even if it goes below 66 after the rule has started.

1 Like

I made the recommended changes, and it's working beautifully. This may be an ignorant question, but what happens if the air conditioner is turned off manually before reaching the cooling set point, then is automatically re-activated by the rule? Is the first "instance" of the rule still waiting for the Temp Event, or does it simply start over?

Yes the first instance is still running.
If you give the wait for event a time out period this will deal with it.

You would need to make it longer than it would actually take to cool the room.
i.e. if it takes roughly 20 minutes to cool the room make the timeout 25 minutes.

1 Like

Ok, I applied a reasonable timeout. Does the same apply for the rule trigger? For example, if the temperature is reported above the setpoint even when the rule is already running, will it open another instance of the rule and have both instances waiting for the low temp event?

It would only trigger the rule again if the temperature goes above your trigger level then goes below it and then above it again which I would imagine is unlikely if the air con is running.
Either way if 2 instances of the same rule are running they are waiting for the same event so it shouldn't be anymore taxing on the hub.
You could use a private boolean to only have one instance running if you really want.

IF Auto Air Conditioning is off OR Private Boolean True then
exit rule
On: Bedroom Air Conditioner
Set Private Boolean True
Wait for Event Temp 66 timeout --> x minutes
Off: Bedroom Air Conditioner
Set Private Boolean False

Hi @cjtman.theriault

Did you manage to set the air conditioning controls into the HE dashboard? Which template should I use?