Re-pairing Sensor to Z2M after Battery died resulting in unsupported device?

I have a PIR+mmWave sensor from Tuya that I was using for a good while until recently the battery died. For some reason it didn’t just reconnect when replacing the battery so I decided to Force Remove the device and Repair it. After enabling Permit Join, it can find the device but shows unsupported now.

I have a 2nd identical sensor still being used in my Laundry Room, and as you can see below it’s supported just fine.

Not 100% sure why or how this happened, but any advice here would be greatly appreciated!

Force remove is tricky. A Zigbee coordinator can only as a Zigbee device to leave the network. If you use ‘force remove’, the device is removed from the database, but the device still has the network keys.
Maybe try to remove the device without ‘force’, and then try to re-pair.

@francisp thanks for that suggestion. Just tried that and sadly same problem. Wish I knew about that before doing force remove the first couple of times. Have I potentially dug myself into a hole with this particular device?

@francisp I solved the problem with the help of AI. In my case I was using claude-3.5 (Anthropic) but I’d imagine, ChatGPT, Gemini etc would probably do a good job too.

Steps of the solution:

  1. Identify the IEEE address of the device showing “unsupported” and paste that somewhere for reference purposes
  2. Stop the Z2M add-on. Add in the following to the Z2M add-on configuration YAML as it relates this specific device and it being a Tuya device.
external_converters:
  - tuya.js

advanced:
  cache_state: false
  cache_state_persistent: false
  cache_state_send_on_startup: false
  
device_options:
  _TZE200_kb5noeto:
    optimistic: true
    retain: true
  1. Download or rename the database.db file found in homeassistant/zigbee2mqtt/database.db - in my case I renamed it to database.db.new
  2. if you downloaded the database.db instead of renaming it, delete it all together so that when you start the Add-on again it will create a new database.db file
  3. Start Zigbee2MQTT - There should now be no devices shown on the list
  4. Enable pairing and put device into pairing mode
  5. It should now reconnect successfully and show supported as the old info is no longer present in the current database
  6. Find the newly created database.db file and open it. There should be 2 lines, 1 will be the coordinator and 2 will be the newly paired device. Confirm that the IEEE address is the same as the one saved previously
  7. Stop Zigbee2MQTT
  8. (Optional) rename this database to database.db.new or download it as a backup
  9. In the backup database prior to deletion, find the same IEEE address again (likely the last one on the list if you tried to repair it recently and it filed to show support).
  10. Delete that line as it has the old data for the IEEE address of that same device
  11. Copy and Paste over the Line 2 in the database.db.new which should have the new data for the newly paired device that is succesfully showing supported
  12. Change the ID number at the beginning of the line for that device as it’s likely not #2 and you’ll likely have a gap if you examine all your devices in the database. In my case there was a gap between device ID 8 an 10 and so I changed my newly paired device to ID 9 so that it doesn’t conflict with another device in the list.
  13. Save the database.db.backup and then delete the other current database.db file (backup optional) and rename the backup file to remove the .backup so that the Add-on will now reference the modified database which has all the previously paired device data and now the fixed newly paired and fully supported device :slight_smile:
  14. Restart the Zigbee2MQTT Add-on and everything should be back in order
1 Like

After reflecting back on these steps, I’m not really sure how necessary the changes to the config file and creating the tuya.js file (which is currently blank still) were as essentially what this solution boils down to is:

  1. Backing up the database
  2. Stopping the add-on
  3. Deleting the database
  4. Starting the add-on and repair the device
  5. Stop add-on again
  6. Merge new device pairing data into the old backup database and check for conflicts
  7. Restore the new database
  8. Start add-on again

But it’s working now, so not really gonna touch anything further :smiley: