Who's Home

Nov 17 2017

I love home automation (HA) because it allows me to make mundane tasks happen without any sustained intervention. Just setup a scene, and let the magic happen. Generally, this works great whether it is a scheduled event or something that is trigger driven. But, every so often I have a scene that requires more intelligence than is available out of the box.

One example of this is the scene that turns on our porch light. I only want it to run when one of my family members is not currently home. For a long time I struggled with how to detect that in a low touch way. Fortunately, I recently discovered that the Unifi Controller API provides a list of currently connected clients; making it quite easy to use each of my family’s mobile phone as a proxy for whether they are currently home.

The main limitation of the Unifi Controller API is that it requires cookie based authentication, which makes using it directly from my Vera Control home automation controller (HAC). So with a few hours on my hands I decided to write a quick bridge that can be used when making who’s home decisions on the HAC.

The bridge is written using Node.js and can be found on GitHub. For those running Windows, I have included instructions for installing it as a service. As it is runs in Node.js, it should also work on Linux, but I haven’t tested it.

Depending on your HAC, and use case, two return types (json/simple) are provided. Vera users will want to stick with “simple”; unless I missed something its script engine does not natively support JSON. Sample LUA code is also provided to for use in scene decisions.

Placing it is a little unintuitive in the scene editor. It goes in the highlighted section.

Enjoy, and as always if you have any questions please feel free to reach out and I will assist as best I can.

Website design by Yammm Software
Powered by Drupal