Thermostat off When Window is Open. Restore thermostat mode when closed


#1

1) Give a description of the problem
I created this super simple piston to disable my thermostat when a window is opened. Too many times do I come home in the summer to me cooling the outside so this simple piston was the answer. Thermostat off when window is open but not returning to prior state when windows are closed.

2) What is the expected behavior?
When a window is opened the thermostat mode is captured and then the thermostat is turned off

3) What is happening/not happening?
The thermostat is turning off correctly when the window is opened but not turning back on when it is closed. I searched around and found a few people doing something similar and I copied it but for some reason mine isn’t working.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
2/15/2019, 9:56:40 AM +243ms
+1ms ╔Received event [zCS - All Windows].contact = closed with a delay of 56ms
+9856ms ║RunTime Analysis CS > 20ms > PS > 9815ms > PE > 20ms > CE
+9857ms ║Piston waited at a semaphore for 9771ms
+9860ms ║Runtime (37611 bytes) successfully initialized in 9815ms (v0.3.109.20181207) (9857ms)
+9861ms ║╔Execution stage started
+9873ms ║║Comparison (enum) closed is (string) open = false (2ms)
+9875ms ║║Cancelling condition #6’s schedules…
+9877ms ║║Condition #6 evaluated false (9ms)
+9878ms ║║Condition group #1 evaluated false (state did not change) (11ms)
+9881ms ║║Cancelling statement #2’s schedules…
+9894ms ║║Skipped execution of physical command [Ecobee Downstairs].setThermostatMode([]) because it would make no change to the device. (3ms)
+9895ms ║║Executed [Ecobee Downstairs].setThermostatMode (6ms)
+9898ms ║╚Execution stage complete. (38ms)
+9900ms ╚Event processed successfully (9899ms)
2/15/2019, 9:56:30 AM +821ms
+0ms ╔Received event [Ecobee Downstairs].thermostatMode = off with a delay of 68ms
+9089ms ║RunTime Analysis CS > 13ms > PS > 9058ms > PE > 18ms > CE
+9090ms ║Piston waited at a semaphore for 9019ms
+9092ms ║Runtime (37610 bytes) successfully initialized in 9058ms (v0.3.109.20181207) (9091ms)
+9093ms ║╔Execution stage started
+9107ms ║║Comparison (enum) open is (string) open = true (2ms)
+9109ms ║║Condition #6 evaluated true (9ms)
+9116ms ║║Comparison (enum) off is_not (string) off = false (2ms)
+9118ms ║║Cancelling condition #7’s schedules…
+9119ms ║║Condition #7 evaluated false (8ms)
+9120ms ║║Cancelling condition #1’s schedules…
+9121ms ║║Condition group #1 evaluated false (state changed) (22ms)
+9124ms ║║Cancelling statement #2’s schedules…
+9962ms ║║Executed physical command [Ecobee Downstairs].setThermostatMode([]) (829ms)
+9964ms ║║Executed [Ecobee Downstairs].setThermostatMode (831ms)
+9967ms ║╚Execution stage complete. (874ms)
+9968ms ╚Event processed successfully (9969ms)
2/15/2019, 9:56:29 AM +806ms
+1ms ╔Received event [Ecobee Downstairs].thermostatMode = with a delay of 95ms
+103ms ║RunTime Analysis CS > 26ms > PS > 57ms > PE > 20ms > CE
+105ms ║Runtime (37541 bytes) successfully initialized in 57ms (v0.3.109.20181207) (102ms)
+107ms ║╔Execution stage started
+122ms ║║Comparison (enum) open is (string) open = true (2ms)
+124ms ║║Condition #6 evaluated true (11ms)
+131ms ║║Comparison (enum) is_not (string) off = true (2ms)
+133ms ║║Cancelling condition #7’s schedules…
+135ms ║║Condition #7 evaluated true (8ms)
+136ms ║║Cancelling condition #1’s schedules…
+137ms ║║Condition group #1 evaluated true (state changed) (24ms)
+140ms ║║Cancelling statement #8’s schedules…
+148ms ║║Executed virtual command setVariable (3ms)
+151ms ║║Cancelling statement #4’s schedules…
+966ms ║║Executed physical command [Ecobee Downstairs].off() (805ms)
+967ms ║║Executed [Ecobee Downstairs].off (807ms)
+970ms ║╚Execution stage complete. (864ms)
+972ms ╚Event processed successfully (972ms)
2/15/2019, 9:56:29 AM +138ms
+2ms ╔Received event [Ecobee Downstairs].thermostatMode = off with a delay of 80ms
+91ms ║RunTime Analysis CS > 23ms > PS > 45ms > PE > 22ms > CE
+93ms ║Runtime (37538 bytes) successfully initialized in 45ms (v0.3.109.20181207) (90ms)
+95ms ║╔Execution stage started
+111ms ║║Comparison (enum) open is (string) open = true (2ms)
+113ms ║║Condition #6 evaluated true (11ms)
+119ms ║║Comparison (enum) off is_not (string) off = false (2ms)
+121ms ║║Cancelling condition #7’s schedules…
+122ms ║║Condition #7 evaluated false (9ms)
+124ms ║║Cancelling condition #1’s schedules…
+125ms ║║Condition group #1 evaluated false (state changed) (23ms)
+128ms ║║Cancelling statement #2’s schedules…
+590ms ║║Executed physical command [Ecobee Downstairs].setThermostatMode([]) (452ms)
+592ms ║║Executed [Ecobee Downstairs].setThermostatMode (454ms)
+595ms ║╚Execution stage complete. (501ms)
+596ms ╚Event processed successfully (596ms)
2/15/2019, 9:56:19 AM +98ms
+1ms ╔Received event [Ecobee Downstairs].thermostatMode = with a delay of 59ms
+9137ms ║RunTime Analysis CS > 18ms > PS > 9102ms > PE > 16ms > CE
+9138ms ║Piston waited at a semaphore for 9067ms
+9140ms ║Runtime (37610 bytes) successfully initialized in 9102ms (v0.3.109.20181207) (9138ms)
+9141ms ║╔Execution stage started
+9156ms ║║Comparison (enum) open is (string) open = true (2ms)
+9158ms ║║Condition #6 evaluated true (10ms)
+9164ms ║║Comparison (enum) is_not (string) off = true (2ms)
+9166ms ║║Condition #7 evaluated true (7ms)
+9167ms ║║Condition group #1 evaluated true (state did not change) (20ms)
+9170ms ║║Cancelling statement #8’s schedules…
+9178ms ║║Executed virtual command setVariable (3ms)
+9181ms ║║Cancelling statement #4’s schedules…
+9976ms ║║Executed physical command [Ecobee Downstairs].off() (787ms)
+9977ms ║║Executed [Ecobee Downstairs].off (789ms)
+9980ms ║╚Execution stage complete. (839ms)
+9982ms ╚Event processed successfully (9981ms)
2/15/2019, 9:56:18 AM +35ms
+1ms ╔Received event [Ecobee Downstairs].thermostatMode = off with a delay of 61ms
+172ms ║RunTime Analysis CS > 17ms > PS > 139ms > PE > 15ms > CE
+174ms ║Runtime (37543 bytes) successfully initialized in 139ms (v0.3.109.20181207) (172ms)
+175ms ║╔Execution stage started
+193ms ║║Comparison (enum) open is (string) open = true (2ms)
+195ms ║║Condition #6 evaluated true (13ms)
+201ms ║║Comparison (enum) off is_not (string) off = false (2ms)
+203ms ║║Condition #7 evaluated false (7ms)
+204ms ║║Condition group #1 evaluated false (state did not change) (23ms)
+207ms ║║Cancelling statement #2’s schedules…
+1020ms ║║Executed physical command [Ecobee Downstairs].setThermostatMode([]) (803ms)
+1021ms ║║Executed [Ecobee Downstairs].setThermostatMode (806ms)
+1024ms ║╚Execution stage complete. (848ms)
+1025ms ╚Event processed successfully (1025ms)
2/15/2019, 9:56:16 AM +852ms
+1ms ╔Received event [Ecobee Downstairs].thermostatMode = with a delay of 69ms
+77ms ║RunTime Analysis CS > 19ms > PS > 41ms > PE > 16ms > CE
+79ms ║Runtime (37537 bytes) successfully initialized in 41ms (v0.3.109.20181207) (77ms)
+80ms ║╔Execution stage started
+94ms ║║Comparison (enum) open is (string) open = true (2ms)
+96ms ║║Condition #6 evaluated true (9ms)
+103ms ║║Comparison (enum) is_not (string) off = true (2ms)
+105ms ║║Cancelling condition #7’s schedules…
+106ms ║║Condition #7 evaluated true (9ms)
+108ms ║║Cancelling condition #1’s schedules…
+109ms ║║Condition group #1 evaluated true (state changed) (22ms)
+112ms ║║Cancelling statement #8’s schedules…
+119ms ║║Executed virtual command setVariable (2ms)
+123ms ║║Cancelling statement #4’s schedules…
+1139ms ║║Executed physical command [Ecobee Downstairs].off() (1007ms)
+1140ms ║║Executed [Ecobee Downstairs].off (1010ms)
+1143ms ║╚Execution stage complete. (1063ms)
+1145ms ╚Event processed successfully (1145ms)
2/15/2019, 9:56:15 AM +972ms
+1ms ╔Received event [Ecobee Downstairs].thermostatMode = off with a delay of 63ms
+71ms ║RunTime Analysis CS > 18ms > PS > 37ms > PE > 17ms > CE
+74ms ║Runtime (37535 bytes) successfully initialized in 37ms (v0.3.109.20181207) (72ms)
+75ms ║╔Execution stage started
+88ms ║║Comparison (enum) open is (string) open = true (2ms)
+90ms ║║Condition #6 evaluated true (10ms)
+96ms ║║Comparison (enum) off is_not (string) off = false (2ms)
+98ms ║║Cancelling condition #7’s schedules…
+99ms ║║Condition #7 evaluated false (8ms)
+101ms ║║Cancelling condition #1’s schedules…
+102ms ║║Condition group #1 evaluated false (state changed) (21ms)
+105ms ║║Cancelling statement #2’s schedules…
+828ms ║║Executed physical command [Ecobee Downstairs].setThermostatMode([]) (714ms)
+830ms ║║Executed [Ecobee Downstairs].setThermostatMode (716ms)
+833ms ║╚Execution stage complete. (759ms)
+834ms ╚Event processed successfully (835ms)
2/15/2019, 9:56:14 AM +624ms
+2ms ╔Received event [Ecobee Downstairs].thermostatMode = with a delay of 99ms
+95ms ║RunTime Analysis CS > 25ms > PS > 53ms > PE > 17ms > CE
+97ms ║Runtime (37540 bytes) successfully initialized in 53ms (v0.3.109.20181207) (94ms)
+99ms ║╔Execution stage started
+113ms ║║Comparison (enum) open is (string) open = true (2ms)
+115ms ║║Condition #6 evaluated true (11ms)
+121ms ║║Comparison (enum) is_not (string) off = true (2ms)
+123ms ║║Cancelling condition #7’s schedules…
+124ms ║║Condition #7 evaluated true (8ms)
+125ms ║║Cancelling condition #1’s schedules…
+126ms ║║Condition group #1 evaluated true (state changed) (22ms)
+129ms ║║Cancelling statement #8’s schedules…
+136ms ║║Executed virtual command setVariable (3ms)
+140ms ║║Cancelling statement #4’s schedules…
+1304ms ║║Executed physical command [Ecobee Downstairs].off() (1155ms)
+1305ms ║║Executed [Ecobee Downstairs].off (1159ms)
+1308ms ║╚Execution stage complete. (1210ms)
+1310ms ╚Event processed successfully (1309ms)
2/15/2019, 9:56:13 AM +684ms
+1ms ╔Received event [zCS - All Windows].contact = open with a delay of 52ms
+76ms ║RunTime Analysis CS > 18ms > PS > 37ms > PE > 21ms > CE
+78ms ║Runtime (37537 bytes) successfully initialized in 37ms (v0.3.109.20181207) (76ms)
+79ms ║╔Execution stage started
+90ms ║║Comparison (enum) open is (string) open = true (2ms)
+92ms ║║Condition #6 evaluated true (7ms)
+106ms ║║Comparison (enum) off is_not (string) off = false (2ms)
+108ms ║║Condition #7 evaluated false (15ms)
+109ms ║║Condition group #1 evaluated false (state did not change) (25ms)
+112ms ║║Cancelling statement #2’s schedules…
+858ms ║║Executed physical command [Ecobee Downstairs].setThermostatMode([]) (742ms)
+859ms ║║Executed [Ecobee Downstairs].setThermostatMode (744ms)
+862ms ║╚Execution stage complete. (784ms)
+864ms ╚Event processed successfully (863ms)


