We have moved at community.getvera.com

Author Topic: How to query auto-away status in lua?  (Read 1273 times)

Offline Ben

  • Sr. Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
How to query auto-away status in lua?
« on: July 23, 2014, 05:52:49 pm »
Hi folks,

I'm using the auto-away feature of the Nest as a trigger to turn off a power outlet so I can save electricity on due to certain devices being in standby mode. I've also got Vera to switch the same outlet off over night, again to save power. However it makes no sense for me to power that outlet back up in the morning if Nest knows we're away (auto away = AWAY). But how do I get that auto-away status in lua?

thanks
Ben

Offline watou

  • Moderator
  • Hero Member
  • *****
  • Posts: 889
  • Karma: +44/-12
Re: How to query auto-away status in lua?
« Reply #1 on: July 23, 2014, 06:27:40 pm »
I'm using the auto-away feature of the Nest as a trigger to turn off a power outlet so I can save electricity on due to certain devices being in standby mode. I've also got Vera to switch the same outlet off over night, again to save power. However it makes no sense for me to power that outlet back up in the morning if Nest knows we're away (auto away = AWAY). But how do I get that auto-away status in lua?

The Nest thermostat has two distinct "away" concepts: one is the "auto away" mode which switches the house to "away" mode automatically after some period of time of not detecting movement (either by thermostats or the Protect smoke/CO detector).  The other concept is the home vs. away mode, which will either be controlled manually by you from the physical thermostat, web, mobile app, or Vera, and/or set to away automatically as described.  So I think you're interested in the second concept, the simple home vs. away switch trigger and setting.

You can use the trigger for the home device for Nest when the device is set to home or set to away.  Or, in Lua you can do something like this:

Code: [Select]
local HOME_DEVICE = 37 -- replace 37 with the device ID of your Nest home/away device
local isHome = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", HOME_DEVICE) == "1"

if isHome then
 -- do something when the home device is set to home
else
 -- do something when the home device is set to away
end

So if you want to use the changing of the status as the trigger, it's available in Vera UI.  Or, in whatever other Lua code you're using, you can use something like the snippet above to determine the current state.

watou

Offline Ben

  • Sr. Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
Re: How to query auto-away status in lua?
« Reply #2 on: July 24, 2014, 03:39:57 am »
Thank you watou, I think that's just what I wanted  :D