December 20, 2016

Openhab

Since the ninjablock company has run out of money, and is not supporting the ninjablock anymore, and its cloud service is pretty unreliable (at the best of times) I decided to merge all my homeautomation items with Openhab. At the time I adopted this, it was the only major, multi-vendor supported Home automation “brain” around. Since then home assistant has come around, and alot of others have picked up support for alot more “things”. If I had the money, I would probably jump on the Smart Things wagon, but I don’t :(

So this is a bit of a back post of the system, since I’ve had it running for almost 2 years since Openhab 1.7 came out. But I thought I would just share a bit about it, and my setup

I am still yet to upgrade to OpenHAB 2.0 yet, it seems like a lot of work, it doesn’t look like there is a straight forward upgrade path from 1.x. So I’m still running 1.7, which is working fine for me

Setup in the house

So I had a nexus 7 laying around, and decided I’d use that as a wall mounted controller. This works well with openHAB because it even has a “full screen” mode for you to use in the app, which will hide the status bar and navigation keys. This is an always on display too

I rarely use the web based GUI to access my home, having this controller works well, plus I have the app installed on my various hand held devices too (And my watch!). So I am never too far away from any controls. I’ve never found the need to open up the web GUI when I’ve been at my desk, much quicker just to unlock my phone and start the app. The default web interface is very ugly too :/

Nexus 7 dashboard

Hardware

Raspberry pi

Originally I had openHAB running on a raspberry pi (v1 B) but could notice the lack of power when interfacing with it. This wasnt too much of an issue when I first set it up, but after setting up a dozen or so rules, things started getting pretty sluggish. Doesn’t help that openHAB isn’t the only thing I have running on my pi. Not that I’m complaining, it does really well for the specs it has. However this was all fixed when I upgraded to a Raspberry Pi v2. That thing was such a powerful step up from v1. Incredible. I run openHAB, owncloud, dhcp/dns and various cron started scripts on that thing and It doesn’t even complain, or let me down.

The only dependancies I needed in this situation were java (obviously, to run openHAB) and an MQTT server (I use mosquitto MQTT). This was to interface with the raspberry pi running the ninjablock things

So all up * 1 x Raspberry pi v2 (to Run openHAB and mqtt) * 1 x Raspberry pi v1 model B (With the ninja crust pi hardware attaached to it, including 433MHZ transmitter) * 1 x Raspberry pi as mpd server

Ninja Blocks

Lucky for me, someone else that had a ninja block came to the same conclusion as me, so had already made a nice little python bridge to get the Ninjablock and its 433Mhz sensors into openHab. Old mate Perrin7 posted his link in the now dead Ninjablock forums. This little shim just connects to the Ninja Crust via its serial port, and listens for any events. It reads these events, figures out what device/sensor it was, and then publishes it to a MQTT thread. OpenHab also just listens to these threads and picks up changes as they are posted! I’ve had this running for a while now with no issues :) the only downside (but probably easily fixed) is I have to start this python script everytime the pi with the ninja block on it restarts (Say if I lose power or something). This is what I have that connects to my Ninjablock over 433Mhz * 1 x Button * 1 x Motion sensor * 1 x Door/window sensor * 3 x remote power switches (Watts Clever brand)

Here is the sitemap, and items list in openhab specific to the ninjablock

Switch Motion_Sensor    "Room Sensor"   (Persist_change) {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:1000000001011010
01011001]"}
Switch C_Lamp   "Pergola Lights"        (frontroom)     {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:11011010110110101
1011100],
                                <[mosquitto:ninjaCape/input/11:state:OFF:110110101101101011010100],
                                >[mosquitto:ninjaCape/output/11:command:OFF:110110101101101011010100],
                                >[mosquitto:ninjaCape/output/11:command:ON:110110101101101011011100]"
                                }
Switch D_Lamp   "Door Lamp"     (frontroom)     {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:110110101101101011011110]
,
                                <[mosquitto:ninjaCape/input/11:state:OFF:110110101101101011010110],
                                >[mosquitto:ninjaCape/output/11:command:OFF:110110101101101011010110],
                                >[mosquitto:ninjaCape/output/11:command:ON:110110101101101011011110]"
                                }
Switch Z_Lamp   "Room Heater"   {mqtt="<[mosquitto:ninjaCape/input/11:state:ON:110110101101101011011010],
                                <[mosquitto:ninjaCape/input/11:state:OFF:110110101101101011010010],
                                >[mosquitto:ninjaCape/output/11:command:OFF:110110101101101011010010],
                                >[mosquitto:ninjaCape/output/11:command:ON:110110101101101011011010]"
                                }

Switch Button   "Button"        {mqtt="<[mosquitto:ninjaCape/input/11:command:ON]"}
Limitless LED

Thing was probably the biggest purchase for me at the time, to replace most of my lights around the house with these. Has been a good investment, and already had a addon in openHAB so it was very easy to set up and get working. I have recently found a neat trick with these too, instead of setting the item as Switch in openHAB, you set it as Dimmer. Then when you link the light in the sitemap, you specify it as a Switch. This trick ensures that everyime you click the switch, your lights will go to 100% brightness (On being 100%, Off being 0%). I found this very useful, as before, when you turn the light on again it would turn back on at the last remembered brightness setting, which wasnt always at full brightness. Then I’d have to faff about with the slider bar to get it back up. “But what about if you want to change brightness after you turned the light on”, you ask. You can see the example in my item list and sitemap below. Using the visibility property, you can have the brightness slider show on your sitemap when the light is actually on, this reduces clutter on the screen (seeing as I only have a limited amount of screen space)

 Frame label="Lights"  {
                Switch item=all_off mappings=[OFF="All Off"]
                Switch item=L_light
                Switch item=L_lightn mappings=[ON=ON]
                Slider item=L_light_dim visibility=[L_light==ON]
                Switch item=K_light
                Slider item=K_light_dim visibility=[K_light==ON]
                Switch item=E_light
                Slider item=E_light_dim visibility=[E_light==ON]
                Switch item=H_light
                Slider item=H_light_dim visibility=[H_light==ON]
                Switch item=B_light
                Slider item=B_light_dim visibility=[B_light==ON]
                Switch item=BT_light
                Slider item=BT_light_dim visibility=[BT_light==ON]
        }
MPD server

Because I had an extra raspberry pi and an extra speaker laying around, I turned it into a remote media player with Mopidy (Another post about this shortly). This enabled me to stream straight from spotify, and control it directly from openHAB too! Super cool :)

Smart Home

So this is where openHAB gets cool. Not only can you interface with smart things throughout your house, and have information gathered and displayed all in one central location, you can create rules to do things when certain things happen (Think IFTTT)

For example * In the mornings when my alarm goes off, openHAB turns the kitchen light on for me * When i leave the house in the morning, it will turn that light off again * I can choose a time at night to turn the wall heater in our bedroom on (this will get smarter when my bluetooth temperature sensors arrive) * I can choose a time in the morning to turn the wall heater off * I Also link my phone location into openHAB (using ownTracks) so then my partner can view my location on a map within openHAB

These are just a few examples, but the amount of devices that openHAB supports, the length you can go to to automate your household is quite extensive and exciting

If you want to see my complete sitemap/items list or my rules I use, get in touch. I’d be happy to share and help get you started on the way to home automation with openHAB