Skip to content

Commit

Permalink
Merge pull request #36 from danielwelch/0.1
Browse files Browse the repository at this point in the history
0.1
  • Loading branch information
danielwelch authored Jul 16, 2018
2 parents faf5ed1 + 5b32d74 commit c0bdc19
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 43 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Add-on for running [zigbee2mqtt](https://github.com/Koenkk/zigbee2mqtt) in [Hass

- Add the [repository URL](https://github.com/danielwelch/hassio-zigbee2mqtt) in your **Hass.io > Add-on Store**

The addon should now be available for installation.
The repository includes two add-ons: zigbee2mqtt and zigbee2mqtt-edge. For a stable release that tracks the released versions of zigbee2mqtt, install zigbee2mqtt. zigbee2mqtt-edge tracks the master branch of zigbee2mqtt, so you can install the edge version if there are features or fixes in the master branch not yet released.

### Configuration

Expand All @@ -26,7 +26,6 @@ To configure this add-on, you must set the following parameters via the Hass.io
|`mqtt_pass`|string|no|Your MQTT Password, if set.|
|`debug`|bool|no|Set to true to enable debug mode for zigbee-shepherd and zigbee2mqtt. See [the wiki](https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-debug) for more information.|
|`err`|bool|no|Set to true to redirect zigbee2mqtt `stdout` to `out.log` and `stderr` to `err.log`. Both `out.log` and `err.log` will be located within `data_path` above.|
|`commit`|string|no|Set this to a specific `zigbee2mqtt` commit SHA hash to use a specific version of `zigbee2mqtt` (in case of regressions)|

Notes:
- Depending on your configuration, the MQTT server URL will need to include the port, typically `1883` or `8883` for SSL communications. For example, `mqtt://homeassistant:1883`.
Expand Down Expand Up @@ -126,9 +125,9 @@ Notes:

### Updating the Add-on and `zigbee2mqtt` Library

Currently, `zigbee2mqtt` is adding new features and functionality quite quickly, and is not using versioned releases. This makes it difficult to increment versioning for this add-on, as we simply pull the latest master branch when building the Docker image. Until `zigbee2mqtt` stabilizes, we will likely not use versioned releases. Therefore, in order to update the add-on and to update `zigbee2mqtt`, you must uninstall and reinstall the add-on via the Hassio UI.
The stable, versioned zigbee2mqtt can be updated using the standard Hass.io update functionality within the user interface. This add-on will be updated with bug fixes and as the underlying `zigbee2mqtt` library is updated.

Note: If you have reinstalled the add-on and believe that the latest version has not been installed, try removing the repository before reinstalling.
To update the edge version of the add-on, you will need to uninstall and re-install the add-on. If you have reinstalled the add-on and believe that the latest version has not been installed, try removing the repository before reinstalling.

### Issues

Expand Down
51 changes: 42 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
#!/bin/bash
set -ev
if [ -z ${TRAVIS_TAG} ]; then
echo "Untagged build found."

cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/run.sh "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/run.sh
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/set_config.py "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/set_config.py

if [ -z "${TRAVIS_TAG}" ]; then
echo "Untagged build found. Building zigbee2mqtt with tag 'test' and zigbee2mqtt with tag 'test'."
# build zigbee2mqtt
docker run -it --rm --privileged --name "${ADDON_NAME}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME}" \
--tag-test \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel
# build zigbee2mqtt-edge
docker run -it --rm --privileged --name "${ADDON_NAME_EDGE}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME_EDGE}" \
--tag-test \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel
else
echo "New git tagged build found."
fi
docker run -it --rm --privileged --name ${ADDON_NAME} \
echo "New git tagged build found. Building zigbee2mqtt with tag 'latest'."
docker run -it --rm --privileged --name "${ADDON_NAME}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target ${ADDON_NAME} \
--git \
--target "${ADDON_NAME}" \
--tag-latest \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login ${DOCKER_USERNAME} \
--password ${DOCKER_PASSWORD}
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel
fi
echo "Local Docker build successful."
73 changes: 51 additions & 22 deletions distribute.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
#!/bin/bash
set -ev

cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/run.sh "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/run.sh
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/set_config.py "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/set_config.py

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "This build is a pull request, aborting distribution script."
exit 0
fi

if [ ! -z "$TRAVIS_TAG" ]; then
echo "Tagged build found. Pushing to Docker with tag 'latest'."
echo "Tagged build found. Pushing zigbee2mqtt image to Docker with tag 'latest'."

docker run -it --rm --privileged --name "${ADDON_NAME}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME}" \
--tag-latest \
--push \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel
else
# DIFF="$(git diff HEAD^ HEAD dropbox-sync)"
# if [ -z $DIFF ]; then
# echo "No changes in Dropbox Sync add-on. Skipping docker push."
# exit 0
# fi
echo "No tag found. Pushing to Docker with tag 'test'."
fi
echo "No tag found. Pushing zigbee2mqtt and zigbee2mqtt-edge images to Docker with tag 'test'."

git status
# distribute zigbee2mqtt with tag test
docker run -it --rm --privileged --name "${ADDON_NAME}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME}" \
--tag-latest \
--push \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel

docker run -it --rm --privileged --name "${ADDON_NAME}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME}" \
--git \
--all \
--push \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}"
# distribute zigbee2mqtt-edge with tag test
docker run -it --rm --privileged --name "${ADDON_NAME_EDGE}" \
-v ~/.docker:/root/.docker \
-v "$(pwd)":/docker \
hassioaddons/build-env:latest \
--target "${ADDON_NAME_EDGE}" \
--tag-latest \
--push \
--all \
--from "homeassistant/{arch}-base" \
--author "Daniel Welch <[email protected]>" \
--doc-url "${GITHUB_URL}" \
--login "${DOCKER_USERNAME}" \
--password "${DOCKER_PASSWORD}" \
--parallel
fi
22 changes: 22 additions & 0 deletions zigbee2mqtt-edge/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG BUILD_FROM
FROM $BUILD_FROM

# Add env
ENV LANG C.UTF-8

RUN apk add --update --no-cache jq nodejs nodejs-npm python3 python3-dev \
python2 make gcc g++ linux-headers udev git && \
pip3 install PyYAML==3.12 && \
git clone -b '0.1.0' --single-branch --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /app

COPY run.sh /app/run.sh
COPY set_config.py /app/set_config.py

WORKDIR /app

RUN ["chmod", "a+x", "/app/run.sh"]
RUN ["npm", "install", "--unsafe-perm", "-g", "pm2"]
RUN ["npm", "install", "--unsafe-perm"]
RUN apk del make gcc g++ python2 linux-headers udev

CMD [ "/app/run.sh" ]
32 changes: 32 additions & 0 deletions zigbee2mqtt-edge/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "zigbee2mqtt-edge",
"version": "test",
"slug": "zigbee2mqtt-edge",
"description": "Development build of the zigbee2mqtt add-on.",
"auto_uart": true,
"url": "https://github.com/danielwelch/hassio-zigbee2mqtt",
"startup": "before",
"boot": "auto",
"map": ["share:rw"],
"options": {
"data_path": "/share/zigbee2mqtt",
"homeassistant": true,
"permit_join": false,
"mqtt_base_topic": "zigbee2mqtt",
"mqtt_server": "mqtt://homeassistant",
"serial_port": "/dev/ttyACM0"
},
"schema": {
"data_path": "str",
"homeassistant": "bool",
"permit_join": "bool",
"mqtt_base_topic": "str",
"mqtt_server": "str",
"serial_port": "str",
"mqtt_user": "str?",
"mqtt_pass": "str?",
"debug": "bool?",
"err": "bool?"
},
"image": "dwelch2101/zigbee2mqtt-edge-{arch}"
}
2 changes: 1 addition & 1 deletion zigbee2mqtt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV LANG C.UTF-8
RUN apk add --update --no-cache jq nodejs nodejs-npm python3 python3-dev \
python2 make gcc g++ linux-headers udev git && \
pip3 install PyYAML && \
git clone -b master --single-branch https://github.com/Koenkk/zigbee2mqtt.git /app
git clone -b master --single-branch --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /app

