diff --git a/README.md b/README.md index b90fb582c..949bd3f65 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/common/rootfs/docker-entrypoint.sh b/common/rootfs/docker-entrypoint.sh index 4e1e789ab..a0ef493c5 100755 --- a/common/rootfs/docker-entrypoint.sh +++ b/common/rootfs/docker-entrypoint.sh @@ -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 + 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" @@ -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 @@ -37,8 +50,8 @@ 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 @@ -46,7 +59,6 @@ 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" diff --git a/zigbee2mqtt-edge/config.json b/zigbee2mqtt-edge/config.json index 83dbdf45b..dbf7f96ca 100644 --- a/zigbee2mqtt-edge/config.json +++ b/zigbee2mqtt-edge/config.json @@ -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, @@ -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", diff --git a/zigbee2mqtt/CHANGELOG.md b/zigbee2mqtt/CHANGELOG.md index 7f5c784b6..9282af7a5 100644 --- a/zigbee2mqtt/CHANGELOG.md +++ b/zigbee2mqtt/CHANGELOG.md @@ -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) diff --git a/zigbee2mqtt/config.json b/zigbee2mqtt/config.json index 309799418..c1824b7d4 100644 --- a/zigbee2mqtt/config.json +++ b/zigbee2mqtt/config.json @@ -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, @@ -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",