Skip to content

Commit db56bc4

Browse files
committed
incorporate changes from PR #785
Signed-off-by: Phill Kelley <[email protected]>
1 parent f78b2d7 commit db56bc4

File tree

1 file changed

+210
-75
lines changed

1 file changed

+210
-75
lines changed

docs/Containers/Zigbee2MQTT.md

+210-75
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ See also:
168168
The default service definition provided by IOTstack for Zigbee2MQTT includes this device mapping:
169169

170170
``` yaml
171-
devices:
172-
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
171+
devices:
172+
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
173173
```
174174
175-
The above syntax assumes your Zigbee adapter connects via USB. You should either remove both of those lines from your compose file, or make the `devices` clause inactive by prepending `x-`, like this:
175+
The above syntax assumes your Zigbee adapter connects via USB. You should either remove or comment-out both of those lines from your compose file. An alternative approach is to make the `devices` clause inactive by prepending `x-`, like this:
176176

177177
``` yaml
178-
x-devices:
179-
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
178+
x-devices:
179+
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
180180
```
181181

182182
You tell the container how to find your Zigbee adapter across the network by using an environment variable:
@@ -196,7 +196,34 @@ Example:
196196
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=tcp://192.168.1.5:6638
197197
```
198198

199-
## Configuration
199+
## Configuration { #configTemplate }
200+
201+
When you select Zigbee2MQTT in the IOTstack menu, the following service definition is added to your compose file:
202+
203+
``` yaml linenums="1"
204+
zigbee2mqtt:
205+
container_name: zigbee2mqtt
206+
image: koenkk/zigbee2mqtt:latest
207+
environment:
208+
- TZ=${TZ:-Etc/UTC}
209+
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=/dev/ttyACM0
210+
- ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER=zstack
211+
- ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
212+
# only enable the next line for Zigbee2MQTT v1
213+
# - ZIGBEE2MQTT_CONFIG_FRONTEND=true
214+
- ZIGBEE2MQTT_CONFIG_FRONTEND_ENABLED=true
215+
- ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true
216+
# - DEBUG=zigbee-herdsman*
217+
ports:
218+
- "8080:8080"
219+
volumes:
220+
- ./volumes/zigbee2mqtt/data:/app/data
221+
devices:
222+
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
223+
restart: unless-stopped
224+
depends_on:
225+
- mosquitto
226+
```
200227

201228
### Environment variables { #envVars }
202229

@@ -219,12 +246,14 @@ For example, if the Zigbee2MQTT `configuration.yaml` example you are following c
219246
``` yaml
220247
serial:
221248
port: /dev/ttyACM0
249+
adapter: zstack
222250
```
223251

224-
then the equivalent environment variable is:
252+
then the equivalent environment variables are:
225253

226254
``` yaml
227255
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=/dev/ttyACM0
256+
- ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER=zstack
228257
```
229258

230259
Note:
@@ -240,50 +269,139 @@ $ docker-compose up -d zigbee2mqtt
240269

241270
The default service definition provided with IOTstack includes the following environment variables:
242271

243-
* <a name="mqttServer"></a>`ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883`
272+
#### timezone support { #tzSupport }
244273

245-
Typical values for this are:
274+
``` yaml
275+
- TZ=${TZ:-Etc/UTC}
276+
```
246277

247-
- `mqtt://mosquitto:1883`
278+
This assumes that your system timezone has been copied to `~/IOTstack/.env`, otherwise defaults to `Etc/UTC`.
248279

249-
This is default value supplied with the IOTstack template. It assumes that both Zigbee2MQTT and the Mosquitto broker are running in non-host mode containers on the same Raspberry Pi.
280+
If you want to set your timezone:
281+
282+
``` console
283+
$ echo "TZ=$(cat /etc/timezone)" >> ~/IOTstack/.env
284+
```
250285

251-
- `mqtt://localhost:1883`
286+
Most (but not yet all) IOTstack containers use this syntax. The idea is that a single value set in `.env` will ensure your containers operate in the same timezone.
252287

253-
This would be appropriate if you were to run Zigbee2MQTT in host mode and the Mosquitto broker was running on the same Raspberry Pi.
288+
#### serial adapter { #serialAdapter }
254289

255-
- `mqtt://«host-or-ip»:1883`
290+
``` yaml
291+
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=/dev/ttyACM0
292+
```
256293

