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:
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
- Open http://openhabianpi:8080/start/index
- Install AVM FRITZ! Binding
- Install HomeKit Add-on
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.
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:
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
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
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.
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
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.
- Open the app
- Add new device
- Choose "Code is missing or cannot scan" below
- Here the openHAB instance should be listed
- Select it and type in the code you defined in openHAB's HomeKit add-on configuration.
- Pairing should be successful now.
Reset HomeKit Pairing
- ssh -p 8101 openhab@localhost (not needed with openHABian anymore)
- smarthome:homekit allowUnauthenticated true
- 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.
- Create SSH key: ssh-keygen -t rsa
- Copy public key to the Raspberry Pi: ssh-copy-id openhabian@openhabianpi
- Type in the passphrase so you do not need to type it in again: ssh-add
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
Add Fritz!Box certificate (Update 2020-04-25)
- scp /Users/myuser/Downloads/boxcert.cer openhabian@openhab:./fritz.crt
- sudo find / -name jre
- cd /opt/jdk/zulu8.40.0.178-ca-jdk1.8.0_222-linux_aarch32hf/jre/bin
- sudo ./keytool -importcert -alias fritzbox -keystore /usr/lib/jvm/zulu-8-amd64/jre/lib/security/cacerts -file ./fritz.crt
Then it is possible to configure your Fritz!Box with https: