Skip to content

Commit c0bdc19

Browse files
authored
Merge pull request #36 from danielwelch/0.1
0.1
2 parents faf5ed1 + 5b32d74 commit c0bdc19

File tree

8 files changed

+153
-43
lines changed

8 files changed

+153
-43
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Add-on for running [zigbee2mqtt](https://github.com/Koenkk/zigbee2mqtt) in [Hass
88

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

11-
The addon should now be available for installation.
11+
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.
1212

1313
### Configuration
1414

@@ -26,7 +26,6 @@ To configure this add-on, you must set the following parameters via the Hass.io
2626
|`mqtt_pass`|string|no|Your MQTT Password, if set.|
2727
|`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.|
2828
|`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.|
29-
|`commit`|string|no|Set this to a specific `zigbee2mqtt` commit SHA hash to use a specific version of `zigbee2mqtt` (in case of regressions)|
3029

3130
Notes:
3231
- 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`.
@@ -126,9 +125,9 @@ Notes:
126125

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

129-
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.
128+
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.
130129

131-
Note: If you have reinstalled the add-on and believe that the latest version has not been installed, try removing the repository before reinstalling.
130+
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.
132131

133132
### Issues
134133

build.sh

+42-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,53 @@
11
#!/bin/bash
22
set -ev
3-
if [ -z ${TRAVIS_TAG} ]; then
4-
echo "Untagged build found."
3+
4+
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/run.sh "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/run.sh
5+
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/set_config.py "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/set_config.py
6+
7+
if [ -z "${TRAVIS_TAG}" ]; then
8+
echo "Untagged build found. Building zigbee2mqtt with tag 'test' and zigbee2mqtt with tag 'test'."
9+
# build zigbee2mqtt
10+
docker run -it --rm --privileged --name "${ADDON_NAME}" \
11+
-v ~/.docker:/root/.docker \
12+
-v "$(pwd)":/docker \
13+
hassioaddons/build-env:latest \
14+
--target "${ADDON_NAME}" \
15+
--tag-test \
16+
--all \
17+
--from "homeassistant/{arch}-base" \
18+
--author "Daniel Welch <[email protected]>" \
19+
--doc-url "${GITHUB_URL}" \
20+
--login "${DOCKER_USERNAME}" \
21+
--password "${DOCKER_PASSWORD}" \
22+
--parallel
23+
# build zigbee2mqtt-edge
24+
docker run -it --rm --privileged --name "${ADDON_NAME_EDGE}" \
25+
-v ~/.docker:/root/.docker \
26+
-v "$(pwd)":/docker \
27+
hassioaddons/build-env:latest \
28+
--target "${ADDON_NAME_EDGE}" \
29+
--tag-test \
30+
--all \
31+
--from "homeassistant/{arch}-base" \
32+
--author "Daniel Welch <[email protected]>" \
33+
--doc-url "${GITHUB_URL}" \
34+
--login "${DOCKER_USERNAME}" \
35+
--password "${DOCKER_PASSWORD}" \
36+
--parallel
537
else
6-
echo "New git tagged build found."
7-
fi
8-
docker run -it --rm --privileged --name ${ADDON_NAME} \
38+
echo "New git tagged build found. Building zigbee2mqtt with tag 'latest'."
39+
docker run -it --rm --privileged --name "${ADDON_NAME}" \
940
-v ~/.docker:/root/.docker \
1041
-v "$(pwd)":/docker \
1142
hassioaddons/build-env:latest \
12-
--target ${ADDON_NAME} \
13-
--git \
43+
--target "${ADDON_NAME}" \
44+
--tag-latest \
1445
--all \
1546
--from "homeassistant/{arch}-base" \
1647
--author "Daniel Welch <[email protected]>" \
1748
--doc-url "${GITHUB_URL}" \
18-
--login ${DOCKER_USERNAME} \
19-
--password ${DOCKER_PASSWORD}
49+
--login "${DOCKER_USERNAME}" \
50+
--password "${DOCKER_PASSWORD}" \
51+
--parallel
52+
fi
2053
echo "Local Docker build successful."

distribute.sh

+51-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,63 @@
11
#!/bin/bash
22
set -ev
33

4+
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/run.sh "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/run.sh
5+
cp "${TRAVIS_BUILD_DIR}"/zigbee2mqtt/set_config.py "${TRAVIS_BUILD_DIR}"/zigbee2mqtt-edge/set_config.py
6+
47
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
58
echo "This build is a pull request, aborting distribution script."
69
exit 0
710
fi
811

912
if [ ! -z "$TRAVIS_TAG" ]; then
10-
echo "Tagged build found. Pushing to Docker with tag 'latest'."
13+
echo "Tagged build found. Pushing zigbee2mqtt image to Docker with tag 'latest'."
14+
15+
docker run -it --rm --privileged --name "${ADDON_NAME}" \
16+
-v ~/.docker:/root/.docker \
17+
-v "$(pwd)":/docker \
18+
hassioaddons/build-env:latest \
19+
--target "${ADDON_NAME}" \
20+
--tag-latest \
21+
--push \
22+
--all \
23+
--from "homeassistant/{arch}-base" \
24+
--author "Daniel Welch <[email protected]>" \
25+
--doc-url "${GITHUB_URL}" \
26+
--login "${DOCKER_USERNAME}" \
27+
--password "${DOCKER_PASSWORD}" \
28+
--parallel
1129
else
12-
# DIFF="$(git diff HEAD^ HEAD dropbox-sync)"
13-
# if [ -z $DIFF ]; then
14-
# echo "No changes in Dropbox Sync add-on. Skipping docker push."
15-
# exit 0
16-
# fi
17-
echo "No tag found. Pushing to Docker with tag 'test'."
18-
fi
30+
echo "No tag found. Pushing zigbee2mqtt and zigbee2mqtt-edge images to Docker with tag 'test'."
1931

20-
git status
32+
# distribute zigbee2mqtt with tag test
33+
docker run -it --rm --privileged --name "${ADDON_NAME}" \
34+
-v ~/.docker:/root/.docker \
35+
-v "$(pwd)":/docker \
36+
hassioaddons/build-env:latest \
37+
--target "${ADDON_NAME}" \
38+
--tag-latest \
39+
--push \
40+
--all \
41+
--from "homeassistant/{arch}-base" \
42+
--author "Daniel Welch <[email protected]>" \
43+
--doc-url "${GITHUB_URL}" \
44+
--login "${DOCKER_USERNAME}" \
45+
--password "${DOCKER_PASSWORD}" \
46+
--parallel
2147

22-
docker run -it --rm --privileged --name "${ADDON_NAME}" \
23-
-v ~/.docker:/root/.docker \
24-
-v "$(pwd)":/docker \
25-
hassioaddons/build-env:latest \
26-
--target "${ADDON_NAME}" \
27-
--git \
28-
--all \
29-
--push \
30-
--from "homeassistant/{arch}-base" \
31-
--author "Daniel Welch <[email protected]>" \
32-
--doc-url "${GITHUB_URL}" \
33-
--login "${DOCKER_USERNAME}" \
34-
--password "${DOCKER_PASSWORD}"
48+
# distribute zigbee2mqtt-edge with tag test
49+
docker run -it --rm --privileged --name "${ADDON_NAME_EDGE}" \
50+
-v ~/.docker:/root/.docker \
51+
-v "$(pwd)":/docker \
52+
hassioaddons/build-env:latest \
53+
--target "${ADDON_NAME_EDGE}" \
54+
--tag-latest \
55+
--push \
56+
--all \
57+
--from "homeassistant/{arch}-base" \
58+
--author "Daniel Welch <[email protected]>" \
59+
--doc-url "${GITHUB_URL}" \
60+
--login "${DOCKER_USERNAME}" \
61+
--password "${DOCKER_PASSWORD}" \
62+
--parallel
63+
fi

zigbee2mqtt-edge/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG BUILD_FROM
2+
FROM $BUILD_FROM
3+
4+
# Add env
5+
ENV LANG C.UTF-8
6+
7+
RUN apk add --update --no-cache jq nodejs nodejs-npm python3 python3-dev \
8+
python2 make gcc g++ linux-headers udev git && \
9+
pip3 install PyYAML==3.12 && \
10+
git clone -b '0.1.0' --single-branch --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /app
11+
12+
COPY run.sh /app/run.sh
13+
COPY set_config.py /app/set_config.py
14+
15+
WORKDIR /app
16+
17+
RUN ["chmod", "a+x", "/app/run.sh"]
18+
RUN ["npm", "install", "--unsafe-perm", "-g", "pm2"]
19+
RUN ["npm", "install", "--unsafe-perm"]
20+
RUN apk del make gcc g++ python2 linux-headers udev
21+
22+
CMD [ "/app/run.sh" ]

zigbee2mqtt-edge/config.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "zigbee2mqtt-edge",
3+
"version": "test",
4+
"slug": "zigbee2mqtt-edge",
5+
"description": "Development build of the zigbee2mqtt add-on.",
6+
"auto_uart": true,
7+
"url": "https://github.com/danielwelch/hassio-zigbee2mqtt",
8+
"startup": "before",
9+
"boot": "auto",
10+
"map": ["share:rw"],
11+
"options": {
12+
"data_path": "/share/zigbee2mqtt",
13+
"homeassistant": true,
14+
"permit_join": false,
15+
"mqtt_base_topic": "zigbee2mqtt",
16+
"mqtt_server": "mqtt://homeassistant",
17+
"serial_port": "/dev/ttyACM0"
18+
},
19+
"schema": {
20+
"data_path": "str",
21+
"homeassistant": "bool",
22+
"permit_join": "bool",
23+
"mqtt_base_topic": "str",
24+
"mqtt_server": "str",
25+
"serial_port": "str",
26+
"mqtt_user": "str?",
27+
"mqtt_pass": "str?",
28+
"debug": "bool?",
29+
"err": "bool?"
30+
},
31+
"image": "dwelch2101/zigbee2mqtt-edge-{arch}"
32+
}

zigbee2mqtt/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV LANG C.UTF-8
77
RUN apk add --update --no-cache jq nodejs nodejs-npm python3 python3-dev \
88
python2 make gcc g++ linux-headers udev git && \
99
pip3 install PyYAML && \
10-
git clone -b master --single-branch https://github.com/Koenkk/zigbee2mqtt.git /app
10+
git clone -b master --single-branch --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /app
1111

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

zigbee2mqtt/config.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zigbee2mqtt",
3-
"version": "test",
3+
"version": "0.1.0",
44
"slug": "zigbee2mqtt",
55
"description": "Zigbee to MQTT Bridge",
66
"auto_uart": true,
@@ -26,8 +26,7 @@
2626
"mqtt_user": "str?",
2727
"mqtt_pass": "str?",
2828
"debug": "bool?",
29-
"err": "bool?",
30-
"commit": "str?"
29+
"err": "bool?"
3130
},
3231
"image": "dwelch2101/zigbee2mqtt-{arch}"
3332
}

zigbee2mqtt/run.sh

-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ CONFIG_PATH=/data/options.json
55
DATA_PATH=$(jq --raw-output ".data_path" $CONFIG_PATH)
66
DEBUG_ZIGBEE2MQTT=$(jq --raw-output ".debug // empty" $CONFIG_PATH)
77
ERR_LOG=$(jq --raw-output ".err // empty" $CONFIG_PATH)
8-
SHA=$(jq --raw-output ".commit // empty" $CONFIG_PATH)
98

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

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

16-
if [[ ! -z "$SHA" ]]; then
17-
git reset --hard "$SHA"
18-
fi
1915

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

0 commit comments

Comments
 (0)