Over the last few weeks I've dived into Z Wave home automation with both feet, and now have several things working well (after much fiddling). For those of you thinking of doing the same, or having issues with anything, you might want to look over my github repository which contains my openhab configuration files.
I'm using OpenHAB and I've been nothing but impressed with it, fully open source, and the google group is insanely helpful (Thanks Chris!)
I'm currently using:
An ASUS eeePC 901 running Debian Jessie
An Aeon Labs Z-Stick S2 USB Zwave stick
2 x Aeon Labs 4 in 1 multisensors
2 x Vision Security door/window sensors
3 x TKB Home wall plugs
1 x Horstmann ASR-ZW + HRT4-ZW boiler control / thermostat combo
I'm currently implementing the "wasp in a box" presence detection to control heating temperatures to attempt to save money, and busy thinking of more use cases for it.
I'll commit to the repo whenever anything changes, and hopefully keep you updated here if I remember.
Thursday, 30 October 2014
Friday, 27 June 2014
First Adventure with Z-Wave Home Automation
As we're (hoping to) soon be moving house, I wanted to look into home automation, starting with a set of Philips Hue lightbulbs on my wishlist, but reading led to yet more reading and I've ended up with the beginnings of a Z-Wave network.
I've purchased an Aeon Labs USB stick to stick in the side of my old unused netbook, and am dabbling with python-openzwave. My first task was just to get the sensors (Aeon labs MultiSensor) recognised, and then start building some logic to monitor the temperature and turn on a fan if it rises above a threshold.
I've put some code up on github called flask-openzwave which I hope to grow as I learn more about Open ZWave.
Maybe foolishly, I decided this would be more fun than just buying a box (essentially another linux computer) pre-build with pre-made software. The only thing I'll miss is a nice Android app, but this can be mitigated by some keyfobs and a REST-like web interface. My wife will love it (maybe)...
Labels:
automation,
homeautomation,
zwave
Tuesday, 29 April 2014
Your machine slowly runs out of disk space after using Assembly Binding Log Viewer
I came into the office this morning to find my laptop complaining that disk space on drive C: was critically low - which was odd as my 240GB SSD should be less than half full.
After running SpaceSniffer it was taking ages in C:\Windows\system32, further digging through the graph pointed me to C:\windows\system32\config\systemprofile\appdata\local\content.ie5 which had around 300,000 files in it. All of them were .htm files, so I (tentatively) opened a file up in Vim (so it wouldn't run any scripts, etc). It was then I realised what they were - all of them - were "Assembly Binder Log Entry" files.
I then remembered several weeks ago trying to debug a .NET assembly binding issue, and I'd turned on "Log all binds to disk" in Fuslogvw.exe, fixed my problem but didn't really "click" that it needed turning off afterwards. I naively assumed it would only be logging for the duration I had fuslogvw open. Wrong!
Clearing out the Temp htm files from the above location (by running explorer.exe as an administrator and granting myself permissions) only freed up around 500MB however, I was still missing around 100GB(!).
Running spacesniffer again gave me a new location to investigate: C:\windows\syswow64\config\systemprofile\appdata\local\content.ie5 - which makes sense as it's a 64 bit machine running mainly 32 bit binaries. However, no matter how many times I tried, I couldn't grant myself access, there were simply too many files and it kept timing out.
In the end I followed the process listed here to use psexec to open a command prompt as the relevant user, and set off a del *.htm command which took a good 6 hours to complete, but at least I've got my disk space back, and I won't be making that mistake again in a hurry.
After running SpaceSniffer it was taking ages in C:\Windows\system32, further digging through the graph pointed me to C:\windows\system32\config\systemprofile\appdata\local\content.ie5 which had around 300,000 files in it. All of them were .htm files, so I (tentatively) opened a file up in Vim (so it wouldn't run any scripts, etc). It was then I realised what they were - all of them - were "Assembly Binder Log Entry" files.
I then remembered several weeks ago trying to debug a .NET assembly binding issue, and I'd turned on "Log all binds to disk" in Fuslogvw.exe, fixed my problem but didn't really "click" that it needed turning off afterwards. I naively assumed it would only be logging for the duration I had fuslogvw open. Wrong!
Clearing out the Temp htm files from the above location (by running explorer.exe as an administrator and granting myself permissions) only freed up around 500MB however, I was still missing around 100GB(!).
Running spacesniffer again gave me a new location to investigate: C:\windows\syswow64\config\systemprofile\appdata\local\content.ie5 - which makes sense as it's a 64 bit machine running mainly 32 bit binaries. However, no matter how many times I tried, I couldn't grant myself access, there were simply too many files and it kept timing out.
In the end I followed the process listed here to use psexec to open a command prompt as the relevant user, and set off a del *.htm command which took a good 6 hours to complete, but at least I've got my disk space back, and I won't be making that mistake again in a hurry.
Sunday, 17 November 2013
Controlling lights from the web using Raspberry Pi and Arduino
I've just got back from a weekend with my parents, where I had lots of fun attempting to get an Arduino Uno to control a cheap set of remote control mains sockets. My dad has a set of 3 of these (http://www.maplin.co.uk/remote-controlled-mains-socket-set-531547) and has them plugged into desk and pedestal lamps in the living room. Since my last two christmas/birthday presents to him were a Raspberry Pi Model B, and a book about home automation using Arduino, he'd picked up an Arduino starter kit from Amazon, and had bought a second remote control and taken it to pieces, all we needed was some solder and some code.
First step, solder 3 wires onto the remote control extracted from the plastic housing, as per http://blog.sui.li/2011/04/12/163/, and connect it up to the Arduino's 5V, ground and digital out pins (I chose pin 11).
Next, import the library from https://code.google.com/p/rc-switch/, then write a quick app to set switch one on and off. Once we'd proved this works, we worked through a quick example using a photodetector, then decided it'd be fun to get this working over the web. Since we didn't have any network connectivity, we roped in the Raspberry Pi to serve a very basic website, and use the Pi's GPIO to signal to the Arduino to turn on the lights. I hope you'll forgive the gross insecurity of the web server, but it's quick and does the job - here's the code:
#include
RCSwitch mySwitch = RCSwitch();
int d_raspPiInputPin = 10;
int d_transmitterPin = 11;
int onboardLedPin = 13;
int lightsOn = 0;
int delayTimeout = 1000;
int delayCommand = 500;
int valueFromPi = 0;
void setup()
{
mySwitch.enableTransmit(d_ transmitterPin);
pinMode(onboardLedPin, OUTPUT);
pinMode(d_raspPiInputPin, INPUT);
Serial.begin(9600);
}
void loop()
{
valueFromPi = digitalRead(d_raspPiInputPin);
if(valueFromPi == HIGH){
allLightsOn();
}
else {
allLightsOff();
}
delay(delayTimeout);
}
void allLightsOn()
{
if (lightsOn == 0) {
mySwitch.switchOn(1, 1);
delay(delayCommand);
mySwitch.switchOn(1, 2);
delay(delayCommand);
mySwitch.switchOn(1, 3);
delay(delayCommand);
mySwitch.switchOn(1, 4);
delay(delayCommand);
lightsOn = 1;
}
digitalWrite(onboardLedPin, HIGH);
}
void allLightsOff()
{
if (lightsOn == 1) {
mySwitch.switchOff(1, 1);
delay(delayCommand);
mySwitch.switchOff(1, 2);
delay(delayCommand);
mySwitch.switchOff(1, 3);
delay(delayCommand);
mySwitch.switchOff(1, 4);
delay(delayCommand);
lightsOn = 0;
}
digitalWrite(onboardLedPin, LOW);
And a photo of the Arduino all wired up:
Notes:
First step, solder 3 wires onto the remote control extracted from the plastic housing, as per http://blog.sui.li/2011/04/12/163/, and connect it up to the Arduino's 5V, ground and digital out pins (I chose pin 11).
Next, import the library from https://code.google.com/p/rc-switch/, then write a quick app to set switch one on and off. Once we'd proved this works, we worked through a quick example using a photodetector, then decided it'd be fun to get this working over the web. Since we didn't have any network connectivity, we roped in the Raspberry Pi to serve a very basic website, and use the Pi's GPIO to signal to the Arduino to turn on the lights. I hope you'll forgive the gross insecurity of the web server, but it's quick and does the job - here's the code:
Python Code:
#! /usr/bin/python
import sys
import RPi.GPIO as GPIO
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class LightsHandler(SimpleHTTPRequestHandler):
def do_GET(self):
print "handling " + self.path
if ("lightson" in self.path):
self.lights_on()
elif ("lightsoff" in self.path):
self.lights_off()
self.send_response(200,'OK')
def lights_on(self):
print "on"
GPIO.output(18, True)
def lights_off(self):
print "off"
GPIO.output(18, False)
HandlerClass = LightsHandler
ServerClass=BaseHTTPServer.HTTPServer
Protocol="HTTP/1.0"
server_address= ("", 8080)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "serving"
GPIO.setmode(GPIO.BOARD)
GPIO.setup(18, GPIO.OUT)
httpd.serve_forever()
Arduino Code:
#include
RCSwitch mySwitch = RCSwitch();
int d_raspPiInputPin = 10;
int d_transmitterPin = 11;
int onboardLedPin = 13;
int lightsOn = 0;
int delayTimeout = 1000;
int delayCommand = 500;
int valueFromPi = 0;
void setup()
{
mySwitch.enableTransmit(d_
pinMode(onboardLedPin, OUTPUT);
pinMode(d_raspPiInputPin, INPUT);
Serial.begin(9600);
}
void loop()
{
valueFromPi = digitalRead(d_raspPiInputPin);
if(valueFromPi == HIGH){
allLightsOn();
}
else {
allLightsOff();
}
delay(delayTimeout);
}
void allLightsOn()
{
if (lightsOn == 0) {
mySwitch.switchOn(1, 1);
delay(delayCommand);
mySwitch.switchOn(1, 2);
delay(delayCommand);
mySwitch.switchOn(1, 3);
delay(delayCommand);
mySwitch.switchOn(1, 4);
delay(delayCommand);
lightsOn = 1;
}
digitalWrite(onboardLedPin, HIGH);
}
void allLightsOff()
{
if (lightsOn == 1) {
mySwitch.switchOff(1, 1);
delay(delayCommand);
mySwitch.switchOff(1, 2);
delay(delayCommand);
mySwitch.switchOff(1, 3);
delay(delayCommand);
mySwitch.switchOff(1, 4);
delay(delayCommand);
lightsOn = 0;
}
digitalWrite(onboardLedPin, LOW);
}
And a photo of the Arduino all wired up:
Notes:
- Don't forget to connect the grounds of the Pi and the Uno together
- We used GPIO 18 on the Pi as a digital output connected to pin 10 on the Uno
- Be careful if you're using the Pi for digital input as it'll only take 3.3 Volts
- We used the onboard LED on the Uno to check that we were sending the right signals to the transmitter
- We needed a short delay between sending commands to the transmitter, otherwise we'd only get some rather than all the lights to respond.
- You'll need to run the python script under sudo to be able to write to the GPIO
Monday, 11 November 2013
BBC's websites killing Press and threatening local democracy, says Theresa May - Telegraph
I'm all for competition and freedom of expression, but on the other hand, I've already paid for the BBC (whether I like it or not - but on the whole I like it), so if I can get good content and news that I've already paid for, she's right I'm not going pay someone else for the same thing:
BBC's websites killing Press and threatening local democracy, says Theresa May - Telegraph:
'via Blog this'
BBC's websites killing Press and threatening local democracy, says Theresa May - Telegraph:
'via Blog this'
Tetris & The Power Of CSS
I found this link today, it's an excellent read, and explains succinctly what I've been wanting to do with my photo library for ages.
Tetris & The Power Of CSS
'via Blog this'
Another good one, which I haven't got round to implementing yet is this:
The algorithm for a perfectly balanced photo gallery
Tetris & The Power Of CSS
'via Blog this'
Another good one, which I haven't got round to implementing yet is this:
The algorithm for a perfectly balanced photo gallery
Subscribe to:
Posts (Atom)