Posts Tagged ‘iot’

Presence Detection

Posted: September 21, 2015 in HA, Hacking and playing, House
Tags: , ,

The ‘ol bug bear – how do I see if anyone is home?

I’ve tried OwnTracks, but the app on Android isn’t the most accurate and reliable (although it is being updated). I’ve tried the network health monitoring binding in OpenHAB and asked it to detect the phone when it connects to the home network (spot the flaw #1). I’ve tried using a BlueTooth (BT) dongle in the OH controller and running regular scans for my phone.

But none of them work 100%. OwnTracks just lets me down (waypoints especially). I leave my Wi-Fi off most of the time to save battery (and network health doesn’t seem to detect it when it is on). BT does work, as long as i am in range. But the minute I go upstairs the phone is out of range and the system thinks I’ve left the house. The other gotcha is that my wife doesn’t turn BT on, so that’s a pain as well.

When I’d spoken to SmartThings (some CES trip before Samsung got involved!) we had discussed the presence tag that their system supported. Fast-forward to the UK release of the new Samsung version and the presence tags suddenly are actually available in the UK. Yay!

Boo! They are ZigBee. So absolutely bugger all use to me. I’m not plugging in the Almond+ or building some new Xbee device just to solve this issue.

I need a device that is small enough to be with me all the time, not be intrusive and allows for reliable long term use before requiring battery changing. Oh and the batteries need to be cheap. I’m not spending more on a replacement battery than the actual device cost me. The other driver is that I’ve managed to get some more scripts written that control our heating system. So if I can prove that no one is home, I can automatically turn the heating off!

BlueTooth Low Energy

A long time ago (~2012) I’d done some experiments on presence detection for work. My concept was to use BT, BTLE, Wi-Fi etc etc to try and establish who was in a room during set-top box use. While this wouldn’t give a one-to-one correlation between who actually watched something and who was there, it would narrow the field considerably. If device X was always present when cooking shows were watched, we could start to recommend cooking shows when device X was in the room. The more devices we detected  and more watching data we got, the better the correlation would become.

Anyway, the idea was greeted with enthusiasm and then totally mis-understood and ended up being something to do with localised advertising in bus stops…. No I don’t know how it got to that either!

The point of this is that when I was looking at this, BTLE beacons were just starting to actually be available. Devices like the Fitbit bands used BTLE to communicate with the phone.  What was the state of cheap BTLE devices today?

The Concept

After thinking about it, the only thing that I always have on me when I leave the house is my door keys. When I come in, the door keys get put in the front door lock and that’s where they live. Can I find a device that I can detect in this position in the house reliably? That is also small enough to fit on my keyring? And is tough enough to survive being thrown around as part of the normal lifecycle of a bunch of keys!

Google and Amazon searches revealed several companies selling iBeacons in various size and power formats. After a couple of email conversations with a company called Avvel I ordered a ‘long range iBeacon’.

Avvel iBeacon (long range)

The device turned up the next day and was simple to setup and configure. At this point I’m not really bothered about the Major and Minor broadcast values – this is only for me. Maybe later if it works I’ll look to use these to indicate the device and who has it…

The Code

I’m already using the bluez library via python on my RPi2 to detect the phone via BT. Every 5 minutes I scan for the BT address of our phones. The true false flag is posted into our mqtt broker where OpenHAB uses the value to set the in/out switch. The plan was to do exactly the same except using BTLE.

As usual, it didn’t happen. While i could happily

sudo hcitool lescan

and find the keyfob, the ability to do this in the python script eluded me. Various tutorials talked about using gatttools or adding extra libraries (that failed to either install, compile or run), but none of them worked.  I wanted to use python in order to limit extra packages, libraries and complexity that installing extra things could add to the system. I can’t have a HA controller fall over because of a clash between different bits.

FInally I expanded my search to other languages and found noble for NodeJS.  I’ve actually used noble when I was doing the presence detection work before – that time I was using it embedded in Node RED. As all my recent work has been in NodeJS, I figured I’d try it for this.

The beacon is set to broadcast every 9.9 seconds (at least I think that’s what I set it to be), so the script scans for 25 seconds every three minutes. At the end of the 25 seconds, the script totals up how many times it has seen each of the specific devices and then sends a true or false value to the mqtt broker for each one where it is again picked up by OH and used. The three minute cycle is controlled by a crontab -e while the 25 seconds is a simple JS setTimeOut().

The Result

Well so far it has worked (sort of). The script picks up the keyfob successfully and OH gets the updates as I come and go. The issue is signal propagation. In a straight line with no obstructions I’m able to detect the keyfob up to about 50m (bottom of the garden!). The issue is that between the RPi2 that has the USB dongle doing the detection and the front door where the keys are supposed to live are walls, radiators, kitchen units and potentially small children. This drops the successful detection rate down considerably – it doesn’t stop it completely, but it does drop it enough to make it unreliable.

My next option is to move the OH box to a better location that may have a clearer ‘line of sight’, but that will mean grubbing around behind the AV cupboard and thats not a job to be taken lightly!


As the keyfob is on a big clip on my door keys, it’s actually easier for me to just unclip it and drop it with my other keys in the lounge rather than leave it on the door keys. It’s also safer than me rummaging around in the AV cupboard.


DIY Hue Strip

Posted: September 7, 2015 in HA, Hacking and playing
Tags: ,
When we re-built the kitchen last year, we wanted to add some low level lighting so that we could use the kitchen at night without using the main (excessively bright) ceiling light. As usual, it kept being put off, but with winter rapidly approaching, the need for these lights is now becoming urgent.
I was thinking about installing some Philips Hue LED strips, but various people had reported that they weren’t overly bright, so their suitability for our needs was an issue. I’m not forking out for a Hue kit and strip to find out it isn’t bright enough! Granted now I’ve played with LED strips, the kids have requested some things that the Hue strip might be suitable for….
The excellent forum at Micasa Verde has a tutorial about hacking some ‘cheap’ Ikea Dioder LED strips using a Fibaro RGBW control unit. This allows me to integrate the lights into my existing OpenHAB setup for automation and still allows for local manual control.
With Vesternet having Monday sales throughout August, I was able to pick up the Fibaro unit cheap.
Rummaging around in the Arduino/RPi box provided the necessary jumper wires and we were away.


The above picture shows the Fibaro RGBW (top) unit jumpered into the Ikea Dioder control (bottom) and LED strip distributor (middle).
The manual switch unit allows for local control of on/off and colour select. There are also 2 additional buttons for fast and slow colour changes.

Fibaro RGBW in Veralite Control Panel

Fibaro RGBW in Veralite Control Panel

Once the unit is powered, the Fibaro can be included in the Z-Wave network and will appear in the Veralite (U15) as 6 separate devices (Master (inc power use), On, Red, Green, Blue, White). And no I don’t know why we have a master and a power…. I’m sure someone can explain it, but it probably makes sense if you have a Fibaro controller.
Once I’d mapped the devices across into my OpenHAB controller, I can use the lights from any of the OpenHAB interfaces.
Group gRGBW "RGBW Light" <colorwheel> (Lights)

Dimmer RGBW_GF_Kitchen_DimmerAll "RGBW Light Control [%d %%]" <switch> (gRGBW) {mios="unit:house,device:128/service/Dimming1/LoadLevelStatus", autoupdate="false"}
Dimmer RGBW_GF_Kitchen_DimmerR "RGBW Light Red [%d %%]" <switch> {mios="unit:house,device:130/service/Dimming1/LoadLevelStatus", autoupdate="false"}
Dimmer RGBW_GF_Kitchen_DimmerG "RGBW Light Green [%d %%]" <switch> {mios="unit:house,device:131/service/Dimming1/LoadLevelStatus", autoupdate="false"}
Dimmer RGBW_GF_Kitchen_DimmerB "RGBW Light Blue [%d %%]" <switch> {mios="unit:house,device:132/service/Dimming1/LoadLevelStatus", autoupdate="false"}
Dimmer RGBW_GF_Kitchen_DimmerW "RGBW Light White [%d %%]" <switch> {mios="unit:house,device:129/service/Dimming1/LoadLevelStatus", autoupdate="false"}
Switch  RGBW_GF_Kitchen_SwitchAll "Switch All" <switch>  (gRGBW) {mios="unit:house,device:128/service/SwitchPower1/Status"}
Switch  RGBW_GF_Kitchen_SwitchR "Switch Red"  <switch>  (gRGBW) {mios="unit:house,device:130/service/SwitchPower1/Status"}
Switch  RGBW_GF_Kitchen_SwitchG "Switch Green"  <switch>  (gRGBW) {mios="unit:house,device:131/service/SwitchPower1/Status"}
Switch  RGBW_GF_Kitchen_SwitchB "Switch Blue"  <switch>  (gRGBW) {mios="unit:house,device:132/service/SwitchPower1/Status"}
Switch  RGBW_GF_Kitchen_SwitchW "Switch White"      <switch>  (gRGBW) {mios="unit:house,device:129/service/SwitchPower1/Status"}
After installing the device I realised that I couldn’t mix and match my control methods – if I turned it on using the manual switch, the change of state wasn’t being picked up in OpenHAB and I couldn’t turn it off. The opposite was true as well – turning it on using OpenHAB didn’t allow me to turn it off via the switch. This is a little frustrating, especially as the manual switch feels like a momentary contact type, so the on-off state shouldn’t be fixed.
I’ve queried this with the bright people on the MCV forum, and they confirm that this is expected behaviour – we have 2 switches – and it appears that the manual switch isn’t a momentary contact, so unified control is impossible. BOOO!
Micasa Verde forum –,25549.0.html
Vesternet –

Adventures in HA – Part Four – HomeGenie (1)

Posted: November 14, 2013 in HA
Tags: ,

I had originally planned to go an download the 30 day trial of Indigo, but a spare hour or so yesterday meant that I dug out a spare SD card and re-installed HomeGenie.

I liked HomeGenie when I first played with it a few months back, although initial attempts to get my X-10 controller to work failed miserably, sticking an Aeon Labs Stick2 in worked fine. At that point I lacked any other devices, so turning on and off a single light wasn’t really a huge leap forward. Now I also have a 3-in-1 sensor I can try and get things to happen based on the sensor as well as manual control.

So back to HomeGenie and it’s pleasant jQuery mobile interface. The interface is minimal, and really designed for use on devices rather than the desktop. The downside is that configuration then becomes much more ‘restricted’ in its abilities.

Originally I had managed to get the controller and switch setup. From there getting the switch to turn a lamp on and off via the interface(confusing my kids no end!). With the new version (1.00_beta_r290 from memory) I got the controller to register (I think), it eventually picked up the switch but then totally failed to let me turn the switch on or off, even though it was correctly reporting the status of the switch (0% or 100%). This may have been due to me getting impatient, repeatedly pressing the button and confusing the poor thing, but I’m sure it responded a lot quicker last time I played with it!

Getting the 3-in-1 to work hasn’t been successful so far. It registers the sensor as a node, but then getting it to do anything (presence, temperature or light level) has left me stumped. Lack of time to pursue this means I’ll need to find some time to go through forums and maybe try again.


HomeGenie –

Adventures in HA – House plans

Posted: October 31, 2013 in HA, Rants
Tags: ,

One of the annoying things about playing with HA software is the room plan. Nearly every platform shows a view of some kind where there’s a splendid, full colour, detailed floor plan showing exactly where EVERY fixture and fitting is.


All my attempts fall flat on their faces because I haven’t got the exact dimensions, or time to measure and then manually enter EVERY dimension in some random piece of software. The software also seems to be too simplistic (and won’t let me have non-rectangular rooms) or excessively complex (CAD suites) or bloody expensive.

So far I’m having more success with MagicPlan on the iPad. It at least gives me the basic room shapes and reasonably accurate dimensions. So I can use it to generate something to test on the platforms I’m playing with.

Ninja Blocks

Posted: January 28, 2013 in Hacking and playing

So time for the geek-out – Ninja Blocks arrived over the weekend!


Ninja Blocks are a small kit comprising a control hub and a set of sensors. The hub and sensor suite change depending upon the version of the Ninja Block that you purchase – I’ve got the v2 block. This gives me a black slightly curved hub with purple ends and a ‘Hack Me’ fabric label out of one side. My sensors are a PIR, a button, an open-close sensor and a temperature & humidity sensor.


Set Up
Set up is easy, literally add the hub to your network and wait for the status light to change to purple – this means that the hub is connected and has up to date software installed.


Now create an account on and tell it the serial number of your hub. All done!


You can add the various sensors to the hub by turning them and and assigning a name to that new device. Once you’ve got a sensor registered in the hub, you can use it to build simple rules. The rules are basic cause and effect style – if this happens, then do this, but the cause and effect can consiste of multiple statements.


eg ‘IF door open triggered AND time between 22:00 and 06:00 THEN send email to AND send tweet saying “door open”‘


For an indication of how easy the rules are to setup, see Marcus’ demo at Le Web 2012.


General Notes
Interface is ajax based JS, so it gets a little flaky on mobile devices (iPads and Android tablets) but works fine on the desktop. The dashboard appears to be mobile aware, so changes it’s layout according to screen size and orientation, but still has issues with the layout. 

I like the simplicity of the device and the sensors…. the issue I have is the lack of ‘off-the-shelf’ devices for the ecosystem. Unlike Z-Wave or ZigBee where I can (theoretically) use existing components, the RF devices that this system uses are far less common and there’s issues of compatibility. I may be wrong, but I think the 433MHz band is unlicensed in the UK so although there are devices using that band, they often use proprietary protocols for communication which makes adding them to the system an issue.


I know there is a UK version of the plug controller that can be controlled by this system, but attempts to get hold of it in the UK have all failed (out of stock, no longer stocked, etc etc) and it’s a bit expensive to get one via Ninja Blocks (actually re-directed to Epodia who want £11 for a single plug). Ideally i’ll get hold of one of these and try to set up an end-to-end scenario, but that will have to wait until I can get a device I can actually control of some kind!


Ninja Blocks –




Internet of Things

Posted: January 25, 2013 in Hacking and playing
Tags: ,
The old questions about the viability of a major ISP getting involved in “home automation” has raised its quasi-regular head again this year. As with most of these types of enquiries it means that we get to get in some new toys, play with them, show the business what is happening and then let them go off and make their decisions.


However this year I’ve managed to gatecrash the research and using the term-du-jour of Internet of Things, get hold of some of the cooler new toys – or at least put the order in to get some once they’re shipped! I’m not going to go into details about each one here, but I will post more info once I get hold of these things….


First up is Ninja Blocks – an Aussie company based in Melbourne. Their second iteration 433MHz IoT box and sensors package is the cheapest of the bundles I’ve ordered, but is also the once closest to shipping. This is basically a central hub that connects out to the cloud with a variety of sensors that it can interact with that can be placed around the house. Sensors work in the 433Mhz radio band, so while they should be easy to obtain, there’s no guarantee that the Ninja Hub will be able to talk to them.Unlike the other devices I’ve requested, this is both Open Source Software AND Open Hardware… so if I feel the urge, I can go and build my own. The main hub even has a purple ‘Hack Me’ label on the side that you use to open the device up.


Next is SmartThings – again, the same premise as Ninja Blocks – a hub and sensor kit that can be set up to perform monitoring and react to specified scenarios. Unlike Ninja Blocks SmartThings uses both ZigBee and Z-Wave standards, potentially allowing off the shelf third party devices to be added to the sensor set. However, even within these defined standards, we’ve found wide variations in the past, so it’s still not a guarantee of compatibility.


Next is Ubi. Ubi is described as a ubiquitous computer that you ‘just plugin and talk to’. It is effectively a voice controlled internet gateway that can interact with other devices. Part of the early marketing indicated that this device could be used in conjunction with SmartThings to allow voice control of the SmartThings network.


Finally there is Almond+. I saw this briefly at CES (annoying Doc Brown impersonator!) but the stand was busy, so I didn’t get to really chat with them about the device. Building on their successful Almond home router, they have extended its capabilities by adding both a ZigBee and Z-Wave chipsets, as well as upgrading the wireless capabilities to 802.11 ac. The device is being funded via Kickstarter and was well on it’s way to hitting target when I last looked.