Author Topic: If door is opened for 5 minutes...turn off air  (Read 37878 times)

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
If door is opened for 5 minutes...turn off air
« on: September 06, 2010, 10:41:22 pm »
I have guests that love to leave the patio door open while sitting outside.  Is there some way trigger something that says if the door is open for so long...turn off the air????
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline raskell

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #1 on: September 07, 2010, 09:01:23 am »
For starters, you can try having the door sensor in the armed state.  You can create an event when the armed sensor is tripped.   On the advanced tab set a 300 second delay (5 minutes).  The command tab action is turn HVAC off.  I have not done this before, but I believe you will also want to create an HVAC resume scene where every 15 minutes or so, turn the HVAC back on if the door sensor is closed.  It is obviously possible to shut off the HVAC immediately when the door opens, so try the delay and let us know how it works for you.
Vera2, UI4, Trane/Schlage TStats(6), Schlage LeverLock, GE 3-wayswitches, WD HA14 3-way dimmers, Intermatic Outdoor Module, Hawking door/window sensor(s), VeraLite UI5, Everspring SM-103

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #2 on: September 07, 2010, 09:44:29 am »
I understand that method, but I am looking for something that, once the sensor is triggered, monitor how long it is opened, if opened at 5 minutes, turn off the A/C.
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #3 on: September 08, 2010, 12:30:40 pm »
Does anyone have any ideas??
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline fall-line

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +1/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #4 on: September 08, 2010, 12:58:36 pm »
So I haven't done this (and I am actually following this thread, hoping that someone who has will reply and confirm), but my strategy would be as follows.


Scene Event: Armed Sensor is tripped

Luup logic:
*Sleep for 5 minutes
* then check status of sensor.
    * If sensor is no longer tripped
              * end.
    * otherwise
              * continue to execute

Essentially what you would have here is the scene firing when the door is opened, but all the scene will do for 5 minutes is sit there watching the clock. Once the 5 minutes has expired, it'll manually (via luup code) check the status of the sensor again, and if it is still in a tripped state, then it'll execute the commands. In your case, it'd be to turn off the AC appliance control module (which is a very good idea btw). In my case, it'd be to send me an email saying you left the door open again.

I think this'll work, and the LUUP code would be pretty straightforward. I could write it up, but I'm sure someone has done it before.

Any comments from those that have done it?

Thanks

« Last Edit: September 08, 2010, 01:33:01 pm by fall-line »

Offline fall-line

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +1/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #5 on: September 08, 2010, 01:29:31 pm »
I think this works. Here is my code:

Code: [Select]
os.execute("sleep 2")

if( luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped",33)=="0" ) then
luup.log("Sensor Not Tripped, ending scene")
    return false
end


Note I have this set to sleep for only 2 seconds for testing, you'll want to change it to 300 for 5 minutes. The other thing you'll want to change is the device id (mine is 33) to match your Device.

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #6 on: September 08, 2010, 03:28:37 pm »
I am basically an end-user, so the code will be an interesting test for me.

Question

Can I test this remotely, or do I actually have to trigger the scene event??
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #7 on: September 08, 2010, 04:22:22 pm »
I tried to get this to work, but I kept getting invalid scene.
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline fall-line

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +1/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #8 on: September 08, 2010, 04:46:32 pm »
Bennynations,

What happens if you paste the code into the LUUP test window and hit go? This window can be found on UI2 in:

Devices -> Luup Plugins -> Test Luup code (Lua) - this last one is a button.

I'm not sure where this is in UI3 or 4, but I imagine it is easy to find.

You should be able to paste it in there and hit go to test, where you can absolutely test it remotely. Just remember you'll need to change the device ID (my example uses device 33) to the device number used by your sensor.

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #9 on: September 08, 2010, 05:24:39 pm »
I found the area and entered the code...it says bad device

I looked at my device and it says that urn:schemas-micasaverde-com:device:MotionSensor:1

My device is number 11

I entered the following:

os.execute("sleep 2")

if( luup.variable_get("urn:schemas-micasaverde-com:device:MotionSensor:1", "Tripped",11)=="0" ) then   
   luup.log("Sensor Not Tripped, ending scene")   
    return false
end

No luck
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline fall-line

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +1/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #10 on: September 08, 2010, 05:48:49 pm »
Both of my door sensors (Both Hawkin HRDS1) also show up in their advanced properties as "urn:schemas-micasaverde-com:device:MotionSensor:1", but when I query the status I found I need to use urn:micasaverde-com:serviceId:SecuritySensor1.. I'm not exactly sure why that is.

I assume you tried my original snipit with just changing the device number as well, yes?


Offline fall-line

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +1/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #11 on: September 08, 2010, 06:04:43 pm »
Also, unless you aere on UI4 you don't need to put the device ID in the "Device Number" field next to the go button, just leave that blank since the device is specified in the code already. If I enter my device number in that field, I get the bad device error as well.
« Last Edit: September 08, 2010, 06:08:12 pm by fall-line »

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #12 on: September 08, 2010, 08:07:12 pm »
I am on Vera2 and UI4.  I got it to work and then saved it in the scene.  Now that I run the scene remotely, I get "empty response."

At least it saved it properly, but I am not sure what to do now.
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline bennynations

  • Full Member
  • ***
  • Posts: 136
  • Karma: +0/-0
Re: If door is opened for 5 minutes...turn off air
« Reply #13 on: September 08, 2010, 08:21:12 pm »
Thanks so much for the help!!  Nice to learn more about this.

Everything is saved and appears to be working.  It is saved as a scene.  When I run the scene, it transmits and turns the air off. 

Is this correct??  If it is checking the status, the door is still closed.  Should it turn the AC off??
2 Schlage locks, Trane Thermostat, Leviton lights and fan control

Offline Les F

  • Hero Member
  • *****
  • Posts: 557
  • Karma: +7/-0
    • When not home, I can be found at the cabin
Re: If door is opened for 5 minutes...turn off air
« Reply #14 on: September 08, 2010, 09:25:45 pm »

Just one extra piece of logic  in case you didn't cover it. 

If door is opened for 5 minutes and air is already off don't do anything.

(you wouldn't want to turn the air on 15 minutes later if it was never on to start with)



Google+ http://tinyurl.com/7hewkbn / Instagram: https://goo.gl/0Hr8K4 / Pinterest https://goo.gl/WjZCQp (Yes, Pinterest is for guys too! take a look)