Mostrando entradas con la etiqueta Scrippting. Mostrar todas las entradas
Mostrando entradas con la etiqueta Scrippting. Mostrar todas las entradas

domingo, 6 de abril de 2025

How to Migrate Devices Between Similar Hardware (ej: Zigbee2MQTT) Instances in Domoticz

Migrating Zigbee devices between different Zigbee2MQTT instances in Domoticz can help avoid the hassle of re-pairing and reconfiguring each device. This guide explains how to reassign Zigbee devices from one HardwareID to another using direct SQLite queries on the domoticz.db database.

1. Identify the Current Hardware IDs

First, list all available hardware entries in your Domoticz database:

sqlite3 domoticz.db "SELECT ID, Name FROM Hardware;"

Look for the IDs associated with your old and new Zigbee coordinators.

2. Find Devices Bound to the Old Coordinator

To verify which devices are currently assigned to the old HardwareID (e.g. 33):

sqlite3 domoticz.db "SELECT ID, Name, DeviceID, HardwareID FROM DeviceStatus 
WHERE HardwareID=33;"

This will help you confirm which devices need to be migrated.

3. Migrate a Specific Device

Let’s say you want to move the device with this DeviceID: 0xa4c1382a2d7d8728 from HardwareID 33 to 41.

Stop Domoticz before modifying the database:

sudo service domoticz stop

Backup the database just in case:

cp /path/to/domoticz.db /path/to/domoticz.backup.db

Run the update:

sqlite3 domoticz.db "UPDATE DeviceStatus SET HardwareID=41 
WHERE HardwareID=33 AND DeviceID LIKE '0x00158d0003cb7cfa%';"

4. Restart Domoticz

Once the migration is complete, restart the service:

sudo service domoticz start

5. Optional: Verify the Migration

Run the same query again but with the new HardwareID:

sqlite3 domoticz.db "SELECT ID, Name, DeviceID, HardwareID FROM DeviceStatus 
WHERE HardwareID=41 AND DeviceID='0xa4c1382a2d7d8728';"

If the entry appears here, your device has been successfully migrated.

Final Notes

  • Make backups before any manual DB operation.
  • Don’t forget to update the Zigbee2MQTT configuration (devices.yaml) in the new instance if necessary.
  • This method avoids re-pairing and keeps your Domoticz setup tidy and efficient.

@inphower.bsky.social - InPhOwEr

Twitter Inphower