Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ For more information see [the documentation](https://github.com/zigbee2mqtt/hass
1. Ensure you can [SSH to your Home Assistant OS](https://community.home-assistant.io/t/howto-how-to-access-the-home-assistant-os-host-itself-over-ssh/263352) (NOT to the SSH Addon)
1. Backup your standalone environment `data` folder (possibly leaving out the `logs/` folder)
1. Start the Zigbee2MQTT HA addon with a non-existing `tty` device, to create the `data` folder
1. Restore your `data` folder contents into `/mnt/data/supervisor/homeassistant/zigbee2mqtt`, e.g. via `scp -O -P 22222 -i PATHTOUSEDSSHKEY ./data/* root@hass:/mnt/data/supervisor/homeassistant/zigbee2mqtt/`
1. Restore your `data` folder contents into `/mnt/data/supervisor/addon_configs/45df7312_zigbee2mqtt/zigbee2mqtt`, e.g. via `scp -O -P 22222 -i PATHTOUSEDSSHKEY ./data/* root@hass:/mnt/data/supervisor/addon_configs/45df7312_zigbee2mqtt/zigbee2mqtt/`
1. Configure your serial port and MQTT settings using the HA addon configuration UI
1. Edit the `/usr/share/hassio/homeassistant/zigbee2mqtt/configuration.yaml` file:
1. Edit the `/mnt/data/supervisor/addon_configs/45df7312_zigbee2mqtt/zigbee2mqtt/configuration.yaml` file:
- Ensure that the serial port section matches the one configured with the UI
- Remove any irrelevant sections from the config (e.g. `mqtt` (if not needed), `advanced/log_syslog`, `frontend`)
1. Start the add-on
Expand Down
20 changes: 16 additions & 4 deletions common/rootfs/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ bashio::log.info "Preparing to start..."
# - https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/issues/387
bashio::config.require 'data_path'

export ZIGBEE2MQTT_DATA="$(bashio::config 'data_path')"

# Migrate configuration to addon specific data path for HA backups, see https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/issues/627
if [[ "$ZIGBEE2MQTT_DATA" == "/addon_config/zigbee2mqtt" ]] && ! bashio::fs.file_exists "$ZIGBEE2MQTT_DATA/configuration.yaml" && bashio::fs.file_exists "/config/zigbee2mqtt/configuration.yaml"; then
Copy link
Contributor

@Nerivec Nerivec Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the folder is named addon_configs not addon_config?
(same for other refs in PR, and #642)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config folder is mounted to /addon_config/ as specified in the config.json

bashio::log.info "Migrating configuration from /config/zigbee2mqtt to $ZIGBEE2MQTT_DATA/zigbee2mqtt"

mkdir -p "$ZIGBEE2MQTT_DATA" || bashio::exit.nok "Could not create $ZIGBEE2MQTT_DATA"
cp -r /config/zigbee2mqtt/* $ZIGBEE2MQTT_DATA/ || bashio::exit.nok "Error copying configuration files from /config to /addon_config."

bashio::log.info "Configuration migrated successfully."
bashio::log.info "Deleting old configuration from /config/zigbee2mqtt"
rm -rf /config/zigbee2mqtt
fi

# Socat
if bashio::config.true 'socat.enabled'; then
bashio::log.info "Socat enabled"
Expand All @@ -23,7 +37,6 @@ if bashio::config.true 'socat.enabled'; then
fi
bashio::log.info "Starting socat"

DATA_PATH=$(bashio::config 'data_path')
SOCAT_OPTIONS=$(bashio::config 'socat.options')

# Socat start configuration
Expand All @@ -37,16 +50,15 @@ if bashio::config.true 'socat.enabled'; then

bashio::log.debug "Modifying process for logging if required"
if bashio::config.true 'socat.log'; then
bashio::log.debug "Socat loggin enabled, setting file path to $DATA_PATH/socat.log"
exec &>"$DATA_PATH/socat.log" 2>&1
bashio::log.debug "Socat loggin enabled, setting file path to $ZIGBEE2MQTT_DATA/socat.log"
exec &>"$ZIGBEE2MQTT_DATA/socat.log" 2>&1
else
bashio::log.debug "No logging required"
fi
else
bashio::log.info "Socat not enabled"
fi

export ZIGBEE2MQTT_DATA="$(bashio::config 'data_path')"
if ! bashio::fs.file_exists "$ZIGBEE2MQTT_DATA/configuration.yaml"; then
mkdir -p "$ZIGBEE2MQTT_DATA" || bashio::exit.nok "Could not create $ZIGBEE2MQTT_DATA"

Expand Down
18 changes: 15 additions & 3 deletions zigbee2mqtt-edge/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@
"timeout": 30,
"panel_icon": "mdi:zigbee",
"map": [
"share:rw",
"config:rw"
{
"type": "share",
"read_only": false
},
{
"type": "homeassistant_config",
"read_only": false,
"path": "/config"
},
{
"type": "addon_config",
"read_only": false,
"path": "/addon_config"
}
],
"ports": {
"8485/tcp": 8485,
Expand All @@ -35,7 +47,7 @@
"8099/tcp": "Frontend tcp-listen port"
},
"options": {
"data_path": "/config/zigbee2mqtt",
"data_path": "/addon_config/zigbee2mqtt",
"socat": {
"enabled": false,
"master": "pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777",
Expand Down
11 changes: 11 additions & 0 deletions zigbee2mqtt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [Unreleased]
- Zigbee2MQTT configuration is now by default stored in the addon specific configuration directory rather than the main `config` directory.
This is required for Home Assistant's backup functionality to work correctly.
New installations and installations using the default settings will automatically migrate to the new path, existing setups with custom settings will continue to work but need to be manually migrated to make use of Home Assistant's backups:

1. Stop the addon
2. Move the `/mnt/data/supervisor/homeassistant/zigbee2mqtt` folder to `/mnt/data/supervisor/addon_configs/45df7312_zigbee2mqtt/zigbee2mqtt` (for example using SSH/SMB or the File Explorer/VSCode addon)
3. Go to the addon config and change the `data_path` from `/config/zigbee2mqtt` to `/addon_config/zigbee2mqtt`
4. Start the addon


## 1.40.2-1
- Updated Zigbee2MQTT to version [`1.40.2`](https://github.com/Koenkk/zigbee2mqtt/releases/tag/1.40.2)

Expand Down
18 changes: 15 additions & 3 deletions zigbee2mqtt/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@
"timeout": 30,
"panel_icon": "mdi:zigbee",
"map": [
"share:rw",
"config:rw"
{
"type": "share",
"read_only": false
},
{
"type": "homeassistant_config",
"read_only": false,
"path": "/config"
},
{
"type": "addon_config",
"read_only": false,
"path": "/addon_config"
}
],
"ports": {
"8485/tcp": 8485,
Expand All @@ -35,7 +47,7 @@
"8099/tcp": "Frontend tcp-listen port"
},
"options": {
"data_path": "/config/zigbee2mqtt",
"data_path": "/addon_config/zigbee2mqtt",
"socat": {
"enabled": false,
"master": "pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777",
Expand Down