lua access to Vera's modes - home,away,night, vacation

[quote=“akbooer, post:15, topic:182797”]so you could write this:

local mode = luup.attr_get "Mode"
local newMode = ({2,1}) [tonumber(mode)] or 1
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetHouseMode", {Mode = newMode}, 0)

Hope this helps.[/quote]

What does the newMode line mean? Is it an array with the new and the old mode?

Yes.

local newMode = ({2,1}) [tonumber(mode)] or 1

House mode is (or should be) an integer: 1 = Home, 2 = Away, …

This just says that if the mode is 1 make it 2, if it’s 2 make it 1, if it’s neither of those then set it to 1.

There’s an infinite number of different ways of writing this, I just chose this way.

Thanks! Just a got a flashback to bash scripts and c code when manual obfuscation and saving a couple of ticks was all the rage ;D

It’s just a pattern I use sometimes.

Ok :slight_smile:

Is there any advantage to using this over luup.is_night()?

House modes are really nothing to with whether or not it’s night according to the sun.

I’ve been trying to change mode as part of a PLEG action. Is this actually possible? I plugged in the luup code listed above but never could get it to work. Same code worked fine as a scene though…

Is there a list of attributes avaialble somewhere?