You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I keep fielding questions on Discord which suggest IOTstack's
Zigbee2MQTT documentation doesn't place sufficient emphasis on using
environment variables to pass configuration settings to the container.
Also, the advent of adapters which are reachable via TCP isn't
mentioned so I have included an example.
Opportunistic cleanup of spurious 0x090A sequences.
Signed-off-by: Phill Kelley <[email protected]>
Copy file name to clipboardExpand all lines: docs/Containers/Zigbee2MQTT.md
+91-14Lines changed: 91 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,17 @@
25
25
1. Run the IOTstack menu and choose both "Mosquitto" and "Zigbee2MQTT". That adds the service definitions for both of those containers to your *compose file*.
26
26
27
27
2.[Prepare your Zigbee adapter](#prepareAdapter) by flashing its firmware.
28
-
3. Follow the steps in [Identify your Zigbee adapter](#identifyAdapter) to work out how your adapter "mounts" on your Raspberry Pi, and edit your *compose file* to include that information.
28
+
3. Follow the steps in [Identify your Zigbee adapter](#identifyAdapter) to work out how your adapter:
29
+
30
+
* "mounts" on your Raspberry Pi; or
31
+
* "connects" over your network,
32
+
33
+
and edit your *compose file* to include that information.
34
+
29
35
4. The default environment variables assume:
30
36
31
-
- You are running Mosquitto and Zigbee2MQTT as IOTstack containers on the same computer; and
37
+
- You are running Mosquitto and Zigbee2MQTT as IOTstack containers on the same computer;
38
+
- Your adapter mounts via USB; and
32
39
- You want the Zigbee2MQTT web front end to be available on port 8080.
33
40
34
41
This is a good basis for getting started. If it sounds like it will meet your needs, you will not need to make any changes. Otherwise, review the [environment variables](#envVars) and make appropriate changes to the service definition in your *compose file*.
@@ -62,9 +69,12 @@ Note:
62
69
63
70
## Identify your Zigbee adapter { #identifyAdapter }
64
71
65
-
This section covers adapters that connect to your Raspberry Pi via USB.
72
+
*[USB adapters](#identifyUSBAdapter)
73
+
*[Remote adapters](#identifyRemoteAdapter)
74
+
75
+
### USB adapters { #identifyUSBAdapter }
66
76
67
-
> See [connect to a remote adapter](https://www.zigbee2mqtt.io/advanced/remote-adapter/connect_to_a_remote_adapter.html) for information on connecting to adapters via TCP.
77
+
This section covers adapters that connect to your Raspberry Pi via USB.
68
78
69
79
Many USB Zigbee adapters mount as `/dev/ttyACM0` but this is not true for *all* adapters. In addition, if you have multiple devices connected to your Raspberry Pi that contend for a given device name, there are no guarantees that your Zigbee adapter will *always* be assigned the *same* name each time the device list is enumerated.
70
80
@@ -104,16 +114,16 @@ For those reasons, it is better to take the time to identify your Zigbee adapter
104
114
The second line indicates a CC2531 adapter is attached to the Raspberry Pi.
105
115
106
116
If the response pattern does **not** change, it means the Raspberry Pi is unable to see your adapter. The two most common reasons are:
107
-
117
+
108
118
1. Your adapter was not flashed correctly. Start over at [prepare your Zigbee adapter](#prepareAdapter).
109
119
2. Your adapter does not mount as a serial device. Try repeating steps 2 through 4 with the command:
110
120
111
121
```console
112
122
$ ls -1 /dev
113
123
```
114
-
124
+
115
125
to see if you can discover how your adapter attaches to your Raspberry Pi.
116
-
126
+
117
127
> One example is the Electrolama zig-a-zig-ah which attaches as `/dev/ttyUSB0`.
118
128
119
129
5. Use the output from the `ls` command in step 4 to form the absolute path to your Zigbee adapter. Example:
@@ -138,7 +148,7 @@ For those reasons, it is better to take the time to identify your Zigbee adapter
138
148
```
139
149
140
150
Note:
141
-
151
+
142
152
* if you forget to do this step, docker-compose will display the following error message:
143
153
144
154
```
@@ -147,13 +157,75 @@ For those reasons, it is better to take the time to identify your Zigbee adapter
147
157
148
158
8. Continue from [bring up your stack](#upStack).
149
159
160
+
### Remote adapters { #identifyRemoteAdapter }
161
+
162
+
This section covers adapters that your Raspberry Pi connects to over a network via TCP.
163
+
164
+
See also:
165
+
166
+
*[connect to a remote adapter](https://www.zigbee2mqtt.io/advanced/remote-adapter/connect_to_a_remote_adapter.html).
167
+
168
+
The default service definition provided by IOTstack for Zigbee2MQTT includes this device mapping:
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:
Any value that can be set in a Zigbee2MQTT [configuration file](#confFile) can also be set using an environment variable.
203
+
Many first time users of the Zigbee2MQTT container are following guidance which assumes their Zigbee2MQTT service is running *natively* rather than in a *container*.
204
+
205
+
When you run Zigbee2MQTT *natively* you provide configuration information by editing Zigbee2MQTT's `configuration.yaml` file. Although you *can* edit `configuration.yaml` when Zigbee2MQTT is running in a container, it is a multi-step process and is also a sub-optimal approach. The correct way to provide configuration information to the Zigbee2MQTT container is via environment variables.
206
+
207
+
**Any** value that can be set in a Zigbee2MQTT [configuration file](#confFile) can also be set using an environment variable.
208
+
209
+
Please read that last sentence again and notice the emphasis on "Any" because it is really important. When you are running Zigbee2MQTT in a container, you **never** have to resort to editing the `configuration.yaml`.
210
+
211
+
The [Zigbee2MQTT documentation](https://www.zigbee2mqtt.io/guide/configuration/#environment-variables) explains the syntax. It boils down to these rules:
212
+
213
+
1. All environment variables start with `ZIGBEE2MQTT_CONFIG_`.
214
+
2. Append all-upper-case labels for section and variable names, separated by underscores.
215
+
3. Append an `=` followed by the value(s).
155
216
156
-
> The [Zigbee2MQTT documentation](https://www.zigbee2mqtt.io/guide/configuration/#environment-variables) explains the syntax.
217
+
For example, if the Zigbee2MQTT `configuration.yaml` example you are following contains these lines:
218
+
219
+
``` yaml
220
+
serial:
221
+
port: /dev/ttyACM0
222
+
```
223
+
224
+
then the equivalent environment variable is:
225
+
226
+
``` yaml
227
+
- ZIGBEE2MQTT_CONFIG_SERIAL_PORT=/dev/ttyACM0
228
+
```
157
229
158
230
Note:
159
231
@@ -190,7 +262,7 @@ The default service definition provided with IOTstack includes the following env
190
262
```
191
263
192
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.
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).
@@ -204,11 +276,15 @@ The default service definition provided with IOTstack includes the following env
204
276
```
205
277
206
278
See [Checking the log](#checkLog) for more information about why this is useful.
207
-
279
+
208
280
* `- DEBUG=zigbee-herdsman*`
209
281
210
282
Enabling this variable turns on extended debugging inside the container.
211
283
284
+
See also [Remote adapters](#identifyRemoteAdapter) for an example of:
Zigbee2MQTT creates a default configuration file at the path:
@@ -231,9 +307,10 @@ If you decide to edit the configuration file:
231
307
232
308
3. [Check the log](#checkLog) for errors.
233
309
234
-
Note:
310
+
Notes:
235
311
236
312
* If you start Zigbee2MQTT from a clean slate (ie where the configuration file does not exist) **and** your *compose file* does not define the [`… MQTT_SERVER`](#mqttServer) environment variable discussed above, the container will go into a restart loop. This happens because the Zigbee2MQTT container defaults to trying to reach the Mosquitto broker at `localhost:1883` instead of `mosquitto:1883`. That usually fails.
313
+
* Settings passed via environment variables take precedence over both the defaults and any changes you make subsequently to `configuration.yaml`. The Zigbee2MQTT container does not update `configuration.yaml` to reflect settings passed via environment variables.
237
314
238
315
## Verifying basic operation
239
316
@@ -430,7 +507,7 @@ The changes you should make to your existing Zigbee2MQTT service definition are:
430
507
```
431
508
432
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).
433
-
510
+
434
511
See [environment variables](#envVars) for more detail.
0 commit comments