Tag Archives: Lightwaverf

New YouTube channel

I just thought I would let you know that I have a new YouTube channel, called Fabulous Home Automation where I intend to add informational videos about home control devices.  There will be a mixture of reviews and technical hints and tips, so hopefully something for everyone.  My very first video is a quick review of some LightwaveRF products.  I’d appreciate your comments, but please be constructive as this is my first video!

View my YouTube channel

 

Advertisement

Logs, logic and inspiration: Managing a complex home control setup

You know how it goes.  You start with one or two home control devices.  You find it amazing that you can control them from your phone.  You want more.  And more…

Here’s a quick diagram of my current setup at home.

setup.png

There are at least 77 items for the home control system to control.  Each one has a unique set of capabilities, and inter dependencies with other devices.  Certain groups of these items require different communication protocols, some radio, some infrared, some HTTP and some via a webserver.

As my system has been created from several protocols and brands, I find it engaging and a full-on hobby to ensure they perform perfectly in concert.  Basic scripting has become more in-depth as I attempt to squeeze out the most from every device.  Although adding additional functionality is stimulating for me and ultimately rewarding for me and my flatmate, each iteration adds a new layer of complexity – and like every complex system, the bigger it is, the harder it can fall.

I’ve recently been faced with a problem.  A few times in a row, the Raspberry Pi 2 has frozen overnight. The controls and automatic lighting obviously do not respond, and then something as simple and as taken for granted as getting light and audio into the shower requires scrabbling through phone apps: not good if the water is already running!  Worse, the switches that are supposed to be triggered in the early morning, such as the “it is dawn” variable do not fire.  So with such a complex system how do you diagnose the problem?

Logs

The first answer is logs.  Loads of logs.  Ensure each of your subsystems are writing down what they are doing and just as importantly when they are doing it.  You can then rifle through the logs and find anything that is not behaving as you’d planned.

Inter-dependency diagrams

Okay, so this may be the most geeky thing I have said on this blog so far, but I like to keep diagrams and spreadsheets showing which systems and activities are inter-related.  And in the event of a catastrophic failure, they pay dividends.  You can literally trace your finger through the lines and see which scripts you need to check if something is not working right.  You can also keep track of things like ID codes and group codes for all your connected devices.

Logic

To do this you need to empty the house of unexpected variables (i.e. the rest of the family and pets large enough to trigger any sensors) and then physically run through each process that you think may be causing the problem.  If you are anything like me this usually involves an embarrassing and potentially uncomfortable period where you are remaining totally motionless right in front of a motion sensor to see what happens when the “no movement here” signal is sent.

Inspiration

You may be surprised by the other users’ perception and understanding of your home control system.  Ask other occupants what they think is happening.  At best they could hit the nail on the head, and if not they just may throw something so left-of-centre out there that is provides you with the fresh outlook you need to trace the problem.

Summary

I feel this entry will become outdated very soon.  As consumers we are on the cusp of having our cake and eating it: a fully integrated one-stop solution for home automation that will work seamlessly and without requiring manual programming.  It may even have the ability to provide reasons for failure and suggest ways to work around it, especially if open-source and app-based: a fellow user in the Netherlands could be granted temporary access to help sort out the problem you’re having with your garage door in California.

This new way will remove the complexity involved in getting disparate systems to work together, but will it provide the level of control we ‘first gen’ full home control aficionados will require?  Either way, I’m glad I’ll be able to say “In my day, we had to fumble around to find the solutions to these issues, and sometimes create our own!”

 

 

Creating a security system

A major plus for home automation is the ability to give any device multiple purposes.  With a little imagination, a Sonos speaker can become a voice announcer, a lightbulb can become an effective method of simulating occupancy in a home.

Everyone wants to feel their possessions are secure.  A standard house alarm is useful- and many are becoming smarter- but there is always the chance that a ringing alarm box is less of a call-to-arms and more of an annoyance to be ignored.  With that in mind, I would suggest building your own security system to notify you as soon as something is out of the ordinary.

