achter.be

photography, coffee, technology and more

Openhab install on Raspberry Pi

Openhab logo

This post is my guide for installing and configuring Openhab on the Raspberry Pi.

Install openhab

  1. Upgrade and update apt-get sudo apt-get update && sudo apt-get upgrade

  2. do a update of the firmware. These are 2 steps you should always do before installing something new. sudo rpi-update

  3. make directory and download and unzip openhab (get link from Openhab/downloads). Replace x.x.x in the command below with the version number you copied. sudo mkdir /opt/openhab && cd /opt/openhab/ && sudo wget "get download link" && sudo unzip distribution-x.x.x-runtime.zip && sudo rm distribution-x.x.x-runtime.zip

  4. Download and install bindings for openhab. This installs all possible addons available. Replace x.x.x in the command below with the version number you copied. cd addons && sudo wget "downloadlink addons" && sudo unzip distribution-x.x.x-addons.zip && sudo rm distribution-x.x.x.-addons.zip

  5. copy the config file and make the startup script executable cd .. && sudo cp configurations/openhab_default.cfg configurations/openhab.cfg && sudo chmod +x start.sh

  6. Edit the config file and start the server. sudo nano openhab.cfg sudo ./opt/openhab/start.sh

  7. Make a startup item with screen, so that you can always access the OSGI console.

sudo nano /etc/init.d/openhab

  1. Paste following code in there on line 14 change the user to your openhab user:

`#! /bin/sh ### BEGIN INIT INFO # Provides: openHAB # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start and stop openHAB in screen Session # Description: This runs openHAB continuously in screen. ### END INIT INFO # Set OH-User OHUSER=openhab # Set OH-Path OHPATH=/opt/openhab

case "$1" in

  start)
        PID=`ps -ef | grep openHAB | grep -v grep | awk '{print $2}'`
        if [ "${PID}" != "" ]
         then
          echo openHAB-Screen is already open, use: sudo -u openhab screen -r `pidof SCREEN`
         else
          echo "Starting openHAB"
          cd ${OHPATH}
          sudo -u ${OHUSER} screen -S openHAB -dm  sh ./start.sh
        fi
        ;;
  stop)
        echo "Stopping openHAB"
        sudo -u ${OHUSER} screen -S openHAB -p 0 -X stuff "exit$(printf \\r)"
        sudo -u ${OHUSER} screen -S openHAB -p 0 -X stuff "y$(printf \\r)"
        sudo -u ${OHUSER} screen -S openHAB -p 0 -X stuff "exit$(printf \\r)"
        PID=`ps -ef | grep openHAB | grep -v grep | awk '{print $2}'`
        while [ `ps -ef | grep $PID | wc -l` -gt 1 ]
         do
          echo -n .
          sleep 2
         done
        echo .
        ;;
  restart|force-reload)
        echo "Restarting openHAB"
        $0 stop
        $0 start
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart}" >&2
        exit 1
        ;;
esac
exit 0`
  1. Make the script executable and configure to run on boot

    sudo chmod a+x /etc/init.d/openhab sudo update-rc.d openhab defaults

    Whenever you want to use the OSGI console, just type

    screen -x and to leave the screen you do ctrl+a d

  2. Normally your server should run now and you should be able to access the demo content through:

    http://<openHAB server ip>:8080/openhab.app?sitemap=demo

Raspberry Pi scrapbook

I’m trying to setup a sort of internet of things sensor network at home.

For this project I’m using raspberry pi and Arduino boards.

As I already had to start over, I’m going to use this post as a scrapbook:

Pi setup:

  1. install Noobs on Raspberry Pi
  2. Select Raspbian as OS
  3. apt-get:
    • tightvncserver
    • upstart
  4. reboot
  5. this probably gives a weird Login screen, ssh to Pi and chown pi:pi .Xauthority in home dir.
  6. reboot again
  7. apt-get:
    • arduino
    • python-pip
  8. install adafruit webide
  9. install pyserial:
    • by downloading latest version (atm 2.7) in tar.gz ->
    • untar -> install with sudo python setup.py install
  10. Make startup script for scripts:
    • doorbell.py

