Saturday, 31 October 2015

Milight Smart LED bulb review

I've just bought a Milight bridge, 9W RGBW bulb and 2.4Ghz remote.  All from Amazon Uk (from sellers Datawize, BatteryLogic).  From researching online it seems there's at least 5 different names for these bulbs (milight, easybulb, led logic, limitlessled, etc).  The seller of the bridge/hub/controller/box/thingy assures me it's version 4 (there have been 5 versions) but I can't see how to tell without taking it apart.  

I downloaded the android app 'Milight 2.0' by 'Sunny' which seems to be the official app. The instructions actually refer to 'Mi.light' app, which seems to look and work exactly the same (i.e. not very well).  I managed to use the app to find the bridge by connecting to it's own Wifi network.  You can then go into configuration and "AP configure" which allows you to join it to your own Wifi network.  The inbuilt wifi then seems to turn itself off.

Now at this point I repeated the above steps several times, because I couldn't (or rather the app couldn't) see it after it had been configured.  You can re-set the thing by holding in the hidden reset button with a pin until the lights flash rapidly.

I also at this point went into my router settings and made sure DHCP would always give it the same IP address (based on its MAC address).

After a few attempts I went back to the Play store and found the Wifi RGB Led controller app by Cold-Core which actually recognized the bridge and allowed me to pair it with the bulb (to do this, turn on the bulb at the switch and press "on" on one of the zones (1-4) within 3 seconds - the bulb will then flash 3 times for success.  The pairing process is identical for the plastic remote control.

Now that all worked I configured the openhab binding by following this page https://github.com/openhab/openhab/wiki/Milight-Binding - substituting my newly assigned static IP address and putting port 8899 and using channel number 6 rather than 1 to reflect how the new bulbs/bridges work.  I can now turn bulbs on/off and change colour both remotely and automatically (e.g. when home is unoccupied, or when i stumble downstairs in the middle of the night).

With that all working, overall I'm impressed - for a fraction of the price of Hue/Lifx they seem to do the job.  The only downside I can see is they don't report status, so sending messages is "fire-and-forget".  I haven't had any problems so far however.

There's some detail on development and versioning of the APIs, bridges etc on www.limitlessled.com/dev/

Sunday, 21 June 2015

Quainton Village Society

Just a quick one to say I'm now hosting another website for the folks in Quainton - check it out at Quainton Village Society

Wednesday, 10 December 2014

Getting the Dell Laser printer C1760nw working on 64 bit Debian

I've just taken delivery of a Dell C1760nw from Amazon for just over £100 to replace the knackered inkjet which went before it.  As expected, getting the drivers working wasn't plain sailing, so for everyone else's benefit, here's what worked for me:

1) Download the 32 bit deb from here: http://www.support.xerox.com/support/phaser-6000/downloads/engb.html?operatingSystem=linux&fileLanguage=en_GB
2) Open a terminal as root
3) dpkg --add-architecture i386
4) apt-get update
5) apt-get install libcupsimage2:i386
6) dpkg -i xerox-phaser-6000-6010_1.0-1_i386.deb
7) /etc/init.d/cups restart
8) Navigate to http://localhost:631
9) Add a printer (Xerox Phaser 6000B v1.0)
10) Print test page
11) Celebrate.

Thursday, 30 October 2014

My Z wave and Openhab configuration

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.

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)...


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.




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:

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_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:

  1. Don't forget to connect the grounds of the Pi and the Uno together
  2. We used GPIO 18 on the Pi as a digital output connected to pin 10 on the Uno
  3. Be careful if you're using the Pi for digital input as it'll only take 3.3 Volts
  4. We used the onboard LED on the Uno to check that we were sending the right signals to the transmitter
  5. We needed a short delay between sending commands to the transmitter, otherwise we'd only get some rather than all the lights to respond.
  6. You'll need to run the python script under sudo to be able to write to the GPIO