This security system is created wholly from home automation products and is armed when you select a switch called “Leaving” on Domoticz, waits for 5 minutes to allow you time to come back in if you have forgotten anything (which I always do!), then after a further 5 minutes attempts to detect your phone(s) and if they are in wifi range, disarms the system again.

What you’ll need

  • Raspberry Pi running Domoticz
  • RFXCOM RFXtrx433
  • A number of door sensors, vibration sensors or PIRs (or any combination of these)
  • Python running on the Raspberry Pi
  • Maybe a network IP camera if you want to capture a photo when the alarm is triggered

How long it will take

Depending on the number of door sensors/PIRs/Cameras that you want to install, it could take anything from 15 minutes to several hours.

Step One – Install your devices

Choose entry points to your home.  The obvious one is the front door but also think about other places where someone may try to gain entry.

For doors, place the sensor towards the top of the door.  Remember to look at where the battery will need changing from, and ensure this will be easy to access by orienting the battery compartment/drawer towards the ground.  If space is limited, remember that there’s nothing to stop you attaching the larger part of the sensor (the transmitter) on the door itself and the smaller part (housing the magnet) on the frame of the door.  Use sticky strips first to test, even if you plan to screw the sensor to the door later.

For vibration sensors you can usually affix these directly to the window using suction cups.  If the type you have requires a more permanent fixing, try taping the sensor to the window first to ensure you (and other family members) are happy with their placement.

For PIRs, install these unobtrusive but accessible areas.  Remember that as these devices are wireless, you can even place them on shelves.  You don’t need to put them in corners of rooms like wired sensors.  Choose places where it would be impossible not to cross the detector if moving from room to room (hallways are a great position).  Remember that if you have pets the sensors should be raised up so that they can only be activated by humans.

Learn and name each sensor into Domoticz.  Remember to specify what type of device you are adding (PIR, Door sensor etc).

Step Two – Create a few Dummy switches

Create a dummy switch called “Leaving”.  This will be ON when you have left the home and OFF when you return.

Another dummy switch called “Security Alarm” is needed.  This is the switch that tells the scripts whether to send you an alert when a sensor is triggered.  You don’t want to get alerts when you are at home (as you’re probably the one triggering them!)

Another dummy switch called “Waiting for Phones” needs to be created.  This will be ON when the security system is waiting for you to return home.

Then create a switch for each phone you want to automatically disarm the system with.  I use two switches (“Chesters Phone” and “Harrys Phone”).

Finally, we need one more dummy switch – “Arm Security”.

Step Three – Write the scripts

A few scripts are needed now.  What will happen when you switch on the “Leaving” switch?  What about when it is turned off?  What happens when a sensor is activated and the “Security Alarm” switch is on?

The first code I write is saved as “device_SECURITY_Leave.lua” and is saved in the domoticz/scripts/lua/ folder

commandArray = {}
if devicechanged['Leaving'] == 'On' then
 commandArray['Environment Automation'] = 'Off'
 commandArray['Living Room Camera'] = 'On'
 commandArray['Security Alarm'] = 'Off'
 commandArray['Arm Security'] = 'On'
 commandArray['TEMP Set to 15'] = 'On'
 end
 return commandArray


This script (which I have reduced down as there are tens more switches to change when the flat is left unoccupied) runs once the Leaving switch is turned on.

We need a script to say when the alarm is activated – notice that I don’t switch the “Security Alarm” switch on with the above code.  If I did, once the Leaving switch was set, notifications would be sent to my phone as I walk through the flat to leave and open the front door.  I want to add a delay to the arming of the system.  This script is a timed script so starts with the text”script_time” instead of “script_device” – I’ve called it “script_time_SECURITY_Leaving.lua”

t1 = os.time()
s = otherdevices_lastupdate['Arm Security']
 
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
 
commandArray = {}
 
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
print ('Leaving difference ' .. difference)

if (difference > 300 and otherdevices['Security Alarm'] == 'Off' and otherdevices['Arm Security'] == 'On') then
 commandArray['Security Alarm'] = 'On'
 commandArray['Arm Security'] = 'Off'
 print ('Security Alarm is now armed.')
 commandArray['SendNotification']='Security Armed#Security alarm is now armed.'
end 

