Tag Archives: Domoticz

Outdoor lighting

Unless you are lucky enough to have pre-wired lighting in outdoor spaces, it can be hard to link outdoor lighting to a home automation setup.  There aren’t many wireless and battery powered lights that can be controlled with radio signals, because ‘listening’ for the radio signals all the time will drain the batteries pretty quickly.

As part of my ‘ready for summer’ programme, we’ve just attached a reed fence to the back balcony, primarily so we can let our cat out for a bit of sun now and then so she doesn’t launch herself off the 3rd floor.  But me being me, I wanted some form of home control out there,  Of course, I could take out the Hue Go and I’m sure I will especially when summer (and wine) comes.  But it would be nice to have something permanent out there.

I remembered that I had a couple of the Lightwaverf LED lights we used to use in the kitchen and bathroom.  These are small white blocks, with a cluster of 3 bright LEDs (powered by 3 AAA batteries) encapsulated in a transparent circle that also acts as an on/off button.  The boffins at Lightwaverf have managed to work out how to use very little energy with these lights, so replacing the batteries does not need to happen as often as you might guess.

They’re perfect for mood lighting so I guessed they would have enough oomph for a double balcony.  They do indeed as the below images will testify!

backbalc1

balcony2

The lights themselves are not waterproof, so after some careful consideration (and rummaging around the house) I gathered together 2 old (clean!) takeaway boxes and some trusty super-strength double-sided sticky foam.  I stuck the top (the flat end) of the box to the wall, then the whole LED unit onto the surface, then pushed what was the bottom of the box (now the front of the light) on.  To replace the batteries I’ll just have to remove the ‘cover’ and then slide out the LED from its integrated holder.

Although (as in the picture) the lights look rather industrial, I like them!  Of course, you could encase the lights in whatever waterproof enclosure you want, just remember that you will have to open them at some stage to replace the batteries.

Now the lights were not accessible by human hands, I had to devise a way of switching them on and off.  I’d already linked them up with Domoticz, so we could use the app to control the lights.  But that’s not enough, is it!  As all 3 doors to the flat (and some doors inside the flat) have open/closed sensors, I hooked up the lights to the balcony door.  When the door opens, the lights come on for 5 minutes.  That’s enough to find a seat, set up a table and then decide if you’re staying out there, in which case you can use the Domoticz interface to keep the lights on.

One more thing… I didn’t want the lights to come on during the day when the door is opened.  That would just be wasteful.  As I had already set up a dummy switch called ‘Dusk’ that switches on just before sunset and switches off at sunrise, I could add this to the mix.

Just this much text as a script in your domoticz folder on your Pi achieves this.  It’s really that simple.

commandArray = {}
if (devicechanged['DOOR Chester Balcony'] == 'Open' and otherdevices['VAR Dusk'] == 'On' and otherdevices['Rear Balcony Lights'] == 'Off') then
 commandArray['Rear Balcony Lights'] = 'On FOR 5'
end
return commandArray

So even for someone who has no knowledge of programming, you can see what’s going on here.  In English:

If Chester’s door has just opened, and it’s dark enough to need lights and the balcony lights are not already on, switch on the balcony lights for 5 minutes.

Interestingly, the lights as in the picture were just too far away from the transceiver attached to the Pi to receive the signals reliably.  So there could have been the potential for one or both of the lights to stay on, even after they had been told to switch off.  To solve this, I used a LightwaveRF branded signal repeater, a really useful device that acts like a wifi repeater, but for home automation radio commands.

backbalc3

As for the balcony, it’s going to be great for summer.  But the cat might not be allowed on it as much as we’d hoped – within 5 minutes of her exploring her new space, I was prising her off the banister as she determinedly tried to fling herself off from the third floor.  I’ll have to think of a way that our home automation setup can prevent this!

Advertisement

Are Hue serious?

I cannot overstate the impact that equipping the flat with Philips Hue lights has had.  These seemingly innocuous light bulbs behave much like any other.  You can switch them on and off at the wall like normal bulbs, but the magic happens when you command them to change colour, brightness and saturation via the Philips Hue app, or like me via a direct command to the Bridge via a http request.

The Bridge is a puck-shaped device that you plug into your router and this then communicates with all the bulbs within its radio-range.  For bulbs that are too far away from the Bridge, the message is communicated through all available bulbs.  This way a command can reach all the way through a large house (or comfortably through a small flat like ours).

Flap1

Here’s the Hue Bridge (the circular device with the blue lights).  You can see that I’ve found a cool place to tidy away all my home control devices: in the empty space previously occupied by a obsolete hot air heating system vent.  The Hue Bridge shares its home with a Hive controller, a Sonos Bridge and a LightwaveRF Link.  All devices are out of view until I need to look at any of them.

