Turn off HVAC when windows/doors open

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Sat Mar 24, 2012 2:44 pm
philc offline
Posts: 156
Joined: May 17, 2011

Turn off HVAC when windows/doors open

Okay, let me start by saying I'm sorry. I just do not have the time to "soak" in Python or Applescript long enough to learn it, so I really do rely on the fantastic community built around Indigo....

I have used Berkinet's awesome plugin to integrate my AD2USB device into my Indigo setup. Indigo accurately reflects the state of all my alarm sensors now - just fantastic. I also have my Venstar thermostat integrated into Indigo - it's working flawlessly. So now, with spring coming on (rather, already here!) I want to coordinate the two. So, if I open a window or door (alarm faults) and leave it open for more than thirty seconds, I want the thermostat to turn off any heating or cooling mode. If all the windows and doors close (fault clears), HVAC comes back on.

Jay wrote a great Python script for me that involves a similar action for my bathroom exhaust fan - light stays on for one minute, exhaust fan turns on. I tried to modify that script to turn off the HVAC based on the alarm state...but I made a mess of it. Mainly, I don't know how to refer to the device state in Python, and I don't know how to communicate to the thermostat. If someone has time, you can give me a fish or teach me to fish - I'll be happy either way.

Appreciate the support in advance.

(Moved this post from the Applescript forum - oops).

Posted on
Sat Mar 24, 2012 5:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Turn off HVAC when windows/doors open

Point me back to the other post with the script and I'll see what I can do...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Mar 24, 2012 5:12 pm
philc offline
Posts: 156
Joined: May 17, 2011

Re: Turn off HVAC when windows/doors open

Jay,
Really appreciate the offer to help. Here's the link to the other script:
http://www.perceptiveautomation.com/userforum/viewtopic.php?f=7&t=7853

Phil

Posted on
Mon Mar 26, 2012 10:05 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Turn off HVAC when windows/doors open

Unfortunately, I can't help you much beyond the controlling the thermostat part - I don't use the ad2usb plugin so I don't know what states are involved. Here's some example code on how to manipulate a thermostat from Python.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Mar 26, 2012 12:17 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Turn off HVAC when windows/doors open

Jay: The ad2usb devices support states[' onOffState']

Posted on
Mon Mar 26, 2012 4:42 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Turn off HVAC when windows/doors open

I don't believe that answers the question really - perhaps you can elaborate for the user?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Mar 26, 2012 5:26 pm
philc offline
Posts: 156
Joined: May 17, 2011

Re: Turn off HVAC when windows/doors open

Okay, so here's how far I am. Pretty sure it's wrong, but figured if you guys took the time to help me, I could take the time to start writing stuff.

# get the alarm object
alarm = indigo.devices[639799681]
# if the alarm is faulted
if alarm.onState:
# turn off the heater/air conditioner
indigo.thermostat.setHvacMode(513557825, value=indigo.kHvacMode.HeatCooloff)

I've set the alarm device number to the alarm keypad - it shows faulted or clear.
I'm not sure what alarm.onState is doing for me, if anything. Probably need berkinet's help here.
The final line should be good to go based on the link Jay provided.

The plan would be to put this in a trigger that activates when the alarm faults. The trigger delays for half a minute, then runs the script above to check if the alarm is still faulted. If so, it would turn off the HVAC.

Sorry to be such a numpty...appreciate whatever eyeball feedback you can give. Would like to have the script pass professional muster before I start wearing out the WAF by opening and closing windows like a mad man!

Posted on
Mon Mar 26, 2012 7:03 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Turn off HVAC when windows/doors open

Good start, but...

Try this:
Create a trigger so that when the device state of the ad2usb device becomes faulted it executes a delayed action to turn on the fan after 30 seconds. Then, use this script for the action. Create one trigger for each device that will control the HVAC.
Code: Select all
alarmDevice = indigo.devices[AD2USB-DEV-ID]
if alarmDevice.states['onOffState']:
        indigo.thermostat.setHvacMode(513557825, value=indigo.kHvacMode.HeatCooloff)

I can't vouch for the last line since I don't have a Venstar and can't test it.

Of course, you still need a way to re-enable the HVAC. One way to do this is to have an action associated with the trigger that enables a scheduled action that runs every 15 minutes or so and tests if the alarm keypad device state is "ready" - if the panel is "ready" then the action turns on the heater and disables the scheduled trigger.

Posted on
Mon Mar 26, 2012 7:13 pm
philc offline
Posts: 156
Joined: May 17, 2011