#2

Based on the lightning bolts on lines 22 and 24, this piston is triggering on the window contact, and the thermostat state. When the window is open and the thermostat is on, this piston turns it off. The change instate is firing the piston again and since the window is open and the thermostat is off, it is turning it on. You appear to be bouncing back and forth between states. If you change line 22 to “changes to” rather than “is”, this piston should trigger only on the window state changing and not the thermostat changing.


#3

You are a genius! Thank you so much. I thought the logs were pretty long for a window opening. Now it makes sense. Now that it’s fixed time to break it and add the second thermostat :smiley:

Since I always like it when people post their final working design here it is! I suspect there was a more efficient way to do the second thermostat but variables are still something I am working to understand so KIS for now


#4

This last iteration has two identical triggers, which can cause issues.
I would combine them into one, something like this:

IF Contact changes to open     <-- Trigger
Then
    Set variable {upstairs}
    Set variable {downstairs}
    Wait 1 second
    Turn off Thermostat 1
    Turn off Thermostat 2
END IF

IF Contact changes to closed   <-- Trigger
Then
    With Thermostat 1 = Set thermostat mode to {upstairs}
    With Thermostat 2 = Set thermostat mode to {downstairs}
END IF

This creates one set of logic for when the window opens, and another for when it closes.
(notice there are no ELSE statements)


