Skip to main content

How to integrate AVM smart devices into HomeKit by using openHAB

After some evaluating openHAB (Vers. 2.2.0) on my NAS I wanted to do it right and started with this (German) article to use openHABian together with a Raspberry Pi.My primary goal was to integrate my AVM smart home devices to control them with HomeKit.

To get started I used the following items:
  • Raspberry PI
  • SD Card 16 GB
And the following software (I used a Mac, so you might need to replace some tools if you use another OS):
  • Download the latest openHABian image here. This is a dedicated linux distribution to provide an openHAB server.
  • Download SD Formatter here. Needed to format your SD card.
  • Download Etcher here. Needed to install the openHABian image on the SD card.

Installation openHABian

  • Insert the SD card
  • Connect the Raspberry Pi via LAN with your network
  • Plugin the Raspberry Pi
  • Wait about 45 minutes until all updates were installed
  • When everything went well you should be able to connect to http://openhabianpi:8080
  • Connect via ssh: ssh openhabian@openhabianpi (standard password: openhabian)
  • Open the config: sudo openhabian-config
  • Run 01 "Update"
  • Run 02 "Upgrade System"

Configuration openHAB

Configure AVM Things

First of all you need to connect the Fritz!Box, therefore you should get a notification in the inbox in PAPER UI:
You just need a Fritz!Box user. I created a dedicated one which only has the permission "Smart Home". HTTPS is only available when you MyFRITZ! Service for remote access. When the Fritz!Box is connected all other connected smart devices become visible:

Configure HomeKit Add-on

You can keep all the defaults, but you need to add the IP for the interface. In my case this is just the same IP as the Raspberry Pi has, my PI just has one network interface.

If you do not add the IP here your device will be listed in the Home app but paring will always fail, as described here.

Create HomeKit Items

To use your items with HomeKit you need to create so called "accessories" as described here. As follows a little sample:

Switch HK_Livingroom_Light "Light Livingroom" <light> (gLightLivingroom) [ "Lighting" ] { channel ="avmfritz:FRITZ_DECT_200:10_51_2_165:667777888999:outlet" }

Number HK_Livingroom_Temperatur "Temperature Livingroom" (gTemperatureLivingroom) [ "CurrentTemperature" ] { channel ="avmfritz:FRITZ_DECT_200:10_51_2_165:667777888999:temperature" }

To copy the items I use the following command:
scp /Users/philipp/Desktop/HK.items openhabian@openhabianpi:/etc/openhab2/items/HK.items

Start openHAB service manually

Type in the following command to start the service manually:

sudo systemctl start openhab2

Start openHAB within terminal session

1. openhab-cli stop
2. openhab-cli clean-cache
3. openhab-cli start

This will start the service and also the Karaf console. When you close your SSH session the service will also go down.

To just open the Karaf console for your existing instance use:
openhab-cli console

Start openHAB service automatically after reboot

sudo systemctl enable openhab2
sudo shutdown -r now
sudo systemctl status openhab2

Use the script above to enable automatic start after reboot and to test it.

Permission Fix

For some reason the permission was messed up and I had to fix it with sudo openhabian-config. 

Trace & Debug issues

To trace issues with the HomeKit integration I enabled trace for it by submitting this command within the Karaf console:

log:set TRACE com.beowulfe.hap

To change it back I used

log:set DEFAULT com.beowulfe.hap

HomeKit Pairing

I paired my openHAB with the iOS Home app.
  1. Open the app 
  2. Add new device
  3. Choose "Code is missing or cannot scan" below
  4. Here the openHAB instance should be listed
  5. Select it and type in the code you defined in openHAB's HomeKit add-on configuration.
  6. Pairing should be successful now.

Reset HomeKit Pairing

  1. ssh -p 8101 openhab@localhost (not needed with openHABian anymore)
  2. smarthome:homekit allowUnauthenticated true
  3. smarthome:homekit clearPairings

Add SSH Key

To create and upload my SSH key I used a Mac. So you might need to adapt your script to do it with another operation system.
  1. Create SSH key: ssh-keygen -t rsa
  2. Copy public key to the Raspberry Pi: ssh-copy-id openhabian@openhabianpi
  3. Type in the passphrase so you do not need to type it in again: ssh-add
On a Mac you can create a bookmark. Therefore you need the following commands:

1. To create the needed config file: nano ~/.ssh/config
2. To create the bookmark you need the following lines:

Host openhab
User openhabian
Port 22
HostName openhabianpi
IdentityFile ~/.ssh/id_rsa

3. with ctrl + x you leave nano and you will be asked to save the file
4. Then you can open the terminal with ssh openhab without typing in a password
5. With passwd I changed my password for the user openhabian to get rid of the default password


Popular posts from this blog

How to delete Azure Active-Directories

When I was trying to delete an Azure Active-irectory by using the management portal I have received the error message “Directory contains one or more applications that were added by a user or administrator” and I was really confused.

Then I found out this is a common issue. The solution was even more confusing, some PowerShell cmdlets are needed. Unfortunately I was not able to proceed, it was not possible to login with my Microsoft-ID to execute the needed commands.

Here I found out I have to install the correct version of the tools. These are located here.

Did you ever think about two-step verification to increase your password security?

My feeling is that two-step verification is still not very common, although a lot of services are listing this feature. Here you will find them:
Facebook Google Microsoft Twitter Evernote Dropbox Apple (currently just available in U.S., UK, Australia, Ireland, and New Zealand) Helpful apps are e.g. Google Authenticator or Authy.
Updated my list on 27.02.2014 with some more services Buffer Yahoo! Apple added, Canada, France, Germany, Italy, Japan, Spain Updated my list on 10.03.2014 with one more Hootsuite Updated my list on 26.03.2014 tumblr Updated my list on 02.04.2014 APP.NET LinkedIn

Have you ever reconsidered your personal iPhone security policy?

Why should I reconsider my iPhone security policy? I have my iPhone four digit pass code and Find my iPhone feature feature is activated. So how should abuse be possible? What could a thief be doing with my stolen iPhone? Well, possibly quite a lot. At least the bold print bullets in this article should be mandatory for everyone. Of course this is no guarantee for invulnerability but it will improve your security. After watching this video you should consider the following actions:
Change your Apple ID rescue mail address and do not add this mail account to your iPhone.Consider to use a proper and usable password policy for your Apple ID like this or this (German article).Consider a complex pass code for your iPhone. As you can see in the video four digit pass codes can be hacked in no time on iPhone 4. For newer iPhone a leak is not yet known but it is properly there. Definitely do not use these pass codes.Alternative to point three: activate delete iPhone after 10 wrong attempts (Go …