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)

PNG(s) to PDF, the command line way

A quick tip for command line users: if you want to convert .png files to .pdf:

convert *.png filename.pdf

Simple! If you want to keep control of page sequence or specific files to convert:

convert page1.png page2.png page3.png filename.pdf

Needless to say, but I’ll say it anyways, the .pdf won’t be in vector graphics, so not scalable but that is because .png is not a vector graphics format.

Ejabberd on Ubuntu

Just keeping a note to self (and others who could find it useful). How to install Ejabberd on Ubuntu server 12.04:

  • aptitude install ejabberd (for some reason apt-get didn’t work out that well);
  • go to wherever you manage your DNS records and add a SVR record as mentioned here;
  • edit /etc/ejabberd/ejabberd.cfg and add admin user as mentioned here .

All of these steps are to avoid placing hosts as localhost on your ejabberd.cfg file which could work but than you might have problems with clients trying to connect.

Diff with vimdiff

For those who are vim fans, a quick tip on how to run a diff/merge  task:

Open the files with:

vimdiff file1 file2 file3   –> Vertical split is default

vimdiff -o file1 file2 file3  –> If you’d like horizontal split of files

To jump between files:

Ctrl-W w

To jump places where differences are found:

]c    –> to see next part of a change

[c   –> to go back to the start of a previous part of a change

These are just the quick basics, there are a ton of other commands listed on Vim’s documentation page.

Installing CyanogenMod on HTC Desire [Android]

I’m tired of waiting for T-Mobile NL to give me FroYo (Android 2.2). Besides, that controlling which apps I can or can’t have access to.

So, let’s get to it ourselves!

Starting this process I didn’t have the needed warm and fuzzy feeling because the tutorials I found were not so detailed. Which is why I’ll describe step-by-step what I did  (actually typing while I’m going through the process myself):

——-

Note: I’m not responsible for anything that happens to your phone and I can’t provide any support or additional information. I ran it on my own doing some research, please try to do the same if you get stuck.

——-

  1. First, backup your apps. I did it with an app called “Astro File Manager”
  2. To get root, go to Unrevoked. Select your mobile device and your OS.
  3. I’m on a Linux machine, so after I have reflash.tar.gz downloaded on your computer, untar it, than run sudo ./reflash
  4. You’ll be guided about the next steps (connect your phone as disk drive, turn on USB Debugging).
  5. Once everything is done, I got on my phone a “ClockworkMod Recovery” boot screen. Just to be extra safe, I ran through “Backup and restore” to create a backup. After the backup was done, I chose “reboot system now”
  6. Now you should have root! :) The phone should restart the looking the same as it did before.
  7. Let’s prepare to install something else. From your computer download the latest version of the radio. I got the link from here . Move the zip file to the root of your phone’s SD card.
  8. Go to the Android Market and find/install “ROM Manager” (I used the free version). After it is installed, run it and choose to boot in recovery mode. You should get a screen asking you if the action has root access, allow it and run it again.
  9. Now back in ClockworkMod Recovery, choose “install zip from sdcard”. Find the zip file you just downloaded and install it.
  10. Reboot your phone.
  11. Now back into your normal looking phone again. Go back to ROM Manager and select “Download ROM”
  12. Let’s pick CyanogenMod, latest build is given and select Google Apps as well.
  13. Once everything is downloaded, click both checkboxes “Backup existing ROM” and “Wipe Data and Cache”. Press ok.
  14. You’ll now reboot to CyanogenMod! Process done!

References:

Encrypt files with GnuPG

Here is a simple and quick way for you to encrypt files in Linux:

gpg –output doc.gpg –encrypt –recipient EmailofRecipient@blah.com original_file.doc

Further explained:

  • –output (or -o) is the name of the encrypted file
  • –recipient (or -r) is the person who will be decrypting the file. If the file is for yourself only, use the email address of your GPG key.

To decrypt:

gpg --output output_file.doc --decrypt doc.gpg

I recently used this to encrypt a sensitive file before placing it on my Dropbox account. Nice safe way to place a private document in the cloud.

Reference, GnuPG manual.

Download YouTube videos (Linux)

Want to know how to download a YouTube video? Just go and watch the video! It’ll automatically be downloaded for you. Let me explain further…

While you watch the video on the web it is being downloaded for you to your /tmp directory. Try it out:

  1. go watch any YouTube video
  2. go to /tmp
  3. you’ll find a mysterious file name there without any extension reference. Double click and you should see that is is your video. If you’d like change the file name to something you’ll remember better and move it to whichever folder you want.

The  file downloaded will be .flv so if you want another format later on, please use a converter app.

Gwibber microblogging app now 2.0 [Linux]

Gwibber, an open source microblogging app for Gnome has now reached version 2.0!

Although at 2.0, the developers are not considering this a stable release yet and not making it available on the stable distribution channels. What I could notice first from the upgrade was the UI from:

to

Gwibber 2.0

Which means:

  • it is now easier to jump between different accounts (Gwibber supports Identi.ca, Twitter, Facebook, Digg, StatusNet, Flickr and more).
  • You can easily post to only one account.
  • Easy “re-dent” / “re-tweet”.

I’m sure there are more behind the scenes improvements but so far I haven’t seen any list. For now, the upgrade was worthwhile.

Recover deleted files with Magic Rescue

If you’re trying to recover deleted files or files in a corrupted partition, you might want to give Magic Rescue a try. With this command-line tool you will basically be looking for specific file types (searching by their extension). So, for a massive file recovery task, it will not be a good approach.

The program uses what it calls “recipes” as the instruction of which files to look for and how to do so. On a standard installation of Magic Rescue on my Ubuntu 9.04 distro, I got the following recipes (located at /usr/share/magicrescue/recipes) :

  • avi
  • elf
  • gimp-xcf
  • gzip
  • jpeg-jfif
  • mp3-id3v2
  • perl
  • zip
  • canon-cr2
  • flac
  • gpl
  • jpeg-exif
  • mp3-id3v1
  • msoffice
  • png

If you’d like you can write your own recipe, the man page will instruct you how to do so.

To start looking for files, make sure you create an output directory and than execute:

magicrescue -r [name of recipe] -d [output directory] [DEVICE PATH, eg /dev/sda]

*more options and parameters are available, the above are the mandatory ones.

I used it testing .avi extensions and it worked pretty well to recover some files I had deleted even a long time ago.