Skip to content

Commit

Permalink
Merge pull request #76 from lnr0626/hassio-addon
Browse files Browse the repository at this point in the history
Hassio addon initial submit
  • Loading branch information
TD22057 authored Sep 9, 2018
2 parents a5aa74b + 24b8883 commit fa3bfff
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ tag = False
search = Version: {current_version}
replace = Version: {new_version}

[bumpversion:file:hassio/config.json]
search = "version": "{current_version}"
replace = "version": "{new_version}"
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG BUILD_FROM
FROM $BUILD_FROM

ENV LANG C.UTF-8
RUN apk --no-cache add python3-dev

COPY . /opt/insteon-mqtt

RUN pip3 install /opt/insteon-mqtt && \
chmod +x /opt/insteon-mqtt/hassio/entrypoint.sh

CMD ["/opt/insteon-mqtt/hassio/entrypoint.sh"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Version: 0.6.2 ([History](HISTORY.md))
Blah, blah, blah, too much reading, how do I use it? [Read the quick
start guide](docs/quick_start.md)

Using hassio? [Read the hass.io quick start guide](docs/hassio_quick_start.md)


# Overview

Expand Down
30 changes: 30 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

DOCKER_REPO=lnr0626

TAG=$(jq -r '.version' ./hassio/config.json)

docker run --rm --privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--all \
-l \
--from "homeassistant/{arch}-base" \
--doc-url "https://github.com/TD22057/insteon-mqtt" \
--name "Insteon MQTT" \
--description "Insteon PLM <--> MQTT Bridge" \
--image ${DOCKER_REPO}/{arch}-insteon-mqtt \
--squash \
--version ${TAG}

docker push ${DOCKER_REPO}/i386-insteon-mqtt
docker push ${DOCKER_REPO}/i386-insteon-mqtt:$TAG
docker push ${DOCKER_REPO}/armhf-insteon-mqtt
docker push ${DOCKER_REPO}/armhf-insteon-mqtt:$TAG
docker push ${DOCKER_REPO}/amd64-insteon-mqtt
docker push ${DOCKER_REPO}/amd64-insteon-mqtt:$TAG
docker push ${DOCKER_REPO}/aarch64-insteon-mqtt:$TAG
docker push ${DOCKER_REPO}/aarch64-insteon-mqtt

92 changes: 92 additions & 0 deletions docs/hassio_quick_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Insteon-MQTT Bridge Quick Start for Hass.io users

## First time installation

This package assumes that you:

- Have a hass.io installation up and running with either SSH access or a
network share.

- Have a working MQTT broker up and running. If not, do that first
([Mosquitto](https://mosquitto.org/) is good choice, and has [an addon for
hass.io](https://www.home-assistant.io/addons/mosquitto/)).

- Have an Insteon PLM modem (serial or USB) or one of the older hubs that
supports a PML port (usually 9761) on a fixed IP address.

- Have hass.io connected to your mqtt broker.

1) Create a directory for insteon-mqtt in your /addons folder:
`mkdir /addons/insteon-mqtt`

2) Copy the `hassio/config.json` file into `/addons/insteon-mqtt/config.json`

3) Install the Local Insteon MQTT addon through the hass.io addon store.
* If you do not see the 'Local Add-ons' repository or the Insteon MQTT
add-on, click the refresh button in the top right corner on the Hass.io
Add-ons page, and it should show up.

4) Start the addon. This will setup the default config files under `/config/insteon-mqtt/config.yaml`.

5) Edit `/config/insteon-mqtt/config.yaml` as appropriate. There is no
automatic device discovery at this time. Insteon devices must already
be linked with the modem as a controller and the device as a responder
(press set on modem first, then the device).

- Set the Insteon port to be the USB port or address of the PLM modem.
- Set the modem Insteon hex address (printed on the back of the modem).
- Edit the Insteon device section and enter the hex addresses of all
the devices you have.
- Edit the storage location. Each device will save it's database in
this directory.
- Edit the MQTT topics and payload section. The sample config.yaml file
is designed for integration with Home Assistant but you can change it
to use whatever style of messages you want.

6) Restart the insteon-mqtt addon to pick up the changes.

7) Download an Insteon device database for every device. This may
take awhile and battery operated devices (motion sensors, remotes,
etc) will fail because they aren't awake. Publish the following command
to `insteon/command/modem`

```
{ "cmd": "refresh_all", "force": false }
```

Once that finishes, you should wake up each battery powered device
(by activating it or pressing the set button - it may depend on the
device) and then quickly send a command to the Insteon hex address
of that device to download the database (hopefully this will be
automatic in the future). Publish the following command to
`insteon/command/aa.bb.cc`

```
{ "cmd": "refresh", "force": false }
```

If you haven't linked the device as a controller of the modem
(press set on the device, then set on the modem), you'll also need
to tell the device to pair with the modem. This step is also
needed for complicated devices like the smoke bridge which require
multiple Insteon groups to be configured.

IMPORTANT: If you do not call pair for each device one time (it only needs
to be done once) means that the correct controller/responder links from
the device to the PLM modem may not exist and the functionality of the
device with the Insteon-MQTT system may not work until pair() is called.

Publish the following command to `insteon/command/aa.bb.cc`
```
{ "cmd": "pair" }
```

Downloading the device database and pairing only needs to be done
one time. The refresh command only needs to be sent again if you
make changes to the Insteon links (scenes) manually without using
the server.

## Updating

To update, replace your `/addons/insteon-mqtt/config.json` with the most
recent `hassio/config.json
13 changes: 13 additions & 0 deletions hassio/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Insteon MQTT",
"description": "Python Insteon PLM <-> MQTT bridge",
"slug": "insteon-mqtt",
"version": "0.6.2",
"startup": "services",
"boot": "auto",
"auto_uart": true,
"map": ["config:rw"],
"options": {},
"schema": {},
"image": "lnr0626/{arch}-insteon-mqtt"
}
12 changes: 12 additions & 0 deletions hassio/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

/bin/mkdir /config/insteon-mqtt/

/bin/cp /opt/insteon-mqtt/config.yaml /config/insteon-mqtt/config.yaml.default

if [ ! -f /config/insteon-mqtt/config.yaml ]; then
echo "Copying default config.yaml"
/bin/cp /opt/insteon-mqtt/config.yaml /config/insteon-mqtt/config.yaml
fi

insteon-mqtt /config/insteon-mqtt/config.yaml start

0 comments on commit fa3bfff

Please sign in to comment.