if (difference > 600 and otherdevices['Waiting for Phone'] == 'Off' and otherdevices['Leaving'] == 'On') then
 commandArray['Waiting for Phone'] = 'On'
 commandArray['Harry Phone'] = 'Off'
 commandArray['Chester Phone'] = 'Off'
 print ('Waiting for phones to return.')
end 

return commandArray

Again, I’ve removed quite a few of the potential sensors to activate the alarm, but you get the idea.  You may notice another switch in there – “SECURITY Living Room”.  This switch is linked to a network camera we have in the living room, and thanks to the inbuilt scripting in Domoticz, sends a picture from the camera via email to multiple recipients.

The Security Screen of my homemade home control panel

The above script checks how long it has been since the “Arm Security” switch has been activated.  If 5 minutes, then the “Security Alarm” switch is turned on.  If 10 minutes, then the system starts searching for phones.  Living in a block of flats it is hard to judge the best interval for this.  On more than one occasions Chester and I have left the flat for the day, only to bump into a neighbour on the stairwell and have a gossip with them.  This has turned into more than a 10 minute delay, and as we’re still in range of our WiFi, this in turn switches off the “Security Alarm” switch.

Now we need the script to watch out for our phones to automatically disarm the system.  This is in three parts.  One part controls the timing (i.e. run a script every minute if waiting for phones to return) while the other two try to find our phones using a quick Python script.  The first goes in the domoticz/scripts/lua folder and I have called it script_time_SECURITY_Phones.lua:

commandArray = {}
if otherdevices['Waiting for Phone'] == 'On' then
 os.execute('python3 ./Security-Detection-Harry.py &')
 os.execute('python3 ./Security-Detection-Chester.py &')
end 
return commandArray

As you can guess, we now need some Python programs.  They are both the same (except each phone has its own static IP address and its own switch in Domoticz).  These are stored in the domoticz folder itself (not in any subfolder):

This one is called Security-Detection-Harry.py

import urllib
import requests
from random import randint 
import base64,requests,json,time,datetime
import os
"""
Detects Harry's phone and switches Domoticz if found.
"""
hostname = "192.168.1.1"
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
   print (hostname, 'is up!')
   req = requests.get('http://192.168.1.94:8080/json.htm?type=command&param=switchlight&idx=176&switchcmd=On')
else:
   print (hostname, 'is down!')
   req = requests.get('http://192.168.1.94:8080/json.htm?type=command&param=switchlight&idx=176&switchcmd=Off')

So the above script searches for my phone (the IP address of my phone is fixed to 192.168.1.1) and switches a switch in Domoticz if my phone is detected or not.  In the above example Domoticz has given my “Harrys Phone” switch the number 17, so that’s the one I want to alter depending on whether the phone is present or not.

The next script deactivates the security alarm if the phones are detected.  Saved in domoticz/scripts/lua it is called script_device_SECURITY_Phones.lua:

commandArray = {}
if devicechanged['Waiting for Phone'] == 'On' then
 commandArray['Harry Phone'] = 'Off'
 commandArray['Chester Phone'] = 'Off'
end
if (devicechanged['Chester Phone'] == 'On' and otherdevices['Waiting for Phone'] == 'On' and otherdevices['Leaving'] == 'On') then
        commandArray['Leaving'] = 'Off'
        print("Chester's phone detected.")
 commandArray['SendNotification'] = 'Security Message#Chesters phone detected.  Disarming system and switching on devices.'
end
if (devicechanged['Harry Phone'] == 'On' and otherdevices['Waiting for Phone'] == 'On' and otherdevices['Leaving'] == 'On') then
        commandArray['Leaving'] = 'Off'
        print("Harry's phone detected.")
 commandArray['SendNotification'] = 'Security Message#Harrys phone detected.  Disarming system and switching on devices.'
end
if (devicechanged['Chester Phone'] == 'On' and otherdevices['Waiting for Phone'] == 'On' and otherdevices['Leaving'] == 'Off') then
        commandArray['Waiting for Phone'] = 'Off'
        print("Chester's phone detected.  No action taken.")