Startup scripts:

  • cd /etc/init
  • nano scriptname.conf
  • copy/paste this code and fill in

    # Program_explanation
    
    description "Your_description"
    author "User"
    
    start on runlevel [2345]
    stop on runlevel [016]
    chdir path_to_dir_with_script
    exec python path_to_script.py
    respawn
    
  • start script with sudo service scriptname start, it starts every reboot and when it quits it respawns.

[review] Backblaze, cloud backup

Backblaze

Since I started using computers, I have had a mixed relation with backups. They are too much hassle to deal with, they fail, I didn’t have enough space. But since the internet connections are able to handle all data I produce now, I decided to start using cloud backup. I’v chosen Backblaze cloud backup.

I had and still have a fully installed and running local backup system. But it took me a while to figure out an easy way to have a offsite backup for my photography. The problem is that having an off site backup used to be a lot of work, I tried several ways, but never found a way that worked reliably and wasn’t a lot of work.

The only easy way, was and still is by uploading everything, but the problem in Belgium was that there were up and download limits set by the providers. Even today on the “unlimited” packages there still is a kind of restriction, it is around 500 gb to 1TB a month depending on the area you live in.

Why Backblaze?

After extensively researching the different solutions, I decide to go with Backblaze, because of the following reasons:

  • Backup external drives
  • Throttle upload speed of your data when needed
  • Ship backup drives worldwide
  • Only 4$ a month if you choose the 2 year plan
  • Unlimited backup space

As far as I found, there are no other services that offer all these options for that money.

How does it work?

It works great, after subscribing and paying with your credit card, you download and install the program for your OS. Backblaze will start to upload data from your internal drives. If you want to add more drives, just select it in the preferences pane. If you have upload limits, you can choose to throttle the speed and Blackblaze gives you an estimate how much it will upload during a day.

A few figures to give you an idea:

  • 1.2 TB data backed up
  • Initial backup took 3.5 months
  • Restored main OS X data once
  • Restored 35 GB in a zip-file

Is it good?

Although it took almost 4 months of backing up, it was no hassle, Backblaze just worked. Restoring was just a matter of selecting the files I wanted, waiting for the zip to be generated and then downloading it.

But it’s not all good, the restore process sucks. You’ll get all your files back, but it’s up to you to put them all back where they belong. That’s no fun, let me tell you. You have to deal with permissions, finding the correct folder and so on. Another annoyance, is the fact that after the restore, my secondary internal drive was no longer recognized as being the same drive, so it had to be backed up again, like the replaced primary drive. Why?

Conclusion?

Backblaze is a great solution for an off site backup, but it takes a while to get all your data backed up, my suggestion let me send you guys a drive with my data for an extra cost, like crashplan does. When you have to restore, it’s all manual labour. I would suggest that they implement some sort of restore program that does most of the work for you.

Despite the remarks I have, I’m a satisfied Backblaze cloud backup user and would recommend it to everybody

I wasn’t forced to write this blogpost, everything in here is my own view, the content wasn’t reviewed by any departement of the brands mentioned in here

[review] Kingston 3K hyperX SSD

Update: after 5 months this Kingston 3K hyperX SSD completely died on me

Kingston 3K HyperX SSD

At the end of june, my girflfriend (SaraVdV) got a mail from Kingston if she and I wanted to test a new SSD drive from Kingston.

After some mailing back and forth, because Sara and I both work on mac’s, Kingston send us both a 256GB HyperX 3K SSD drive. It comes in a nice package, with an external usb enclosure and it’s own screwdriver. Which is always very handy. The drives we received were 2.5″ drives, but included in the package you buy, there’s also a 3.5″ bay.

