Vera – Is someone home?

Home automation was attractive for two specific reasons, or functions if you prefer.

  1. Timed routine event management – the ability of Vera to turn perimeter lights on and off, and to complete certain actions at certain times (and even with a slight variation if needed) regularly and without fail.
  2. Occupancy driven events – Air Conditioning / Heating set points modified based on whether anyone is home, lights turned off when no one is around etc etc etc.

Vera Home Automation

It’s the second class of items that has caused me issues (the first are as easy as making a schedule and letting it rip… being able to set the schedule based on a +/- sunset/sunrise is just a bonus) – think about it, if you’re a computer sitting on a shelf how do you tell if someone is home?

I tried a few different ways of doing this;

  • Ping Sensor – App – Allows Vera to ping devices, in this case our cell phones, and when the phones disappear off the home Wifi the system can infer that we’ve left the area and trigger events accordingly.

    Right? Wrong. Seems Blackberrys sit on that network with perfect consistency, but my Android smart phone would go into a “sleep” mode that I can’t change through it’s internal settings, and so it would register false positives and that’s just annoying.

    The other problem with this is that if one of us forgets our phone, the system thinks we’re home and as a consequence fails to secure itelf properly.

    Not optimal.

  • Program Logic Event Generator – App – This is a tremendously powerful toolkit used to create conditional events. I had initially envisioned a system whereby Vera would ping the phones and look for activity (doors or windows open, motion detectors tripped) and at a certain threshold determine that we were home.

    I made this more complicated than it needed to be, and it all fell apart whenever we went to sleep as, obviously, activity in the house drops off a bit.

    Good idea – no dice.

  • Virtual Switch – App – I tripped across this solution while working on the PLEG kludge, I had Vera turn a lamp off when we armed the alarm system to “away”, then turn it on when we disarmed the system. When the system was armed to “stay” (typically when we go to bed) the lamp remains on. The condition of the lamp became the “occupancy” sensor, and events could be triggered or deferred based on the on/off state of the lamp.

    Simple but effective, the one sortcoming is that the appliance module was a Wemo Appliance module and was prone to occasional failures.

    Replacing the physical switch with a “virtual switch” within Vera was simple, and had the added bonus of freeing up the appliance module for use elsewhere.

Why is this important?

Disarming the alarm system when we get home (by remote) unlocks the front door for us and turns the interior hallway lights up to 30% if its after dark. We don’t want either of those things to happen if we’re just waking up in the morning and shuffling around looking for coffee.

More importantly for me as a shift worker, the thermostat can now change it’s set point based on whether we are home, and not on an arbitrary mon-fri (sat and sun) schedule that doesn’t even remotely fit my sleep schedule.

local dID = 57
local allow = false -- true runs scene if switch is on, false blocks it
local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",dID)
return ((status == "1") == allow)

Not too complicated, but it took a while to get there.


  1. Madeye says:

    Fascinating. Really. How to turn one’s residence into a great big programming puzzle ;-)

    (BTW … ‘kludge’ – (or ‘kluge’) -(klo?o?j) is a workaround or quick-and-dirty solution that is clumsy, inelegant, difficult to extend, and hard to maintain, yet an effective and quick solution to a problem.’)

  2. Mugwug says:

    Nifty exercise trying to get a computer to take care of something that seems fairly simple at first.

    Also fixed the Kludge….


Leave a Reply

Your email address will not be published. Required fields are marked *