end
if (devicechanged['Harry Phone'] == 'On' and otherdevices['Waiting for Phone'] == 'On' and otherdevices['Leaving'] == 'Off') then
        commandArray['Waiting for Phone'] = 'Off'
 print("Harry's phone detected.  No action taken.")
end
return commandArray

Very nearly there!  This script is saved in domoticz/scripts/lua and is called script_device_SECURITY_Return.lua and tells Domoticz what to switch back on when one of us arrives home.

commandArray = {}
if devicechanged['Leaving'] == 'Off' then
        commandArray['Power Up'] = 'On'
        commandArray['Living Room Camera'] = 'Off'
        commandArray['Arm Security'] = 'Off'
        commandArray['Waiting for Phone'] = 'Off'
        commandArray['Security Alarm'] = 'Off'
        commandArray['Environment Automation'] = 'On'
 if otherdevices['VAR Dusk'] == 'On' then
         commandArray['DIMMER TV Lamps'] = 'Set level 100'
         os.execute('./Hue-LR-Darkday.py')
  commandArray['Front Balcony Lights'] = 'On'
 end
        commandArray['Air Purifier'] = 'On'
        commandArray['Living Room TV'] = 'On'
        commandArray['Washing Machine'] = 'On'
 commandArray['Cat Sitter'] = 'Off'
end
return commandArray

Now there’s only one thing left to do: decide what happens when the alarm is activated.  You could turn on lights, make sound come out of a network speaker, switch on the TV, contact you using the Domoticz alerts function… the list is endless.  Here’s some of my code, again stored in domoticz/scripts/lua and this is called script_device_SECURITY_Sensors.lua

commandArray = {}

if (devicechanged['DOOR Entrance'] == 'Open' and otherdevices['Security Alarm'] == 'On') then
 commandArray['SendNotification'] = 'Security Message#Front door opened.'
 commandArray['VAR Entrance'] = 'On'
        commandArray['SECURITY Entrance'] = 'On'
 print('ALARM ACTIVATED - FRONT DOOR SENSOR')

elseif (devicechanged['DOOR Hallway'] == 'Open' and otherdevices['Security Alarm'] == 'On') then
 commandArray['SendNotification'] = 'Security Message#Hallway door opened.'
        commandArray['SECURITY Living Room'] = 'On'
        print('ALARM ACTIVATED - HALLWAY SENSOR')

elseif (devicechanged['DOOR Hallway'] == 'Closed' and otherdevices['Security Alarm'] == 'On') then
 commandArray['SendNotification'] = 'Important Security Message#Hallway door closed!'
        commandArray['SECURITY Living Room'] = 'On'
        commandArray['VAR Entrance'] = 'On'
        print('ALARM ACTIVATED - HALLWAY SENSOR')end
return commandArray
This is a small (but functioning) fragment of all the sensors that will trigger a security alert in the flat if we are away and something unexpected happens.
Summary
I have probably made this system more difficult than it needs to be over time, but this security system does work flawlessly and does provide peace of mind when we’re away.  If you have some home automation sensors doing one type of job, why not get them involved in creating a bespoke security system… and make them earn their keep around your home.  Your family will thank you for it – as long as the process of arming and disarming the system is as user friendly as possible.

LightwaveRF and IFTTT

LightwaveRF have opened a channel on IFTTT, meaning that as long as you have a Lightwave Link Hub, you can control your lights (and later, switches) via a staggering array of recipes  using pre-made ones or by picking a choosing events from a long list of items such as calendar entries, Nest devices and emails.

ifttt1

Although not as useful for me as I prefer lower-level controlling of the devices, I can see that this is a great leap for LightwaveRF.  The company produces really good quality products and I am surprised that not more people have heard about them.  Hopefully this partnership will switch on more people to the potential time and energy saving attributes of good quality home automation products.

 

Controlling Sonos via LightwaveRF Mood Controllers

I had a request to write about how I control my Sonos players via my LightwaveRF Mood Controllers.  Actually, it’s a good call: re-engineering the mood controllers from simple light switches to pads which can control both lighting moods and audio more closely reflects the ‘built-in’ panels found in expensive custom installs.  In fact, using the technique below there’s nothing to stop you from controlling any number of home control activities from your mood controllers or handheld remotes.