Pro Tip:
The reason I removed the extra conditions is because webCoRE is smart enough to not send a turn off command to a device that is already off.
(plus you want to capture the current states regardless of whether the Thermostats are on or off)


Thermostat Mode Change based on Outdoor Temp with Window Sensors
#5

Oh wow! That is much simpler. Thanks for the tip.
New Final!


#6

Clever.


#7

thank you ShaggySS for posting your final solution, wish everyone would do that rather than disappearing or just saying i fixed it…

i will use the code, pro tip is interesting, which was what i’m doing anyway. i’m in progress of making code to change the mode of the thermostat based on outside temp with window sensors…


#8

So what if you have 20 contact sensors what do you do? if you add multiple contacts and one window opens if will switch off, and then when the next window opens it will overwrite the previous state of the thermostate.

lots of possibilities… do i need to put a if statement around the body of if’s…


#9

here is my final solution in this post:

the only thing i’ve added was some push notifications…


#10

anderep. Sorry for the delay. In answer to your question I grouped my contact sensors together. So upstairs windows are a group, downstairs windows are a group and then I grouped both of those into a master “ALL Windows” group. I did this by creating a virtual contact sensor and then if x windows are open change virtual contact sensor to open.

This may look a little confusing because I also do it for light. Simple look at my action tiles dashboard shows me window\light status.


#11

Looks good. I chose not to use is open, I wanted windows open to only trigger when windows open, so I could over ride at the thermostat and not fight the piston.


#12

Smart.

I am a big fan of automation as long as I can still keep my free will, LOL
(which is why I rarely use Conditions as Triggers)


#13

I misspoke…
I use ‘changes to open’ in my hvac piston to turn off/on hvac when my global variable for windows open/close


#14

This code has 1 problem. It’ll shut down the HVAC when doors are open even when the thermostat is NOT calling for cooling or heating. Ideally, it should only shut it down if at that point in time HVAC was actually cooling or heating.