Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Get started

Kim Diallo edited this page Dec 23, 2018 · 1 revision

Install


We now assume that all requirements are met and we have a shell access to the Raspberry Pi via SSH or local.

Where you store data and how you name your directories or containers is up to you and a matter of style. For the sake of simplicity I stay for this wiki at EXAMPLE and in ~/.


  1. First things first; clone the repository.
git clone https://github.com/kimdiallo/Pidoho.git

  1. Get in there!
cd Pidoho

  1. And build the image. This will take a while, no reason to get nervous.
docker build . 


Setup


Now we need a to create a location for config files which should later be used to run homebridge inside the container. Thanks to dockers --volume, which lets you add any directory as volume to a container, a piece of cake. All we have to do is, to make a dir per container.

And since we are here on docker, we should try to build our services so small and simple as possible, in the end everything is faster, more stable, more effective and less complex. So let's create a bunch of directories for a lot of short and clear configs in many slim containers.

  1. Lets make dirs.
mkdir -p ~/EXAMPLE/container{1..9}

  1. Copy one of the example configs included in the repo.
cp ~/Pidoho/examples/config/config.json.script2.example ~/EXAMPLE/container1/config.json

  1. And also some script foo that can be proceeded.
cp -R ~/Pidoho/examples/scripts ~/EXAMPLE/container1/

  1. Edit the config.json
{
    "bridge": {
        "name": "EXAMPLE_BRIDGE",
        "username": "CC:22:D3:E2:EE:32",
        "port": 51080,
        "pin": "000-00-000"
    },
    "platforms": [ ],
    "accessories": [
        {
              "accessory": "Script2",
              "name": "EXAMPLE",
              "on": "/scripts/EXAMPLE/on.sh 1",
              "off": "/scripts/EXAMPLE/off.sh 1",
              "fileState": "/scripts/EXAMPLE/script.flag"
        },
        {
              "accessory": "Script2",
              "name": "EXAMPLE-Send",
              "on": "/scripts/EXAMPLE-Send/on.sh 1",
              "off": "/scripts/EXAMPLE-Send/off.sh 1",
              "fileState": "/scripts/EXAMPLE-Send/script.flag"
        }
    ]
}

If you do not change this config, it will work once. The in the first "bridge"-part you have to change the name, the port and username obligatory, they have to be unique per HomeApp-Instance.

This EXAMPLE-script will do nothing but provide two switches without function except state.


  1. Ready for the first docker run!
docker run -d --name container1 --restart unless-stopped --network host --device /dev/ttyAMA0:/dev/ttyAMA0 --device /dev/mem:/dev/mem --privileged -v ~/EXAMPLE/container1:/root/.homebridge kimdiallo/homebridge:latest

That means:

  • -d or --detach containers started in detached mode exit when the root process used to run the container exits.
  • --restart unless-stopped Restart the container unless it is explicitly stopped or Docker itself is stopped or restarted. Also restart after reboot.
  • --network host network driver for a container, that container’s network stack is not isolated from the Docker host.
  • --device /dev/ttyAMA0:/dev/ttyAMA0 --device /dev/mem:/dev/mem and --privileged Add a host devices to the container and give the needed privileges to interact with the GPIOs.
  • -vor --volume adds [/any/host/dir:/to/container]
  • --name As the name indicates

  1. Take a look
# docker logs container1
[2018-12-23 06:40:34] Loaded config.json with 2 accessories and 0 platforms.
[2018-12-23 06:40:34] ---
[2018-12-23 06:40:35] Loaded plugin: homebridge-broadlink-rm
[2018-12-23 06:40:35] Registering platform 'homebridge-broadlink-rm.BroadlinkRM'
[2018-12-23 06:40:35] ---
[2018-12-23 06:40:36] Loaded plugin: homebridge-dht
[2018-12-23 06:40:36] Registering accessory 'homebridge-dht.Dht'
[2018-12-23 06:40:36] ---
[2018-12-23 06:40:36] Loaded plugin: homebridge-gpio-device
homebridge-gpio-device API version: 2.2
[2018-12-23 06:40:36] Registering accessory 'homebridge-gpio-device.GPIODevice'
[2018-12-23 06:40:36] ---
[2018-12-23 06:40:37] Loaded plugin: homebridge-platform-maxcube
[2018-12-23 06:40:37] Registering platform 'homebridge-platform-maxcube.MaxCubePlatform'
[2018-12-23 06:40:37] ---
[2018-12-23 06:40:37] Loaded plugin: homebridge-script2
[2018-12-23 06:40:37] Registering accessory 'homebridge-script2.Script2'
[2018-12-23 06:40:37] ---
[2018-12-23 06:40:37] Loading 0 platforms...
[2018-12-23 06:40:37] Loading 2 accessories...
[2018-12-23 06:40:37] [EXAMPLE] Initializing Script2 accessory...
[2018-12-23 06:40:37] [EXAMPLE-Send] Initializing Script2 accessory...
Setup Payload:
X-HM://0023GXK3KF0EP
Scan this code with your HomeKit app on your iOS device to pair with Homebridge:
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
                                                      
Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 000-00-000 │     
    └────────────┘     
                       
(node:21) [DEP0025] DeprecationWarning: sys is deprecated. Use util instead.
[2018-12-23 06:40:38] Homebridge is running on port 51080.
HypriotOS/armv7: test@flur in ~/EXAMPLE/container1/EXAMPLE
# 

  1. Just scan the QR code with your iPhone or iPad to add the all accessory from bridge to HomeKit.
Clone this wiki locally