The Philips Hue App vs. direct control

The app itself is not great, purely because it takes a while to load up, and I don’t like the way that it behaves.  I think the app was not designed for someone like me, who wants to press one icon and get the lights exactly how I want them.

hue-bathroom1

A rather extreme example: how lighting can change the atmosphere within a split second (don’t worry, our bathroom isn’t often that pink!)

Direct control (http request) is the best way to control Hue as far as I am concerned.  I do away with the app altogether and use the control pads throughout the flat.  This incidentally was before Philips brought out a new device that can do this – the Hue Tap.

Basically, the pad is pressed to select a colour, this sends a radio signal which is picked up by the transciever attached to the Raspberry Pi.  Domoticz acknowledges that the button was pressed, and then sends an appropriate request or requests to the Philips Hue Bridge via the network.   I say requests because you can send as many commands in one go as you like, up to about 10 per second.

You can get a list of all the commands you can send to the Bridge, as well as how to set up the Bridge to accept these commands at the Philips Hue API site.

Speaking to the Pi

putty

I use Putty to connect to the Raspberry Pi, so that I don’t need to connect a screen and keyboard to the Pi.  I just fire up Putty from a computer on the same network and then use that computer’s screen and keyboard to control the Pi.  Read the installation instructions (and the legal information) before installing Putty.

Once you have launched Putty, enter the network address and port of the Pi into the boxes, and click connect.

puttylogon

You’ll then see a login screen.  Enter the login credentials as supplied by the place you downloaded the Raspberry Pi image from (I got my image from the Domoticz website – use the Raspberry Pi file.  More instructions available here).

puttyscreen

You’ll then be able to change the folder you are looking in to domoticz.

Type cd domoticz and press enter.

pi@domoticzpi ~/domoticz $

will be displayed.

That’s it!  You’re connected to your Pi and you can command it from any computer with Putty installed on your home network.

Why Domoticz is a no-brainer

When I first decided to connect all my devices centrally, I looked around the internet for a solution.  There are many options to choose from, almost too many.  Some you pay for, others you don’t.  Some come with a ‘hub’ that you connect to your router and the hub sends out radio and network commands to your devices.  Others rely on external hardware that you purchase separately.  There are some really good paid services out there, but I wanted to try it on the cheap.  That’s when I found Domoticz.

rfxcom433Domoticz is a small-footprint program that you can install on pretty much any computer, but if you want to connect to your devices via radio waves, to send on/off/dim signals, and receive temperature or movement sensor data, you’ll need to buy a separate piece of hardware.  I bought an rfxcom rfxtrx433.  It’s a matchbox-sized box with a stubby aerial sticking out of the top.  You connect it to your computer via USB.

At first we used a Windows PC that was left on all day every day as our ‘home server’ (one of the terms used to describe the ‘brain’ of the home control system).  It worked reasonably well, and Domoticz almost never crashed.  The thing was, we were probably using far more power than we needed to.  So I looked at using the Raspberry Pi, a small and cheap computer.From the Domoticz website you can download an image to transfer to the Raspberry Pi via an SD card.  This image contains all you need to start using Domoticz straight away, right from the second you plug in the Raspberry Pi.  This makes life sooo much easier.  You can even plug in the rfxtrx433 into one of the Pi’s USB ports and it will start working straight away.  It’s that simple.

raspi

domoticz-screenshotThen, the exciting part.  When you type in the Pi’s network address (eg 192.168.1.34) and add on the port number (the default of the Pi when Domoticz is first installed is 8080), you’ll see an unpopulated screen with no devices.  Adding devices is done in quite an innovative way: devices that send information routinely, like temperature sensors for example, appear in the ‘unused devices’ tab and with a few clicks they can be added to your dashboard.  Adding other hardware that uses network commands, such as the Philips Hue Bridge, is done via the Hardware Setup page.

domoticz-blockyAfter some or all of your devices are added, you can create decisions that Domoticz can make on your behalf.  You can make these as sophisticated or easy as you want: and there are two ways of programming these decisions.  The easy way is using ‘blocky’.  This is a drag-and-drop way to quickly build up a program.  A great feature of blocky is that the blocks you drag around will only fit together if they can interact in the way you’re trying to get them to interact.  The more advanced way to tell Domoticz what to do is to edit and create mini-programs that run either when a device changes state, or every minute.

This is a really quick summary of what Domoticz can do, I would advise that you visit the website and forum, grab a Raspberry Pi, install the Domoticz image onto an SD card and have a go yourself.  You’ll be amazed at what a free piece of software can achieve to realise your home control dreams.

I’ll be posting a lot more about Domoticz.  After all, pretty much everything in our flat is controlled by it one way or another.