Raspberry Pi, Fhem and the Philips Hue

While searching for other ways to control a set of Philips Hue lights, I found fhem (a GPL’d perl server for house automation). With fhem I can have a huge amount of flexibility on automation rules and combination of devices working together; but for now I’m interested in a quick way to control the lights from outside of my house without using a 3rd party service.

For the Raspberry Pi OS, I went with Raspbian . Instructions are already pretty detailed on their site so I won’t repeat it.

To install fhem, do the following on your Raspbian:

1. sudo apt-get -f install && sudo apt-get install perl libdevice-serialport-perl && sudo apt-get install libio-socket-ssl-perl && sudo apt-get install libwww-perl

2. sudo wget http://fhem.de/fhem-[latest-version] && sudo dpkg -i [latest-version].deb

3. cd /opt

4. sudo chmod -R a+w fhem && sudo usermod -a -G tty pi && sudo usermod -a -G tty fhem

5. sudo cpan JSON

6. echo -n $Username:$Password | base64 (Save the output of this command!**)

Now go to your fhem web view, at http://ip-of-your-raspbian:8083 . You will probably see an alert:

WEB,WEBphone,WEBtablet has no basicAuth attribute.
telnetPort has no password/globalpassword attribute.

To remove this, edit your config file by going to “Edit files” and then click on “fhem.cfg”. You’ll need to add:

attr telnetPort globalpassword $Password

attr WEB basicAuth **Output_of_step_6_command_above

attr WEBphone basicAuth **Output_of_step_6_command_above

attr WEBtablet basicAuth **Output_of_step_6_command_above

On my example, I used the same username and password combination for the web, mobile and tablet interfaces, which is written on step #6 above. If you wish to use different password and/or usernames just create new base64 hashes.

Going back to fhem’s web interface, you should now see a text input box on the top of the page and on the left a set of menu items. On the text input box type:

define bridge HUEBridge

After that, run really fast to your Hue bridge and press the link button. Go back to fhem, refresh and you should see the Hue Lights now displayed.

Sources:  meintechblog (in German),  Robin’s Blog (in German)

One thought on “Raspberry Pi, Fhem and the Philips Hue

Leave a Reply

Your email address will not be published. Required fields are marked *