Skip to content

Commit 4ac4f1d

Browse files
NerivecKoenkk
andauthored
feat: Onboarding (#740)
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
1 parent a4a6678 commit 4ac4f1d

File tree

6 files changed

+71
-38
lines changed

6 files changed

+71
-38
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,9 @@ venv.bak/
109109
secrets.json
110110

111111
zigbee2mqtt/rootfs
112-
zigbee2mqtt-edge/rootfs
112+
zigbee2mqtt/Dockerfile
113+
zigbee2mqtt/build.yaml
114+
zigbee2mqtt-edge/rootfs
115+
zigbee2mqtt-edge/Dockerfile
116+
zigbee2mqtt-edge/build.yaml
117+
zigbee2mqtt-local/*

README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<a href="https://discord.gg/dadfWYE">
1818
<img src="https://img.shields.io/discord/556563650429583360.svg">
1919
</a>
20-
<a href="http://zigbee2mqtt.discourse.group/">
21-
<img src="https://img.shields.io/discourse/https/zigbee2mqtt.discourse.group/status.svg">
22-
</a>
2320
</div>
2421
<h1>Official Zigbee2MQTT Home Assistant add-on</h1>
2522
</div>
@@ -36,23 +33,15 @@
3633
- **Zigbee2MQTT** is the stable release that tracks the released versions of Zigbee2MQTT. (**recommended for most users**)
3734
- **Zigbee2MQTT Edge** tracks the `dev` branch of Zigbee2MQTT such that you can install the edge version if there are features or fixes in the Zigbee2MQTT dev branch that are not yet released.
3835
1. Click on the add-on and press **Install** and wait till the add-on is installed.
39-
1. Click on **Configuration**
40-
- If you are **not** using the Mosquitto broker add-on fill in your MQTT details (leave empty when using the Mosquitto broker add-on) under the `mqtt` section. Format can be found [here](https://www.zigbee2mqtt.io/guide/configuration/mqtt.html#server-connection), but skip the initial `mqtt:` indent. e.g.: <br>
41-
```yaml
42-
server: mqtt://localhost:1883
43-
user: my_user
44-
password: "my_password"
45-
```
46-
Note: If the `password` includes certain special characters (reserved by yaml specification), the enclosing quotes are required. So it is recommended to always quote it when in doubt.
47-
- Since Zigbee2MQTT automatically attempts to detect the adapter, you can leave the `serial` section empty for now; we may need it later in step 7.
48-
- Click **Save**
49-
- **Tip:** it is possible to refer to variables in the Home Assistant `secrets.yaml` file (not the Zigbee2MQTT one!) by using e.g. `password: '!secret mqtt_pass'`
50-
- **CAUTION:** settings configured through the add-on configuration page will take precedence over settings in the `configuration.yaml` page (e.g. you set `rtscts: false` in add-on configuration page and `rtscts: true` in `configuration.yaml`, `rtscts: false` will be used).
5136
1. Start the add-on by going to **Info** and click **Start**
52-
1. Wait till Zigbee2MQTT starts and press **OPEN WEB UI** to verify Zigbee2MQTT started correctly.
37+
1. Wait a few seconds and press **OPEN WEB UI**, you will now see the onboarding page. More information about the onboarding can be found [here](https://www.zigbee2mqtt.io/guide/getting-started/#onboarding).
38+
1. Fill in the desired settings, for most setups changing the following is enough:
39+
- Select your adapter under _Found Devices_, this will configure the _Coordinator/Adapter Port/Path_ and _Coordinator/Adapter Type/Stack/Driver_.
40+
- Fill in the _Closests WiFi Channel_ to select the most optimal Zigbee channel.
41+
1. Press **Submit**, Zigbee2MQTT will now start, wait a few seconds and refresh the page. You should now see the Zigbee2MQTT frontend.
5342
- If it shows `502: Bad Gateway` wait a bit more and refresh the page.
5443
- If this takes too long (e.g. 2 minutes +) check the **Log** tab to see what went wrong.
55-
- In case the add-on fails to start with the following error: `USB adapter discovery error (No valid USB adapter found). Specify valid 'adapter' and 'port' in your configuration.`, we need to fill in the `serial` section (which we skipped in step 5). Format can be found [here](https://www.zigbee2mqtt.io/guide/configuration/adapter-settings.html#adapter-settings), but skip the initial `serial:` indent. e.g.: <br>
44+
- In case the add-on fails to start with the following error: `USB adapter discovery error (No valid USB adapter found). Specify valid 'adapter' and 'port' in your configuration.`, we need to fill in the `serial` section. Format can be found [here](https://www.zigbee2mqtt.io/guide/configuration/adapter-settings.html#adapter-settings), but skip the initial `serial:` indent. e.g.: <br>
5645
```yaml
5746
adapter: zstack
5847
port: /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0018ED3DDF-if00

common/rootfs/docker-entrypoint.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,7 @@ else
4747
fi
4848

4949
export ZIGBEE2MQTT_DATA="$(bashio::config 'data_path')"
50-
if ! bashio::fs.file_exists "$ZIGBEE2MQTT_DATA/configuration.yaml"; then
51-
mkdir -p "$ZIGBEE2MQTT_DATA" || bashio::exit.nok "Could not create $ZIGBEE2MQTT_DATA"
52-
53-
cat <<EOF > "$ZIGBEE2MQTT_DATA/configuration.yaml"
54-
version: 4
55-
homeassistant:
56-
enabled: true
57-
advanced:
58-
network_key: GENERATE
59-
pan_id: GENERATE
60-
ext_pan_id: GENERATE
61-
EOF
62-
fi
50+
mkdir -p "$ZIGBEE2MQTT_DATA" || bashio::exit.nok "Could not create $ZIGBEE2MQTT_DATA"
6351

6452
if bashio::config.has_value 'watchdog'; then
6553
export Z2M_WATCHDOG="$(bashio::config 'watchdog')"
@@ -68,7 +56,13 @@ fi
6856

6957
export NODE_PATH=/app/node_modules
7058
export ZIGBEE2MQTT_CONFIG_FRONTEND='{"enabled":true,"port": 8099}'
71-
export Z2M_ONBOARD_NO_SERVER="1"
59+
export ZIGBEE2MQTT_CONFIG_HOMEASSISTANT_ENABLED='true'
60+
export Z2M_ONBOARD_URL='http://0.0.0.0:8099'
61+
62+
if bashio::config.true 'force_onboarding'; then
63+
export Z2M_ONBOARD_FORCE_RUN="1"
64+
bashio::log.info "Forcing onboard to run"
65+
fi
7266

7367
if bashio::config.true 'disable_tuya_default_response'; then
7468
bashio::log.info "Disabling TuYa default responses"

zigbee2mqtt-edge/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"baudrate": "int?",
8383
"rtscts": "bool?"
8484
},
85-
"watchdog": "str?"
85+
"watchdog": "str?",
86+
"force_onboarding": "bool?"
8687
},
8788
"image": "ghcr.io/zigbee2mqtt/zigbee2mqtt-edge-{arch}"
8889
}

zigbee2mqtt/DOCS.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,59 @@
11
# Pairing
2+
23
By default the add-on has `permit_join` set to `false`. To allow devices to join you need to activate this after the add-on has started. You can now use the [built-in frontend](https://www.zigbee2mqtt.io/information/frontend.html) to achieve this. For details on how to enable the built-in frontent see the next section.
34

45
# Enabling the built-in frontend
6+
57
Enable `ingress` to have the frontend available in your UI: **Settings → Add-ons → Zigbee2MQTT → Show in sidebar**. You can find more details about the feature on the [Zigbee2MQTT documentation](https://www.zigbee2mqtt.io/information/frontend.html).
68

79
# Configuration
10+
11+
## Onboarding
12+
13+
[Onboarding](https://www.zigbee2mqtt.io/guide/getting-started/#onboarding) allows you to setup Zigbee2MQTT without having to manually enter the details in the add-on configuration page. When starting the add-on with a brand new install (no configuration present), the frontend will show a quick setup page, allowing you to select various settings for Zigbee2MQTT to be able to start.
14+
15+
> [!NOTE]
16+
> Successful detection of adapters, to select from, may vary based on your setup/network. You may have to enter these [details manually](https://www.zigbee2mqtt.io/guide/configuration/adapter-settings.html#basic-configuration) on the page instead.
17+
18+
> [!TIP]
19+
> You can force the onboarding to re-run (e.g. changing adapter) using the toggle available in the add-on configuration page (visible after checking `Show unused optional configuration options`). This will force onboarding to run even after you have successfully configured it for the first time. Make sure to disable it once done.
20+
21+
## Manual
22+
823
Configuration required to startup Zigbee2MQTT is available from the add-on configuration. The rest of the options can be configured via the Zigbee2MQTT frontend.
924

10-
**CAUTION:** settings configured through the add-on configuration page will take precedence over settings in the `configuration.yaml` page (e.g. you set `rtscts: false` in add-on configuration page and `rtscts: true` in `configuration.yaml`, `rtscts: false` will be used). _If you want to control the entire configuration through YAML, remove them from the add-on configuration page._
25+
> [!CAUTION]
26+
> Settings configured through the add-on configuration page will take precedence over settings in the `configuration.yaml` page (e.g. you set `rtscts: false` in add-on configuration page and `rtscts: true` in `configuration.yaml`, `rtscts: false` will be used). _If you want to control the entire configuration through YAML, remove them from the add-on configuration page._
27+
28+
#### Examples for each configuration section
29+
30+
- socat
31+
```yaml
32+
enabled: false
33+
master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
34+
slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
35+
options: "-d -d"
36+
log: false
37+
```
38+
- mqtt
39+
```yaml
40+
server: mqtt://localhost:1883
41+
user: my_user
42+
password: "my_password"
43+
```
44+
- serial
45+
```yaml
46+
adapter: zstack
47+
port: /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0018ED3DDF-if00
48+
```
1149
1250
# Configuration backup
13-
The add-on will create a backup of your configuration.yml within your data path: `$DATA_PATH/configuration.yaml.bk`. When upgrading, you should use this to fill in the relevant values into your new config, particularly the network key, to avoid breaking your network and having to repair all of your devices.
14-
The backup of your configuration is created on add-on startup if no previous backup was found.
51+
52+
The add-on will create a backup of your configuration.yml within your data path: `$DATA_PATH/configuration.yaml.bk`. When upgrading, you should use this to fill in the relevant values into your new config, particularly the network key, to avoid breaking your network and having to re-pair all of your devices.
53+
The backup of your configuration is created on add-on startup if no previous backup was found.
1554

1655
# Enabling the watchdog
56+
1757
To automatically restart Zigbee2MQTT in case of a soft failure (like "adapter disconnected"), the watchdog can be used. It can be enabled by adding the following to the add-on configuration:
1858

1959
```yaml
@@ -23,14 +63,17 @@ watchdog: default
2363
This will use the default watchdog retry delays of 1min, 5min, 15min, 30min, 60min. Custom delays are also supported, e.g. `watchdog: 5,10,30` will start Zigbee2MQTT with the watchdog's retry delays of 5min, 10min, 30min. For more information about the watchdog, read the [docs](https://www.zigbee2mqtt.io/guide/installation/15_watchdog.html).
2464

2565
# Adding Support for New Devices
66+
2667
If you are interested in adding support for new devices to Zigbee2MQTT see [How to support new devices](https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html).
2768

2869
# Notes
70+
2971
- Depending on your configuration, the MQTT server config may need to include the port, typically `1883` or `8883` for SSL communications. For example, `mqtt://core-mosquitto:1883` for Home Assistant's Mosquitto add-on.
3072
- To find out which serial ports you have exposed go to **Supervisor → System → Host system → ⋮ → Hardware**
3173

3274
# Socat
33-
In some cases it is not possible to forward a serial device to the container that zigbee2mqtt runs in. This could be because the device is not physically connected to the machine at all.
75+
76+
In some cases it is not possible to forward a serial device to the container that zigbee2mqtt runs in. This could be because the device is not physically connected to the machine at all.
3477

3578
Socat can be used to forward a serial device over TCP to zigbee2mqtt. See the [socat man pages](https://linux.die.net/man/1/socat) for more info.
3679

zigbee2mqtt/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
"baudrate": "int?",
8686
"rtscts": "bool?"
8787
},
88-
"watchdog": "str?"
88+
"watchdog": "str?",
89+
"force_onboarding": "bool?"
8990
},
9091
"image": "ghcr.io/zigbee2mqtt/zigbee2mqtt-{arch}"
9192
}

0 commit comments

Comments
 (0)