Home vs. Away - How?

My transition from X-10 is going well. The VeraLite is up and running and I have some lights (especially the Christmas lights!) on schedule.

I need to understand something and maybe you can help.

In my old home automation system I had the concept of “states” - “home” or “away”. Things worked differently in each state. For example, lamp timings were different; I didn’t care about door sensors when I was home, but I did when away. The thermostat might have a different program when I was home vs. away. Etc.

In my old system I would create two different “loads” for my Smarthome controller. I would just Open the proper file and download the “program” into the controller when I wanteed to change “state”.

How would I do he same for my VeraLite? In other words, I want a set of scenes to run normally when home, and then switch to (or activate) a different set of scenes when I go away. I suppose using Backup/Restore might work, but that sounds a bit crude.

Advice please!

Thanks, Bob (beachboync)

You could use Virtual Switch to indicate you are home or away.
I also use Day or Night to indicate day or night state.
Then you can use Program Logic Event Generator to customize the events that you
use to trigger these scenes.

I have scenes:

[ul][li]Arrive at Night - Turn lights on when enter from exterior doors
Or Driveway activity and Garage Door opens[/li]
[li]Arrive - Set Thermostat to occupied settings[/li]
[li]Leaving - Set Thermostat to unoccupied settings … turns off all lights … locks all doors.
This has a sophisticated trigger … Double Click Hallway lights, Garage Closes, and Driveway activity in that order in less than 10 minutes.[/li][/ul]

Yes. People have gone down this road before.


I am using this for when I’m away for a longer period than normal.

OK, did some reading. I see that I have to install the Virtual Switch, then write the Lua code

If (virtual switch is for example on=away) then return true else return false

and put that in all my appropriate scenes.

time to start getting up to speed on Lua.

Thanks, Bob (beachboync)

What I did was create a Scene “ARM ALARM”, “DISARM ALARM” when I am away or arriving.
But lately I’m using behaviors to automatically detect when someone is in home. Easily I can know that someone enter my house when a PIN is Entered in the Lock… I run an scene and prepare the house for people in it. The interesting part was how I detect the people leave the house. Basically what I did was check the LastTriped of movement sensors and LastTriped of the Main Door sensor. If the door was close after the last movement and no moment in 30 min I automatically set the house in AWAY mode. I checked this every 30 min when is not night.
Now with the Thermostat, is much better because I can save lots of energy.
My next step is to create the AWAY Virtual Switch instead of the ARM and DISARM but keep the automation.

I know it wasn’t the response you were looking but I hope it can help with a new vision.

Best Regards,

This may or may not help you, but I am using my Nest’s Home/Away sensors to trigger scenes for the rest of the house. There is a NEST plugin that was recently released for Vera.

Thanks all. Good stuff.

Re: Nest - that us good news as I am shopping for a thermostat!

Hi Experiment,

That it is an interesting approach.

Any chance you can post your Away Detection code and how you activate it?

Any chance you can post your Away Detection code and how you activate it?

Using Program Logic Event Generator you could:
Create a Motion trigger for each motion detector: Motion1 … MotionN
Create a MainDoor trigger;

AllIsQuite = (Motion1;MainDoor) AND (Motion2;MainDoor) … AND (MotionN;MainDoor) AND (MainDoor;Now > 30:00)

Then trigger your Away scene(s) when the PLEG satisfies condition AllIsQuite

What this is saying is if the MainDoor trip time is greater than each of the Motion Detector’s trip time and it’s 30 minutes since the door was tripped than trigger.

Personally I use the following for exit:
Leaving = (HallLightOn @ 2 < 30) AND (HallLightOn; CloseGarageDoor; DrivewayActivity < 10:00)

I have to walk through a hallway to get to the garage. I always flick the light ON/Off/On to indicate I want the house to shutdown behind me.

Thanks Richard.

I haven’t got as far as the PLEG yet. I will have a look for docos explaning it’s syntax.

Hi guys. Christmas is over and back to work!

EDITed to give better example:

I have installed the Virtual Switch, but I am not up to speed on Lua/LUUP yet, and also need to know what the device variables (or properties?) are. For example, I think I need to test a value like

local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, 5)
if (lul_tmp == “1”) then
–something to do goes here

I assume in this example that SwitchPower1 is a property of the device, Status returns on or off (or 1 or 0) and 5 is the device number. Correct?

I think I need a good reference to MIOS LUUP extensions and all the device variables or properties. PS I am a very experienced C programmer, just need to know the specifics.

Point me in the right direction please!


There’s some really good information on the MiCasaVerde Wiki on Luup extensions to Lua.
See, for example, [url=http://wiki.micasaverde.com/index.php/Luup_Requests]http://wiki.micasaverde.com/index.php/Luup_Requests[/url], and the HowTo pages.

Find a variable on the UI that you are interested in.
Go to the Advanced TAB for that device.

That tab contains the device ID.
Hover the mouse over the “Name” of the variable.
It will show the ServiceID for the variabe.

And of course the mouse is sitting on top of the Variable Name.

What more can you want …
Usually numeric data is presented as a string. You may need to use tonumber(xxx)

Have fun!

Great stuff Richard, thank you! I see the Service IDs and variable names.

One thing I didn’t understand thought is that if I look at the Advanced properties for some of my devices, it doesn’t seem to change. For example, if I look at the value for Status on one of my switches it shows ‘0’. If I turn it on, it still shows ‘0’. I would think that clicking on the wrench, going to the Advanced tab would show the current value. Why am I not seeing that. Ditto for load level on the lamps - no change although obviously the switch and lamp are working fine.

OK, got it working! The Lua was

local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”, “Status”, 13)
if (lul_tmp == “1”) then
return false
return true

Pretty straightforward, with a little help from my friends!

Question: Do Device IDs change? Instead of 13 above, can I get the number returned from a name lookup?

The properties in the advanced tab are mostly defined at the time the Browser is loaded … you have to refresh the page to get new values. It does not have any event listeners looking for changes.

Device Numbers are assigned at the time a device is created. It is 1+ the highest previous. They only get re-used if you delete the LAST one and then create a new one.

You can walk a list of devices to match the name to get the id … but then you would have to make sure your device names are unique. Vera does not have this restriction. As a result there is no standard name lookup.

Got it Richard, thanks. You have been a big help.