Skip to content

Commit fac5a48

Browse files
committed
2023-05-16 Zigbee2MQTT adaptation to expected kernel change - master branch - PR 1 of 2
Background: - SensorsIot#690 – Kernel update may remove /dev/ttyAMA0 Changes: 1. Adopts generic syntax for device specification to prompt user to add the relevant key (`ZIGBEE2MQTT_DEVICE_PATH`) and path (eg `/dev/ttyUSB0`) to `.env`. Example: ``` $ echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyUSB0 >>~/IOTstack/.env ``` 2. Adopts `TZ=${TZ:-Etc/UTC}` 3. Adds (disabled) environment variable to enable debugging. 4. Rewrites documentation to explain the how-to of device-path setup. Signed-off-by: Phill Kelley <34226495+Paraphraser@users.noreply.github.com>
1 parent 96f4297 commit fac5a48

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

.templates/zigbee2mqtt/service.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ zigbee2mqtt:
22
container_name: zigbee2mqtt
33
image: koenkk/zigbee2mqtt:latest
44
environment:
5-
- TZ=Etc/UTC
5+
- TZ=${TZ:-Etc/UTC}
66
- ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
77
- ZIGBEE2MQTT_CONFIG_FRONTEND=true
88
- ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true
9+
# - DEBUG=zigbee-herdsman*
910
ports:
1011
- "8080:8080"
1112
volumes:
1213
- ./volumes/zigbee2mqtt/data:/app/data
1314
devices:
14-
- /dev/ttyAMA0:/dev/ttyACM0
15+
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
1516
restart: unless-stopped
1617
depends_on:
1718
- mosquitto

docs/Containers/Zigbee2MQTT.md

+14-18
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,21 @@ For those reasons, it is better to take the time to identify your Zigbee adapter
131131

132132
What the output is telling you is that the *by-id* path is a symbolic link to `/dev/ttyACM0`. Although this *may* always be true on your Raspberry Pi, the only part that is actually *guaranteed* to be true is the *by-id* path, which is why you should use it.
133133

134-
7. Use your favourite text editor to open your *compose file*.
135-
8. Find your `zigbee2mqtt` service definition and identify this line:
134+
7. Once you have identified the path to your adapter, you communicate that information to docker-compose like this:
136135

137-
```yaml
138-
- /dev/ttyAMA0:/dev/ttyACM0
136+
```console
137+
$ echo ZIGBEE2MQTT_DEVICE_PATH=/dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00125A00183F06C5-if00 >>~/IOTstack/.env
139138
```
140139

141-
The default from the IOTstack template maps the *external* (Raspberry Pi) device `/dev/ttyAMA0` to the *internal* (Zigbee2MQTT container) device `/dev/ttyACM0`.
142-
143-
> On the Raspberry Pi, the *external* device `/dev/ttyAMA0` is the Bluetooth adapter. It was chosen as the default because it normally exists and its presence avoids docker-compose refusing to bring up the container. However, a Bluetooth adapter doesn't actually respond like a Zigbee adapter so the Zigbee2MQTT container will go into a restart loop if you start it before completing these steps. A side-effect of the container entering a restart loop is the web GUI never starts.
144-
145-
9. Replace `/dev/ttyAMA0` with your *by-id* path. Example:
140+
Note:
141+
142+
* if you forget to do this step, docker-compose will display the following error message:
146143

147-
```yaml
148-
- /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00125A00183F06C5-if00:/dev/ttyACM0
149-
```
144+
```
145+
parsing ~/IOTstack/docker-compose.yml: error while interpolating services.zigbee2mqtt.devices.[]: required variable ZIGBEE2MQTT_DEVICE_PATH is missing a value: eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env
146+
```
150147

151-
10. Save your work.
152-
11. Continue from [bring up your stack](#upStack).
148+
8. Continue from [bring up your stack](#upStack).
153149

154150
## Configuration { #configuration }
155151

@@ -172,10 +168,6 @@ $ docker-compose up -d zigbee2mqtt
172168

173169
The default service definition provided with IOTstack includes the following environment variables:
174170

175-
* `TZ=Etc/UTC`
176-
177-
You should replace `Etc/UTC` with a value that is correct for your location.
178-
179171
* `ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883` { #mqttServer }
180172

181173
Typical values for this are:
@@ -212,6 +204,10 @@ The default service definition provided with IOTstack includes the following env
212204
```
213205

214206
See [Checking the log](#checkLog) for more information about why this is useful.
207+
208+
* `- DEBUG=zigbee-herdsman*` { #enableDebug }
209+
210+
Enabling this variable turns on extended debugging inside the container.
215211

216212
### Configuration file { #confFile }
217213

0 commit comments

Comments
 (0)