257-
If the Mosquitto broker is running on a *different* computer, replace `«host-or-ip»` with the IP address or domain name of that other computer. You should also remove or comment-out the following lines from the service definition:
294+
The default value of `/dev/ttyACM0` works in conjunction with the `devices` clause:
258295

259-
```yaml
260-
depends_on:
261-
- mosquitto
262-
```
296+
``` yaml
297+
devices:
298+
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
299+
```
263300

264-
The `depends_on` clause ensures that the Mosquitto container starts alongside the Zigbee2MQTT container. That would not be appropriate if Mosquitto was running on a separate computer.
301+
Taken together, these assume your Zigbee adapter is connected to a local USB port. If you are using a [remote adapter](#identifyRemoteAdapter) then you should:
265302

266-
* <a name="frontEndEnable"></a>`ZIGBEE2MQTT_CONFIG_FRONTEND=true`
303+
1. Change the right hand side of this variable so that it points to your adapter. For example:
267304

268-
This variable activates the Zigbee2MQTT web interface on port 8080. If you want to change the port number where you access the Zigbee2MQTT web interface, see [connecting to the web GUI](#connectGUI).
305+
``` yaml
306+
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=tcp://«ipaddr»:«port»`
307+
```
269308
270-
* <a name="logSymlink"></a>`ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true`
309+
2. Remove, comment-out or inactivate the `devices` clause (as explained in [remote adapters](#identifyRemoteAdapter)).
271310

272-
Defining this variable causes Zigbee2MQTT to create a symlink pointing to the current log **folder** at the path:
311+
#### adapter type { #adapterType }
273312

313+
``` yaml
314+
- ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER=zstack
315+
```
316+
317+
Identify your adapter from the [official list](https://www.zigbee2mqtt.io/guide/configuration/adapter-settings.html#basic-configuration). At the time of writing, the possible values were `zstack`, `ember`, `deconz`, `zigate` or `zboss`.
318+
319+
#### MQTT server type { #mqttServer }
320+
321+
``` yaml
322+
- ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
323+
```
324+
325+
Typical values for this are:
326+
327+
- `mqtt://mosquitto:1883`
328+
329+
This is default value supplied with the IOTstack template. It assumes that both Zigbee2MQTT and the Mosquitto broker are running in non-host mode containers on the same Raspberry Pi.
330+
331+
- `mqtt://localhost:1883`
332+
333+
This would be appropriate if you were to run Zigbee2MQTT in host mode and the Mosquitto broker was running on the same Raspberry Pi.
334+
335+
- `mqtt://«host-or-ip»:1883`
336+
337+
If the Mosquitto broker is running on a *different* computer, replace `«host-or-ip»` with the IP address or domain name of that other computer. You should also remove or comment-out the following lines from the service definition:
338+
339+
```yaml
340+
depends_on:
341+
- mosquitto
274342
```
275-
~/IOTstack/volumes/zigbee2mqtt/data/log/current
276-
```
277343

278-
See [Checking the log](#checkLog) for more information about why this is useful.
344+
The `depends_on` clause ensures that the Mosquitto container starts alongside the Zigbee2MQTT container. That would not be appropriate if Mosquitto was running on a separate computer.
345+
346+
#### front end { #frontEndEnable }
347+
348+
The "front end" is the name given to the Zigbee2MQTT web interface on port 8080. If you want to change the port number where you access the Zigbee2MQTT web interface, see [connecting to the web GUI](#connectGUI).
349+
350+
Zigbee2MQTT version 2 introduced an incompatibility with this setting. The IOTstack template contains the following lines:
351+
352+
``` yaml
353+
# only enable the next line for Zigbee2MQTT v1
354+
# - ZIGBEE2MQTT_CONFIG_FRONTEND=true
355+
- ZIGBEE2MQTT_CONFIG_FRONTEND_ENABLED=true
356+
```
357+
358+
If you are running Zigbee2MQTT version 1 then the front end will not be enabled unless you uncomment:
359+
360+
``` yaml
361+
- ZIGBEE2MQTT_CONFIG_FRONTEND=true
362+
```
363+
364+
Zigbee2MQTT version 1 ignores the following environment variable so you do not need to comment it out:
365+
366+
``` yaml
367+
- ZIGBEE2MQTT_CONFIG_FRONTEND_ENABLED=true
368+
```
369+
370+
However, if you have been running Zigbee2MQTT version 1 and you upgrade to version 2 then you **must** either delete or comment-out:
371+
372+
``` yaml
373+
# - ZIGBEE2MQTT_CONFIG_FRONTEND=true
374+
```
375+
376+
If you do not do that then the container will go into a restart loop. If you examine the container's log, you will see this error:
377+
378+
```
379+
frontend must be object
380+
```
381+
382+
That error is telling you to comment-out that environment variable.
383+
384+
#### logging { #logSymlink }
385+
386+
``` yaml
387+
- ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true
388+
```
389+
390+
Defining this variable causes Zigbee2MQTT to create a symlink pointing to the current log **folder** at the path:
279391

280-
* `- DEBUG=zigbee-herdsman*`
392+
```
393+
~/IOTstack/volumes/zigbee2mqtt/data/log/current
394+
```
281395

282-
Enabling this variable turns on extended debugging inside the container.
396+
See [Checking the log](#checkLog) for more information about why this is useful.
283397

284-
See also [Remote adapters](#identifyRemoteAdapter) for an example of:
398+
#### debugging { #debugging }
285399

286-
* `- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=tcp://«ipaddr»:«port»`
400+
``` yaml
401+
- DEBUG=zigbee-herdsman*
402+
```
403+
404+
Enabling this variable turns on extended debugging inside the container.
287405

288406
### Configuration file { #confFile }
289407

@@ -329,25 +447,21 @@ You are looking for evidence that the container is restarting (ie the "Status" c
329447

330448
### Checking the log { #checkLog }
331449

332-
You can't use `docker logs zigbee2mqtt` to inspect the Zigbee2MQTT container's logs. That's because Zigbee2MQTT writes its logging information to the path:
450+
You can watch the container's log using this command:
333451

334452
```
335-
~/IOTstack/volumes/zigbee2mqtt/data/log/yyyy-mm-dd.hh-mm-ss/log.txt
453+
$ docker logs -f zigbee2mqtt
336454
```
337455

338-
where `yyyy-mm-dd.hh-mm-ss` is the date and time the container was last started. This means that you have to identify the folder with the latest timestamp before you can inspect the log contained within it.
339-
340-
Fortunately, Zigbee2MQTT offers a shortcut. If the [`… LOG_SYMLINK_CURRENT`](#logSymlink) environment variable is `true` then the path to the *current* log will be:
456+
Press <kbd>control</kbd>+<kbd>c</kbd> to terminate the command. An alternative is to observe the following path using commands like `cat` and `tail`:
341457

342458
```
343-
~/IOTstack/volumes/zigbee2mqtt/data/log/current/log.txt
459+
~/IOTstack/volumes/zigbee2mqtt/data/log/current/log.log
344460
```
345461

346-
You can use commands like `cat` and `tail` to examine the *current* log. Example:
462+
Note:
347463

348-
```console
349-
$ cat ~/IOTstack/volumes/zigbee2mqtt/data/log/current/log.txt
350-
```
464+
* this depends on the [`… LOG_SYMLINK_CURRENT`](#logSymlink) environment variable being set to `true`.
351465

352466
### Checking Mosquitto connectivity { #checkMQTT }
353467

@@ -444,7 +558,59 @@ In words:
444558

445559
You can omit the `zigbee2mqtt` arguments from the `pull` and `up` commands, in which case `docker-compose` makes an attempt to pull any available updates for all non-Dockerfile-based images, and then instantiates any new images it has downloaded.
446560

447-
## Service definition change { #update202204 }
561+
## 2025 v1 to v2 upgrade { #update202501 }
562+
563+
If you have been running Zigbee2MQTT version 1 but do a "pull" from DockerHub you will be upgraded to version 2. The first time you do this, you may encounter the following error:
564+
565+
```
566+
frontend must be object
567+
```
568+
569+
This is caused by a configuration incompatibility between v1 and v2. Although it is not *difficult* to update your service definition to work with v2, if you are in a hurry to get your Zigbee service running again you can revert to v1 by making a temporary alteration to your service definition, like this:
570+
571+
``` yaml
572+
# image: koenkk/zigbee2mqtt:latest
573+
image: koenkk/zigbee2mqtt:1.42.0
574+
```
575+
576+
Then, "up" the container:
577+
578+
``` console
579+
$ cd ~/IOTstack
580+
$ docker-compose up -d zigbee2mqtt
581+
```
582+
583+
When you are ready to upgrade to v2, you will need to undo the above change, and you will also need to update your Zigbee2MQTT service definition based on the [template](#configTemplate). In general terms, you will need to do the following:
584+
585+
1. If you have a locally-connected USB adapter then you will need to add:
586+
587+
``` yaml
588+
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=/dev/ttyACM0
589+
```
590+
591+
If you have a network adapter, you will have that variable defined already so you should not change it.
592+
593+
2. Add:
594+
595+
``` yaml
596+
- ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER=zstack
597+
```
598+
599+
Then read the explanation about [adapter types](#adapterType) and make a decision on whether `zstack` is the correct choice.
600+
601+
3. The value of `ZIGBEE2MQTT_CONFIG_MQTT_SERVER` will probably be correct so you should not change it.
602+
603+
4. Replace the existing `ZIGBEE2MQTT_CONFIG_FRONTEND` with the following:
604+
605+
``` yaml
606+
# only enable the next line for Zigbee2MQTT v1
607+
# - ZIGBEE2MQTT_CONFIG_FRONTEND=true
608+
- ZIGBEE2MQTT_CONFIG_FRONTEND_ENABLED=true
609+
```
610+
611+
5. Any other variables you have set will likely be correct so leave those alone.
612+
613+
## 2022 Service definition change { #update202204 }
448614

449615
This information is for existing users of the Zigbee2MQTT container.
450616

@@ -459,28 +625,7 @@ If you were using the Zigbee2MQTT container in IOTstack before April 2022, you s
459625

460626
> You *could* run the menu, then de-select and re-select Zigbee2MQTT. That *will* have the effect of applying the updated service definition but it also risks overwriting any other customisations you may have in place. That is why editing your *compose file* is the recommended approach.
461627

462-
The updated service definition is included here for ease of reference:
463-
464-
``` { .yaml linenums="1" }
465-
zigbee2mqtt:
466-
container_name: zigbee2mqtt
467-
image: koenkk/zigbee2mqtt:latest
468-
environment:
469-
- TZ=${TZ:-Etc/UTC}
470-
- ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
471-
- ZIGBEE2MQTT_CONFIG_FRONTEND=true
472-
- ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true
473-
# - DEBUG=zigbee-herdsman*
474-
ports:
475-
- "8080:8080"
476-
volumes:
477-
- ./volumes/zigbee2mqtt/data:/app/data
478-
devices:
479-
- "${ZIGBEE2MQTT_DEVICE_PATH:?eg echo ZIGBEE2MQTT_DEVICE_PATH=/dev/ttyACM0 >>~/IOTstack/.env}:/dev/ttyACM0"
480-
restart: unless-stopped
481-
depends_on:
482-
- mosquitto
483-
```
628+
The updated service definition is included [here](#configTemplate) for ease of reference.
484629

485630
The changes you should make to your existing Zigbee2MQTT service definition are:
486631

@@ -498,17 +643,7 @@ The changes you should make to your existing Zigbee2MQTT service definition are:
498643

499644
This causes IOTstack to use Zigbee2MQTT images "as is" from [DockerHub](https://hub.docker.com/r/koenkk/zigbee2mqtt/tags).
500645

501-
2. Add these environment variables:
502-
503-
```yaml
504-
- ZIGBEE2MQTT_CONFIG_MQTT_SERVER=mqtt://mosquitto:1883
505-
- ZIGBEE2MQTT_CONFIG_FRONTEND=true
506-
- ZIGBEE2MQTT_CONFIG_ADVANCED_LOG_SYMLINK_CURRENT=true
507-
```
508-
509-
The first two have the **identical** effect to the changes previously made via the Dockerfile. The last variable makes it easier for you to find and [view the current log](#checkLog).
510-
511-
See [environment variables](#envVars) for more detail.
646+
2. Use the [template](#configTemplate) as a guide to adjusting your environment variables. See also [environment variables](#envVars) for more detail.
512647

513648
3. Add the dependency clause:
514649

0 commit comments

Comments
 (0)