COPY run.sh /app/run.sh
COPY set_config.py /app/set_config.py
Expand Down
5 changes: 2 additions & 3 deletions zigbee2mqtt/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zigbee2mqtt",
"version": "test",
"version": "0.1.0",
"slug": "zigbee2mqtt",
"description": "Zigbee to MQTT Bridge",
"auto_uart": true,
Expand All @@ -26,8 +26,7 @@
"mqtt_user": "str?",
"mqtt_pass": "str?",
"debug": "bool?",
"err": "bool?",
"commit": "str?"
"err": "bool?"
},
"image": "dwelch2101/zigbee2mqtt-{arch}"
}
4 changes: 0 additions & 4 deletions zigbee2mqtt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ CONFIG_PATH=/data/options.json
DATA_PATH=$(jq --raw-output ".data_path" $CONFIG_PATH)
DEBUG_ZIGBEE2MQTT=$(jq --raw-output ".debug // empty" $CONFIG_PATH)
ERR_LOG=$(jq --raw-output ".err // empty" $CONFIG_PATH)
SHA=$(jq --raw-output ".commit // empty" $CONFIG_PATH)

python3 set_config.py "$CONFIG_PATH" "$DATA_PATH"

if [[ ! -z "$DEBUG_ZIGBEE2MQTT" ]]; then
export DEBUG=*
fi

if [[ ! -z "$SHA" ]]; then
git reset --hard "$SHA"
fi

if [[ ! -z "$ERR_LOG" ]]; then
ZIGBEE2MQTT_DATA="$DATA_PATH" npm start 1> "$DATA_PATH"/out.log 2> "$DATA_PATH"/err.log
Expand Down

0 comments on commit c0bdc19

Please sign in to comment.