Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleDockerfile
FROM oznu/homebridge:latest

RUN npm install -g homebridge-nestcd /homebridge
RUN npm install -g --prefix "/var/lib/homebridge" add homebridge-sonoff-tasmota-httpmyq@latest
RUN npm install --g homebridge-sonos
RUN npm install -g homebridge-http-temperatureprefix "/var/lib/homebridge" add homebridge-mqttthing@latest
RUN npm install -g homebridge-mqttthing--prefix "/var/lib/homebridge" add homebridge-plex-sensors@latest
RUN npm install -g homebridge-cmd4
RUN mkdir ~/.homebridge
RUN mkdir ~/.homebridge/Cmd4Scripts
RUN cp /usr/local/lib/node_modules/homebridge-cmd4/Extras/Cmd4Scripts/State.js ~/.homebridge/Cmd4Scripts
RUN chmod 700 ~/.homebridge/Cmd4Scripts/State.js
RUN npm install -g homebridge-http-webhooks
RUN apk add jq

Running our Container

-prefix "/var/lib/homebridge" add homebridge-zp@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-weather-plus@latest
RUN npm --prefix "/var/lib/homebridge" add node-appletv-x@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-nest@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-apple-tv-remote@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-tasmota-zbbridge@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-ikea-tradfri-gateway@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-eufy-security@latest
RUN npm --prefix "/var/lib/homebridge" add homebridge-sonos@latest


Running our Container

Code Block
#!/bin/bash

NAME=homebridge
IMAGE=jmehan/homebridge

DIR=`pwd -P`

docker stop $NAME
docker rm $NAME

Code Block
docker run -d \
--restart=always \
--name homebridge$NAME \
--net host \
-e HOMEBRIDGE_INSECURE=1 \
-e HOMEBRIDGE_CONFIG_UI=1 \
-e HOMEBRIDGE_CONFIG_UI_PORT=8089 \
-p 8089:80898091 \
-p 51826:51826 \
-p 51828:51828 \
-v /share/Volume/CONTAINERS/homebridge/conf$DIR/data:/homebridge \
-v /share/Volume/CONTAINERS/homebridge/plugins:/homebridge/plugins \
jmehan/homebridge$IMAGE


Our Configuration

Code Block
{
    "bridge": {
        "name": "Homebridge",
        "username": "XX:XX:XX:XX:XX:XX",
        "port": 51826,
        "pin": "XXX-XX-XXX"
    },

    "description": "This is an example configuration file",

    "accessories": [
        {
                "accessory": "SonoffTasmotaHTTP",
                "name": "sonoff151",
                "hostname": "192.168.1.151",
                "user": "admin",
                "password": "XXX"
        },
        {
                "accessory": "HttpTemperature",
                "name": "Spa Temperature",
                "url": "http://192.168.1.82/info/",
                "max_temp": 200,
                "http_method": "GET",
                "field_name": "temperature",
                "update_interval": "60000",
                "units": "C"

        },
		{
                "accessory": "Sonos",
                "name": "Katie's Speaker",
                "room": "Katie's Room",
                "mute": false
        },
		{
                "accessory": "mqttthing",
                "type": "lightbulb",
                "name": "teamroom",
                "url": "http://XXXX:1883",
                "topics":
                {
                        "getOn":                "ikea",
                        "setOn":                "ikea"
                },
                "onValue": "on",
                "offValue": "off"
        }


    ],

    "platforms": [
        {
                "platform": "Nest",
                "clientId": "XXX",
                "token":"XXXX",
                "clientSecret": "XXX",
                "code": "XXX"
        },
		{
                "platform": "Cmd4",
                "name": "Cmd4",
                "accessories":
                [
                        {
                        "type": "TemperatureSensor",
                        "name": "sonoff158",
                        "timeout": 3000,
                        "polling": false,
                        "interval": 100,
                        "stateChangeResponseTime": 10,
                        "state_cmd": "sh /homebridge/Cmd4Scripts/sonoff158.sh"
                        }
                ]
        },
        {
                        "platform": "HttpWebHooks",
                        "webhook_port": "51828",
                        "cache_directory": "/homebridge/.node-persist/storage",
                        "sensors": [
                        ]
        }
    ]
}

...

Code Block
languagebash
titlesonoff158.sh
#Humidity

if [ "$1" = "Get" ]; then
   # $2 would be the name 'spa'
   # $3 would be the charactersistic

   if [ "$3" = "CurrentRelativeHumidity" ]; then

        humidity=`curl -v --location-trusted \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer xxx" \
        -X GET "https://developer-api.nest.com/" 2>/dev/null \
        | jq '.devices.thermostats."oFh5M-W1yNJjd1COACDoCrsH5zleG7kM".humidity'`

        echo $humidity
      exit 0
   fi
   if [ "$3" = "StatusActive" ]; then
      echo "1"
      exit 0
   fi

fi

if [ "$1" = "Set" ]; then
  exit 1
fi

exit 0


References