I can say with authority that without these wall-mounted controllers all over the flat, I would never have been allowed to continue developing the system.  Having a familiar controller in each room ensures that users don’t need to run to the central controller or get out their smartphones whenever they want to make quick and regular changes to the light, heating or audio settings.

What you’ll need:

A summary is that node-sonos-http-api does the vast majority of the work, by ‘listening’ to all connected Sonos controllers and controlling them by very simple http requests.  These http requests are triggered by Domoticz once a signal is received from the mood controller.

How long this will take:

  • If you already have the Pi running Domoticz, and have been using a Sonos player already, and maybe have just bought a LigtwaveRF mood controller or other wall controller compatible with Domoticz, the whole thing will take about 30-40 minutes if you take your time.

Add the mood controller to Domoticz

From the Domoticz interface select the Switches screen, then select Learn Light/Switch at the top.  You should imagine the mood controller as two distinct switches stuck together: as far as Domoticz is concerned the two largest buttons are a completely different device compared to the four smaller buttons.

Immediately press the large OFF button (marked with a zero) on the mood controller.  In the box that appears give the mood controller a name – remembering that this is only the name given to the top two buttons of the controller (e.g Bathroom Lights).

This time we’re going to learn the lower row of the mood controller (the four smaller buttons). Repeat the above by pressing Learn Light/Switch and this time immediately press any one of the smaller buttons on the controller.  Name these too (e.g. Bathroom Audio).

Back up your Domoticz database

Just in case the next step causes problems for you it might be good to back up your system.  I’ve only needed to restore the system once – when I made a complete mess of installing node and npm.

Install node-sonos-http-api

I did this to install and it worked.  You may have a different setup or you may want to select another way of doing this.

Make sure you have node and npm installed.  If you don’t, search for and follow the instructions on how to install these carefully as I have messed this up more than once, by being all “I know how to do this, I’ll just skip this step”.  When will I ever learn?!

Get to the Domoticz folder and create a folder called sonos.

In the sonos folder, clone the node-sonos-http-api program by typing


git clone https://github.com/jishi/node-sonos-http-api.git

Navigate to the new node-sonos-http-api folder and fix the dependencies by typing


npm install

You can now run the program by typing


node server.js

Now the magic starts!  Open a browser and navigate to http://192.0.0.0:5005/Kitchen/play, where 192.0.0.0 is the address of your Pi and Kitchen is the name of your Sonos speaker.

