Control your home with your voice (Siri and FHEM)

Since iOS 7 was launched, Siri-Proxy was not working anymore and so there was no chance to use Siri commands for home automation. Now, with iOS 8.1 Apple introduces „HOMEKIT“ – it’s a mix of a database and an API.

In this Tutorial i will show you, how to setup your own Homekit-Server called „HOMEBRIDGE“ that makes it possible again to use Siri for switching on/off lights or everything else.

The official setup article in the fhem wiki seems outdated for me.
Here is mine …

I am using a Wheezy box – but this is working on Jessie and Ubuntu 12.04 / 14.04 too

First of all we have to install nodejs from there repo

# echo „deb https://deb.nodesource.com/node_5.x wheezy main“ > /etc/apt/sources.list.d/nodejs.list
# echo „deb-src https://deb.nodesource.com/node_5.x wheezy main“ >> /etc/apt/sources.list.d/nodejs.list
# apt-get update

You have to PIN the newly created repo or explicitly give apt the version when you install nodejs

For example

root@homenas.mytso.net:~# apt-cache policy nodejs
nodejs:
Installiert: 5.1.0-2nodesource1~wheezy1
Installationskandidat: 5.1.1-1nodesource1~wheezy1
Versionstabelle:
5.1.1-1nodesource1~wheezy1 0
995 https://deb.nodesource.com/node_5.x/ wheezy/main amd64 Packages
*** 5.1.0-2nodesource1~wheezy1 0
100 /var/lib/dpkg/status
0.10.29~dfsg-1~bpo70+1 0
999 http://ftp.debian.org/debian/ wheezy-backports/main amd64 Packages

What does it mean?

It means when you do „apt-get install nodejs“ version 0.10.29 will be installed – but we want to install the 5.x release

# apt-get install nodejs=5.1.0-2nodesource1~wheezy1 libavahi-compat-libdnssd-dev

Now that the dependencies and nodejs are installed, we need to install the homebridge server and the homebridge-fhem plugin.

# npm install -g homebridge homebridge-fhem

Change the global userattr line inside FHEM (fhem.cfg)

attr global userattr devStateIcon devStateStyle fm_type icon room_map sortby structexclude webCmd widgetOverride genericDeviceType:ignore,switch,outlet,light,blind,speaker,thermostat,lock,window,contact

Don’t overwrite the line, append the marked text at the end!!!!!

Now it is time to combine homebridge with fhem by creating a configuration file

# nano ~/.homebridge/config.json

{
„bridge“: {
„name“: „HOMEBRIDGE“,
„username“: „CC:22:3D:E3:CE:30“,
„port“: 51826,
„pin“: „123-45-678“
},

„description“: „This is an example configuration file with all supported devices. You can use this as a template for creating your own configuration file containing devices you actually own.“,

„platforms“: [
{
„platform“: „FHEM“,
„name“: „FHEM“,
„server“: „127.0.0.1“,
„port“: „8083“,
„auth“: {„user“: „admin“, „pass“: „1234“}
}
],
„accessories“: []
}

It’s time to create a startup script

# nano /etc/init.d/homebridge

#!/bin/sh
### BEGIN INIT INFO
# Provides: homebridge
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time for homebridge
# Description: Enable service provided by daemon.
### END INIT INFO
export PATH=$PATH:/usr/bin
export NODE_PATH=$NODE_PATH:/usr/lib/node_modules
PID=`pidof homebridge`
case „$1“ in
start)
if ps -p $PID > /dev/null 2>&1; then
echo „Homebridge is already running“
else
/usr/bin/homebridge > /dev/null 2>&1 &
echo „Homebridge starting“
fi
;;
stop)
if ! ps -p $PID > /dev/null 2>&1; then
echo „Homebridge is not running“
else
kill $PID
echo „Homebridge closed“
fi
;;
restart)
if ! ps -p $PID > /dev/null 2>&1; then
$0 start
else
$0 stop
$0 start
fi
;;
status)
if ps -p $PID > /dev/null 2>&1; then
echo „Homebridge is running PID $PID“
else
echo „Homebridge is not running“
fi
;;
*)
echo „Usage: $0 {start|stop|status|restart}“
exit 1
;;
esac
exit 0

# chmod +x /etc/init.d/homebridge
# update-rc.d homebridge defaults
# /etc/init.d/homebridge start

Now install the Elgato Eve app on your iDevice. If homebridge is running correctly, the accessories defined there should be visible in the Eve app. The default pin code for all HomeBridge accessories is 12345678. If you have to delete some devices, you will manually have to remove the corresponding file in ~/homebridge/persist. To figure out which file to remove, have a look at the debug http server http://yourip:8080/persist.

Now you can finally order Siri to turn on the TV light. Here is a list of possible commands from Apple’s website

„Turn on the lights“ or „Turn off the lights.“
„Dim the lights“ or „Set the brightness to 50%.“
„Set the temperature to 68 degrees.“
„Turn on the coffee maker.“

If you set up homes, zones, rooms, or scenes, you can use also commands like this:

„Turn on the upstairs lights.“
„Turn off Chloe’s light.“
„Turn down the kitchen lights“
„Dim the lights in the dining room to 50%.“
„Make the living room lights the brightest.“
„Set the Tahoe house to 72 degrees.“
„Set the thermostat downstairs to 70.“
„Turn on the printer in the office.“
„Set up for a party, Siri.“
„Set the dinner scene.“
„Set my bedtime scene.“

Or their German counterparts:

„Schalte das Licht ein.“ oder „Schalte das Licht aus.“
„Dimme das Licht.“ oder „Dimme das Licht auf 50 %.“
„Stelle die Temperatur auf 20 °C ein.“
„Schalte die Kaffeemaschine ein.“

Mit Befehlen wie den folgenden können Sie Einstellungen für Wohnbereiche, Zimmer oder Umgebungen zusammenfassen:

„Schalte alle Lampen im Obergeschoss ein.“
„Schalte Chloes Licht aus.“
„Dimme das Licht in der Küche.“
„Dimme das Licht im Esszimmer auf 50 %.“
„Stelle das Licht in der Küche am hellsten ein.“
„Stelle die Temperatur im Tahoe-Haus auf 22 °C ein.“
„Stelle das Thermostat im Erdgeschoss auf 21 °C ein.
„Schalte den Drucker im Büro ein.“
„Siri, bereite alles für eine Party vor.“
„Bereite das Ambiente fürs Abendessen vor.“
„Aktiviere den Nachtruhemodus.“

HINT!

If you plan to control your Home from outside your LAN (WAN, 3G, LTE or other Networks), you need at least an old AppleTV 3 at home – login with your iCloud ID and the AppleTV will work as a bridge.

Posted by:

PeakSpray

Leave A Comment

Your email address will not be published. Required fields are marked (required):

Bitte rechnen Sie folgendes aus: *

Back to Top