In this tutorial we will see how to install and configure the Homebridge gateway to Homekit (the Apple Home Automation Framework) with the home automation software Jeedom. The installation and configuration of the iOS application (iPhone or iPad) is identical to what we already have for Domoticz. I have a little less detailed this part than in the previous tutorial because it is identical, for more detail read the previous article.
Configuration used
For this tutorial, I used a Jeedom box based on a Raspberry Pi 3. In this tutorial we will simply use a temperature probe developed in a few clicks using the ESP Easy framework and an ESP8266 (to stay in The DIY spirit). The method will remain the same whatever your installation and home automation accessories.
Here is a typical configuration.
Raspberry Pi 3 | |
HDMI adapter | |
Raspberry Pi 3 case | |
SD board8 Go SDHC Classe 10 | |
5V – 2.5A power supply |
That is a budget of about €65.
Is it possible to install Homebridge on another workstation?
Yes, it is quite possible to install Homebridge on a NAS for example. You can follow this Home and Domotics tutorial. In gait you can install the gateway on any system that can run Nodejs (ie almost all!). The communication with the home automation box is done via HTTP requests it will suffice to point to the IP address of the box Jeedom. It is not necessarily the best solution however because you go to multiply the machines, the maintenance and the risks of cut of service. By installing Homebridge on Jeedom’s Raspberry Pi and cloning the SD board regularly, you’ll have a more robust system.
Installed Software Versions
Raspbian Jessie Lite
# uname -a Linux jeedom 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
Jeedom version 2.4.6 installed from the Netinstall image (installation guide on Raspberry Pi 3).
IPhone 6S on iOS 10.2
Homebridge Plugin for Jeedom
There is a paid plugin for Jeedom that installs the gateway. The latter is charged (€4). It is necessary to run the application Jeedom mobile for iOS (which is free). Unlike the eDomoticz plugin that deals with discovering and publishing all home automation devices, it is up to the user to choose what he wants to share with his iPhone or iPad. It is at the same time an advantage, one does not pollute his House with unnecessary devices, and one inconvenience, it is necessary to configure everything by the hand. The configuration can be tedious and it will be necessary to think about adding each new device to make it visible from Home.
For this tutorial, I prefer to opt for the installation of the plugin manually to stay in the mind of a box home automation 100% DIY (and budget).
Install Homebridge on Raspbian
Homebridge is a Nodejs project (written in javascript). If you have installed Jeedom from the Netinstall image, you do not need to install Nodesjs and npm (the Nodejs package manager). To verify this, run the following command that will give you the installed version.
# node -v v5.12.0
If Nodejs is not present, do not install it manually. Indeed, Nodejs is used by many Jeedom plugins. Install the ESP Easy or Mysensors plugin (for example) and their dependencies. The correct version will be installed automatically.
We will therefore be able to go directly to the installation of the necessary packages. The –unsafe-perm option overrides any compile errors and warnings. The plugin page can be found here.
sudo npm install -g homebridge --unsafe-perm sudo npm install -g homebridge-http-jeedom --unsafe-perm sudo apt-get install libavahi-compat-libdnssd-dev
This is the minimum configuration to create a Homebridge bridge with Jeedom. We can add other plugins but we leave the objective of the article.
Let’s now create a directory dedicated to Homebridge
mkdir ~/.homebridge
Then open the configuration file in a text editor (pico or nano).
sudo nano ~/.homebridge/config.json
At first we will configure the bridge to make it detectable by iOS. Although this does not seem to be mandatory, I prefer to know the Raspberry Pi’s MAC address. By doing this, iOS immediately discovers the Homebridge Bridge. Execute ifconfig and note the MAC address that corresponds to the connection mode (eth0 in Ethernet, and wlan0 in Wi-Fi).
Paste this type configuration and adapt it to your case.
{ "bridge": { "name": "Jeedom Bridge", "username": "31:AB:CD:B6:16:42", "port": 51826, "pin": "031-45-156" }, "description": "Homebridge platform", "platforms": [ ], "accessories": [] }
Some explanations :
- Name: This is the name that will be displayed on iOS
- Username: the Mac address of the Raspberry Pi. Warning, put in capital letters otherwise Homebridge crash!
- Port: do not change anything
- Pin: you can put what you want provided you respect the format XXX-XX-XXX
The bridge configuration is complete.
Add an accessory to the configuration
For Jeedom, it will be necessary to add an accessory in the accessories table for each orders of the equipment with which one wishes to interact or to visualize the value on iPhone or iPad. It’s quite tedious to do for a lot of control, but at least you can really choose what’s important. House is not meant to replace the smart home box Jeedom (well hope…).
Recover the API key
Before anything else go into the configuration
Note the API key of your Jeedom box.
Retrieve the identifier of a Jeedom object
Open the desired equipment and go to the Commands tab. On the line of the command that you want to integrate to House, press the gear (expert mode required).
Locate the internal ID (ID).
As well as the Logical ID
For each accessory, we will add a parameter block (in JSON format) made up as follows:
{ "accessory": "HttpJeedom", "jeedom_url": "https://jeedom.domain.com/jeedom", "jeedom_api": "xxxxxx", "service": "TemperatureService", "name": "Living Room Temperature", "temperatureCommandID": "ID" }
Explanations:
- Accessory: leave HttpJeedom. This is the reference to the plugin
- Jeedom_url: if the bridge is installed on the same Raspberry as Jeedom, you can enter http://127.0.0.1, otherwise specify the domain name or IP address of the Jeedom box
- Jeedom_api: the previously recovered API key
- Service: there is no particular specification. The best is to give the name of the order followed by Service
- Name: give an explicit name, rather short. The accented characters are supported and displayed correctly on the iPhone screen. Do not locate the command (living room, kitchen) to find you more easily on iOS. Once added, it is best to rename the command and assign a part in House. Speech recognition from Siri will be more effective.
- XxxCommandID: attention is important for the order to be published. It must be of the form logicalIDjeedomCommandID (logical ID)
- ID: The identifier of the previously retrieved command
This gives, for example, the temperature and the humidity returned by the DHT22 probe
{ "accessory": "HttpJeedom", "jeedom_url": "http://127.0.0.1", "jeedom_api": "mVuQikcXm69l2mDMYZiCsLxxxxxxxxxxxxxxxxxxxxxxxxxx", "service": "TemperatureService", "name": "Température Salon", "temperatureCommandID": "47" }, { "accessory": "HttpJeedom", "jeedom_url": "http://127.0.0.1", "jeedom_api": "mVuQikcXm69l2mDMYZiCsLxxxxxxxxxxxxxxxxxxxxxxxxxx", "service": "HumidityService", "name": "Humiditée Salon", "humidityCommandID": "48" }
As you can see, each accessory block {} must be separated by a comma except the last block.
If you have doubts about your configuration file (which may happen with a lot of accessories), you can test it online here.
Caution: Do not use tabs (only spaces) to create a tree to your configuration. An error in the configuration file will cause Homebridge to crash (which is normal in the end).
This gives the next assembled configuration file
{ "bridge": { "name": "Jeedom Bridge", "username": "31:AB:CD:B6:16:42", "port": 51826, "pin": "031-45-156" }, "description": "Homebridge platform", "platforms": [], "accessories": [{ "accessory": "HttpJeedom", "jeedom_url": "http://127.0.0.1", "jeedom_api": "mVuQikcXm69l2mDMYZiCsLXXXXXXXXXXXXXXXXXXXXXXXXXX", "service": "TemperatureService", "name": "Température Salon", "temperatureCommandID": "47" }, { "accessory": "HttpJeedom", "jeedom_url": "http://127.0.0.1", "jeedom_api": "mVuQikcXm69l2mDMYZiCsLXXXXXXXXXXXXXXXXXXXXXXXXXX", "service": "HumidityService", "name": "Humiditée Salon", "humidityCommandID": "48" }] }
It only remains to save it CTRL + X then Y and finally start the bridge with the command
homebridge
Both accessories were found correctly. The identification PIN in House is displayed on the screen. We will also see scrolling through the Terminal all the calls between iOS and Jeedom, practice to test if everything works.
Homekit Setup, Home app on iOS
This is the time to see what it gives on iPhone or iPad. Launch the Home App
Your iPhone (or iPad) must be connected to the Wi-Fi LAN to add a bridge and accessories. Click Add accessory.
If everything is configured correctly, you must have an accessory named Jeedom Bridge that appears. Select it.
Manually enter (or try your luck with optical recognition) the Pin code displayed on the Terminal.
The bridge was successfully added.
We will now proceed to the addition of accessories (orders of equipment Jeedom). The accessories appear one after the other, it may be long the first time. Enjoy it to rename it (remove the location in the title) and assign a location. In this way, the voice command with Siri will be more efficient.
Same for temperature
That’s it, it’s over, you can enjoy your Jeedom equipment from your iPhone. If you have an iPad or Apple TV (quite recent), you can even continue to communicate with Jeedom out of your home (if you have a 3G or 4G connection obviously).
- Weather station with ePaper display (Dashboard) for Jeedom on Raspberry Pi (via the JSON RPC API)
- Install Jeedom v3 from the installation script on Raspberry Pi 3 (or Linux Debian 8 PC)
- Driving the ESP8266 GPIO (Web Server) from Jeedom to TCP / IP Wireless – Part 2
- ESP8266 (Web Client): Sending Data to Jeedom in TCP / IP Wireless (JSON API) – Part 1
- Install Jeedom on an Orange Pi Lite (or Orange Pi+ 2e) running under Armbian Jessie
- Jeedom + MQTT: associate a connected object DIY with the Dashboard