The browser will ‘open’ a blank page, but the speaker in the room will start playing (assuming something is in the play queue.  If not use http://192.0.0.0/Kitchen/playlist/My%20Playlist.  This time, the playlist “My Playlist” is selected (make sure you use hex codes such as %20 instead of spaces in the URL- this includes rooms, so Living Room becomes Living%20Room).

Use the commands listed here to control your Sonos players.

Create scripts

Consider the commands you will want to send to Sonos via the mood controllers.

In this example my room is called Bathroom and the functions I want to add to the mood controller are play, pause, Radio 4 and a playlist called Harry 1.

I’ll need to create four scripts.  The easiest way to create scripts on the Pi  is to use nano, or off the Pi I use WinSCP.

Make sure the scripts are stored in the domoticz folder (not any subfolder).

The scripts will be called Sonos-BR-Play,.sh Sonos-BR-Pause.sh, Sonos-BR-R4.sh and Sonos-BR-Harry1.sh

Sonos-BR-Play will include the following text (just one line is needed to send an http request via a command called curl):

curl http://192.0.0.0:5005/Bathroom/play

Where 192.0.0.0 is the address of the Pi and ‘Bathroom’ is the exact name of the Sonos player.

The other 3 files contain very similar commands:

curl http://192.0.0.0:5005/Bathroom/pause

curl http://192.0.0.0:5005/Bathroom/favorite/BBC%20Radio%204

and

curl http://192.0.0.0:5005/Bathroom/playlist/Harry%201

So now I have these files in the domoticz folder.  I need to make them executable by Domoticz, so in the domoticz folder type


chmod u+x *.sh

We’re coming to the last part now!

Create LUA scripts for Domoticz

We need to run the scripts we created when Domoticz detects the button being pressed on the mood controller.  Let’s imagine the 4 small buttons on the mood controller are going to control the 4 functions we’ve just created scripts for.  The four buttons change the Domoticz device to Group Off, Group Mood 1, Group Mood 2 or Group Mood 3.  You can test this by pressing the buttons and waiting to see Domoticz change the status of the device.

I’m going to imagine that the mood controller’s set of 4 buttons is called ‘Bathroom Audio’ in Domoticz.

Go to the domoticz/scripts/lua folder and create a new file called script_device_BathroomAudio.lua

In the script I’m going to put this text in (you should see by the contents how you can change this):


commandArray = {}

if devicechanged['Bathroom Audio'] == 'Group Off' then

os.execute('./Sonos-BR-Play.sh')
print ('Bathroom Play via mood controller')

elseif devicechanged['Bathroom Audio'] == 'Group Mood 1' then
os.execute('./Sonos-BR-Pause.sh')
print ('Bathroom Pause via mood controller')

elseif devicechanged['Bathroom Audio'] == 'Group Mood 2' then
os.execute('./Sonos-BR-R4.sh')
print ('Bathroom Radio 4 via mood controller')

elseif devicechanged['Bathroom Audio'] == 'Group Mood 3' then
os.execute('./Sonos-BR-Harry1.sh')
print ('Bathroom Harry Playlist via mood controller')

end

return commandArray

That’s it! You should be able to control your Sonos anywhere you can stick a LightwaveRF mood controller.  Let me know how you get on!

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!

DIY: Make a better handset controller

Although I like the look of the standard LightwaveRF hanset controllers, the user of said controller has to remember what device is switched on and off when a numbered button is pressed.  This requires Mastermind-level memory.

Besides, I don’t use the controllers for ‘On’ and ‘Off’ per se, rather just to send a signal to Domoticz, so that the computer can decide what to do (or to reject the command altogether).  This means that the same button can be used for ‘On’ and ‘Off’, and therefore the same handset can be used for multiple functions (lighting moods and audio for example).

So a way to make these controllers more intuative is to add personally created templates to them so that the controller becomes part of your home setup.  You can choose a theme and run with it (as shown).

Firstly, this procedure is reversible, so if you don’t like what you’ve done, you can undo it all and revert back to your original handset.  Just remember to keep all the bits that come off the controller safe.

Secondly, you will lose some functionality.  Because the switch is removed, you don’t have the ability to select button set A, B, C or D.  I personally don’t care about this because the whole reason I wanted to make a custom cover for my remotes was to make them as user friendly as possible.

And if your family can remember that C4 controls the TV power, and D2 controls the garage door, and B1 to B4 control the kitchen lights, then you shouldn’t be reading this blog: you should all be at Cape Canaveral getting ready to take off a-la-Lost in Space.  Danger, Will Robinson!

Basically, you’ll end up with 10 buttons per customised handset.

 

1. Peel off the backing sticker from the controller to expose a screw and unscrew it.

1

2. Prise open the controller.  The things that should come off (quite easily are: The front cover, the rubber keys, the switch (which may come off in one part or may split into the plastic part of the switch and the metal part).  And the screw of course.  If the circuit board has come off from the base of the remote then I think you used a little too much force!  Get you, butchy.

2

You’ll notice that the rubber buttons are not needed – the ‘pads’ you can see in the image are self-contained switches.  Like the ones you get on blister-remotes.

3. Design your overlay.  I will post a template that you can use (search for the ‘Templates’ tag).  Don’t forget to leave a space where the led will shine when a button is pressed.

I used icons from Flat Icon.

4. Print and cut out the overlay.  I found that good quality bright white matt card worked best.

You may need to cutoff tiny strips from any side to make the overlay fit correctly.

3

5. Put one or two layers of the same card underneath the overlay (between the keys and the overlay).  This will make the control pad seem more springy.

6. Tape on the overlay onto the front of the controller.  I used normal tape here but I should have used a thick tape so that I only needed to use 1 pass, rather than 3 passes as I have done in the above picture.

Make sure that you don’t tape up the drawer on the back, otherwise you’ll have probelms when it comes to changing the battery.

7. Voila!  The below example is for the kitchen.  That’s why there is a cute chef as one of the buttons: when you press the chef button, all the devices in the kitchen switch on.

4

8. Now it’s time to program what happens when you press the keys.  More on that elsewhere in this blog.

5

Here’s an example handset (this one is for my bedroom).  It’s been created in the same style as all the ‘hardware controllers’ in the flat, so that picking it up and using it should be second nature.

You can for once use your creative side and your geek side together for this project.  Why not speak to members of your family to get an idea of what they’d like to see on the controllers (favourite colours, family member/pet’s faces etc).  Maybe they could even design the templates for you!

 

 

The bits and bobs what we have

Here’s a starter for 10.  An initial list of the items I’ll be talking about on this blog.  This is not exhaustive, even though I feel exhausted writing this down!

We’ve collected these various disparate systems over the past few years.  It’s my job to make them speak to each other.  Like some kind of flamboyant interpreter at an important European parliament discussion.

Sensors

3 x Oregon Scientific thermo/hygro sensors to monitor temperature and humidity throughout the flat, and outside on one of the balconies.  They send messages to the computer, roughly once a minute, giving up to date temperature and humidity data.  They also include in the message, a request for batteries to be changed.  That’s polite, isn’t it?

Available from: John Lewis

4 x LightwaveRF door sensors to determine if doors in the flat are open or closed – these send one signal when the contacts are moved apart – door open, and one signal when the contacts come back together – door closed. Open, closed.

Website: LightwaveRF

3 x LightwaveRF PIR sensors. These send out a signal when they detect movement, and then another signal when there is no longer any movement.  You can set how long the sensors wait before checking if there is no movement by selecting a time period using a switch on the back.  This can be from 5 seconds, to 10 minutes.  To literally never.

Website: LightwaveRF

Plugs

10+ LightwaveRF plug-in units.  These units do one of two things, depending on which ones you buy.  One type is ON/OFF which means that a signal is received and then ‘ping’, the device you’ve plugged in comes on.  Used for things like TVs or Microwaves.  The other type is DIMMER which means that not only does the device plugged in switches on and off when a command is received, but also that the device can dim from between 0% and 100% brightness.  Or it should go down to 0%, but doesn’t.  More on that in another post.  You really should not use dimmer switches to control the power level of a Microwave.

The plug-in units are really, really useful, and they were especially so when we rented, because they can be removed from a plug socket when you move, instead of frantically tugging out every electrical outlet in the last 5 minutes of your tenancy.

Website: LightwaveRF

1 x Belkin WeMo plug-in unit. I bought this from Maplin as an impulse buy, as it links with another recent purchase, my Ivee Sleek.  I’ll be doing interesting things with both of these items in the coming weeks.  Mainly when Ivee becomes more than a fancy alarm clock that chirps up randomly whilst you’re watching television.

Lighting

20140706_163537We have 17 Philips Hue bulbs and lightstrips in the flat.  These are what really shook up the home control thang, and made our lives better, more relaxing, and simpler.  Quite simply these are the best home control things I have bought.  Not only do they look good, they also behave 99% of the time, and they can be controlled from practically any computer program.  This is the holy trinity as far as home control goes.  Honestly, I can’t say too many good things about Philips Hue.  More gushing to come.

Where it is physically impossible to get Philips Hue bulbs, we have LEDs.  So the flat is very nearly 100% LED lit.  There are three exceptions in the kitchen where LEDs cannot be used at the moment.  Damn you, kitchen!

We also have a few LED downlighters that can be controlled by the LightwaveRF signals.  These are cute and can be used under shelves to create mood lighting.  The only downside is that they go through AAA batteries like our cat goes through litter.

Heating and Environmental Controls

We have an app-controlled heating system called Hive.  You can control the heating from wherever you can get online with your phone (which means everywhere).

Any flat can get problems with high humidity, so we have a dehumidifier.  It’s quite a cheap one, but I’ve made it very intelligent.  It only comes on when necessary, and only when we’re home.  I’ll blog about that some time.

We also have an air purifier which is also similarly automatically controlled.  The air purifier has a lovely colour changing effect and belches out lavender fragrance.  This is nothing to do with home control, but is very much to do with my other hobby, which is being incredibly and breathtakingly gay.

Controllers

To ensure we can ‘talk’ to the flat, we need to have some kind of way to speak to it.  I can go in and change the code in my control programs, but that isn’t very easy to do for many users, so a pretty looking button or a screen is a good way of doing this.

Many of these controllers are supposed to be ‘paired’ with a specific device to switch them on or off.  I shun this concept as amateurish.  I ‘pair’ the controller with the computer, so that the computer decides what to do when it receives a signal from the controller.  More on this later in the blog.

pad4 x LightwaveRF wall mood switches are used throughout the flat to control lights and moods in various rooms.  These are useful because (a) you can stick them anywhere – so you can place them where a light switch would normally be, and (b) because they are always there.  It’s one thing having a smartphone controlled flat, but what if you don’t have your smartphone with you and all you want to do is turn on a light!  Cue this.

The mood switches have 6 ‘pads’ to press.  Two large ones, marked 1 and 0, and four smaller pads, marked with symbols ‘-‘, ‘–‘, ‘—‘ and a standby icon.

The mood switches are good, and look great, but they have very generic markings on them.  I’ve overlaid a printed design on top of them so that users can tell what will happen when a button is pressed.  The switches also have a delightful blue LED which charmingly illuminates to confirm that a signal is being sent.

4 x LightwaveRF handset controllers.  These are hand-held controllers, comprising of 10 buttons and a four-way switch.  8 of the buttons send out unique signals which change depending on the position of the switch, therefore there are 8 x 4 = 32 unique signals.  The other two buttons send out the same signals regardless of the position of the 4-way switch.  Therefore there are 32 + 2 = 34 different signals that can be sent out from these controllers.  I am no Carol Vorderman but Excel tells me that I’m correct.

Sony Tablet S in charging dock.  This is a pretty standard android tablet which is always standing in its charging dock.  It makes controlling the flat easy, as long as you’re in the living room and you have fingers.  The above controllers are used elsewhere.

Ivee

Ivee was so exciting before I bought her.  She literally took months to enter my life, I was counting the days from when I ordered her from Maplin.  Ivee is supposed to be an always-listening voice-controller for your connected devices.  As it is, I can try and ask her “Hello Ivee.  Turn on the bathroom lights.” and she’ll respond with the phrase “The time in Handsome Eddy, New York, is 12:50am”.

I’m sure she’ll get smarter.

Smartphones.  This one is a no-brainer.  It’s also very impressive to show people.  “Hey, look at this.  I can switch on the fan in my living room from here in the office”.  And then they usually say something like “I’ve left something on the photocopier” and leave.  Quickly.

Audio

20150111_215333We have Sonos everywhere.  Literally everywhere.  As the flat is quite small, we have 3 PLAY:1 speakers, a CONNECT (for broadcast to the bathroom), and a PLAYBAR which is a stereo and a TV soundbar all rolled up in one very “I may look like a draught excluder but actually I cost twice as much as the TV I’m under” package.

The Sony tablet in the living room, and our smartphones can control the Sonos, as well as any of the handsets affixed throughout the flat.

The Brain

The brain of the whole crazy outfit is a teeeeeny tiny little computer called a Raspberry Pi.  This computer, the size of a pack of cards, is useful because it doesn’t use a lot of power (so you can leave it on all the time) and it’s reliable.  I use a program called Domoticz to run everything.  A heck of a lot more on this particular set up later.

The interesting thing about home control is that it can be as simple or as complex as you want to make it.  You can decide ‘I want a lamp in my living room to come on when it gets dark outside’ or ‘I want the flat to email me when the humidity gets stupidly high in there’, or ‘sound an alarm and email me when we’re supposedly out of the flat and a door is opened or a movement sensor is activated’.

With a bit of playing around, the world is your oyster.  Or your home is your servant.