Because it would be easier from me to put the drive in the MacBook pro 15″ begin 2009 I have, than to put it in an iMac. I started with that computer, the drive is as easy to install as any drive. However when I booted the mac and started installing OS X I ran into some problems.

At first the install of OS X stalled a couple of times, when I finally managed to install it correctly, I had a 25 sec spinning beachball every 2 minutes. However, because we had review drives, I contacted Kingston directly and started to work out the problem with Mario, on of the engineers at Kingston who developed the drive. Turns out that there is an incompatibility between the nvidia SATA I controller in the MacBook 5.1 and the driver for SATA II or III SSD’s in OS X leopard or later. This makes that every time there is a lot of writing activity to the disk that the controller locks the OS for a while untill the buffers are cleared. So I ended up restoring this MacBook to it’s original config. This is not a fault of the kingston drive but an Apple problem, because I also experienced the same behaviour with another brand of SSD’s.

After my debacle with the drive in the Macbook 5.1, I also installed the drive in Sara’s iMac which is not too big of a hassle if you follow all the guides online for replacing a drive in an iMac. I have not had any problems with installing the drive and reinstalling OS X, nor has Sara experienced any problems since the drive was installed.

In July I purchased myself a new 13″ MacBook pro and installed the HyperX SSD in that computer. No problems, everything installs and works perfect.

Performance wise, everything seems a lot quicker on the iMac of Sara, boot times improved a lot. Every program launches faster and the drive behaves very well under pressure. We didn’t do any graphs or charts, because in the end it all comes down to how you preceive the change.

For the MacBook 13″ I did some testing. Without SSD it cold booted in 34 seconds, after install of the SSD it cold boots in 8secs. That’s just amazing. It feels more instant now then waking my iPad first generation from sleep. Programs are launching very fast, lightroom which is the most important program for me, launches in less then 3 seconds in grid view. It all feels very snappy and instant. I haven’t seen a beachball in months. Reboots are only necessary for updates from the OS. It just works and feels fast. It does what I expected an SSD to do.

The nicest surprise is that we may keep the drives, so I got a nice upgrade for my new MacBook thanks to Kingston.

I wasn’t forced to write this blogpost, everything in here is my own view, the content wasn’t reviewed by any departement of the brands mentioned in here. I did however receive a compensation for this post. So decide for yourself how much value you want to attribute to this post.

[Review] Logitech F540

[Samsung nx200] Logitech F540

Playing the xbox late at night, while my girlfriend is asleep, isn’t possible. So I asked Logitech if I could test out the Logitech F540 wireless headphones for game consoles.

A few days later I had the headphones. After unpacking the rather neatly put together box, it was very easy hooking it up to the Xbox. You basically plugg 2 wires into the basestation. The power and the audio cable. It couldn’t be easier

After turning on the headphones and pushing the sync button on both the station and the headphones, all was set. I played several hours while wearing the headset and was very pleased with the battery life, about 10 play hours. The sound quality for me was great too, although I’m not really a sound guy, but heck it was decent enough to hear the rain fall in Oblivion which for me is all I need.

I didn’t really use the microphone in game, but it’s pleasing to hear yourself through the headphones when the mic is on, so you don’t scream when talking. I did try it once and it seemed to work decent enough, but I can’t really tell because none of the other players in the game bothered to talk.

Most headphones are quite hard to wear after a while, because my ear gets pinched, but the F540 has cups that go all around your ear, not on your ear which is very nice.

The only big problem I had and what for me is kinda of a deal breaker, is that fact that I got loads of interference after a while. Especially when the Xbox was online over the wifi signal, I tried all solutions found on the web, but none really helped, except putting the transmitter at a 45 degrees angle, but that is not very handy when you need somebody to hold the transmitter while you are playing.

So overall, I like the headset a lot, but there are 2 things I didn’t like, one is that I couldn’t use digital audio on it, which is very annoying because our tv only has a headphones and digital out connection and the headphones is never surround and the second one was the interference I got from other devices.