Re: Turn off HVAC when windows/doors open

Thanks Berkinet!

So I can start to learn to fish (or Python, as the case may be), can you help me understand what the syntax in the second line is saying?

I'm reading it this way:

If the variable alarmDevice, defined in the previous line, exhibits a state of 'onOffState' then go to the next (indented) line. Is that correct?

'onOffState' seems a little ambiguous; i.e., does 'onOffState' = alarm keypad shows fault?

As for re-enabling the HVAC...can't I just have a trigger that enables the HVAC when the alarm goes back to ready? Why do I need to poll the keypad? Does it not report when it returns to ready?
Thanks
Phil

Posted on
Mon Mar 26, 2012 7:51 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Turn off HVAC when windows/doors open

philc wrote:
...So I can start to learn to fish (or Python, as the case may be), can you help me understand what the syntax in the second line is saying?

I'm reading it this way:

If the variable alarmDevice, defined in the previous line, exhibits a state of 'onOffState' then go to the next (indented) line. Is that correct?... ...'onOffState' seems a little ambiguous; i.e., does 'onOffState' = alarm keypad shows fault?

It is a bit cryptic. First, alarmDevice.states is an array and 'onOffState' is an element in that array. In this case, onOffState is a boolean. That is, it is either True of False. The line could also be written:
if alarmDevice.states['onOffState'] = True:

However, this line is, in fact, in error (my error). Since we are testing for a fault we really want the False condition. So, this should correctly be:
if not alarmDevice.states['onOffState']: (or if you prefer: if alarmDevice.states['onOffState'] = False:)

philc also wrote:
As for re-enabling the HVAC...can't I just have a trigger that enables the HVAC when the alarm goes back to ready? Why do I need to poll the keypad? Does it not report when it returns to ready?
I am not sure that would work. Consider the case where two windows are opened. Then 20 minutes later, one of the two is closed. In the scenario you suggest, the HVAC system would be re-enabled.

To be honest, this should really be dealt with in a more cohesive manner, with one script, or plugin, managing the whole enchilada. Let me think about this a bit more - or maybe someone else has some ideas. But, in the meantime, what you have so far should work.

Posted on
Fri Apr 27, 2012 3:27 am
philc offline
Posts: 156
Joined: May 17, 2011

Re: Turn off HVAC when windows/doors open

Just wanted to follow up on this thread in case anyone wants to do the same:

Matt (of Indigo) suggested I use variables instead of Python (in response to a feature request I made)...Not as elegant, but doesn't require me to invest in learning Python (yet)...

So I have a trigger to change a variable to true if the alarm faults, with a delay of 30 seconds so that it does not do so for transient conditions. (There's a second action to reset the variable to false six seconds later, so that it can be ready for the next time).

I have a second trigger that fires when the variable is true. The action of that trigger is to turn the HVAC off.

I have a third trigger that fires anytime the alarm returns to "ready to arm", and it turns the HVAC on. HVAC comes on and resumes its settings. Importantly, my Venstar will still receive set point changes, etc., while it is off - a good thing. For instance, Indigo dials down the heat and cool set points every night around 8pm. The other night we had the windows open from 7pm to about 8:30pm. When the windows closed, the thermostat came on with the correct (post-8pm) set points.

Realize this isn't a plugin solution, but it started out that way, so I've kept it in this thread.

Posted on
Sun Aug 19, 2012 1:08 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Turn off HVAC when windows/doors open

I just wanted to drop in here, and point out that the newest version of Switchboard can now help with this.

You can tell from the State's inside the monitored device groups, if any of the devices are open. So for example, a monitored device group that contains the windows, would be able to easily tell if you if *any* of the windows are open.

So a single trigger can be made:

Trigger:

Type * Device State Changed
Device * Your Thermostat (eg Venstar)
* Mode Changed to Cool
* Becomes True

Condition -
If Device <Monitored Device Group (eg Windows and or Doors>
* Number of Devices that are current Open / Triggered
* Is Greater
* 0

Actions -

* Control Thermostat
* Device - Thermostat Device (eg Venstar)
* Action - Set Main Mode
* Mode - All Off

This trigger, waits for the Thermostat to be turned On to AC Mode, and then checks to see if the Windows are open, and if so turns the thermostat back off.

Another action could be added for a reminder, both Email, or a spoken alert from Indigo.

This thread also contains some other ideas regarding thermostat / window / door interactions...

viewtopic.php?f=33&t=8376&start=30

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests