Page 1 of 1

Bug with Replace Device and Python Plugin

Posted: Tuesday 08 April 2025 19:21
by fleinze
Version: 2025.1 build 16627
Platform: official Docker container
Plugin/Hardware: Raspberry pi https://github.com/fleinze/Zigbee2Tasmoticz/
Description:
Every time I use the replace device function I get the following error when the plugin tries to update the device again:

2025-04-08 19:10:30.257 Error: z2t: Device creation failed, Hardware/Unit combination (2:5) already exists in Domoticz.

It seems that the Devices directory does not contain the device affected by the replace function. The plugin tries to create a new device because it can not find the device, and uses the first available unit-number for a new device. This fails because this unit is actually not available in the database, it is just not in the Devices directory.

Workaround: Reloading the plugin manually after using the replace device function.

Yes, I wrote the plugin myself but I am certain that it is not a problem specific to my code.

Re: Bug with Replace Device and Python Plugin

Posted: Tuesday 08 April 2025 23:41
by waltervl
You are using the old plugin framework, better use the new DomoticzEx plugin framework.

And I dont hope you are using the replace function in a plugin. It should only be used to replace a device when it needs to be recreated with another ID when it has a battery replacement or with another hardware gateway. For zigbee this should not be needed as the Domoticz ID is normally related t its unique zigbee ID.

Check the old zigbee2mqtt python plugin for some reference.

Re: Bug with Replace Device and Python Plugin

Posted: Wednesday 09 April 2025 12:01
by fleinze
Thanks for the tipp, I will check the zigbee2mqtt-plugin.

I need "replace" for two reason:
1. I switched from mysensors to zigbee-sensors and wanted to keep the sensor history
2. some zigbee sensors get a new short-address when the battery is replaced. I use the shortaddress as DeviceID.

Re: Bug with Replace Device and Python Plugin

Posted: Wednesday 09 April 2025 17:15
by waltervl
I would advise you to buy a new Zigbee Dongle and use the Zigbee4Domoticz plugin. (if you do not want to use Zigbee2MQTT). Saves you a lot of work and frustration....

Re: Bug with Replace Device and Python Plugin

Posted: Thursday 10 April 2025 7:05
by fleinze
I changed my code to use the DomoticzEx framework.
The original bug also exists with the DomoticzEx framework:
When the replace device function is used, the Devices-directory is not updated correctly.

Re: Bug with Replace Device and Python Plugin

Posted: Thursday 10 April 2025 8:51
by lost
waltervl wrote: Wednesday 09 April 2025 17:15 I would advise you to buy a new Zigbee Dongle and use the Zigbee4Domoticz plugin. (if you do not want to use Zigbee2MQTT). Saves you a lot of work and frustration....
When I started with Zigbee & Z4D plugin, I wanted to do some replace to keep some existing devices (Zwave using integrated OZW) data but was unable to do so as well.
Fortunately, as this was a start, this was not an issue as this was only some plugs/alarm sensors with no interest in year to year comparisons... But can confirm there is an issue there.

Re: Bug with Replace Device and Python Plugin

Posted: Thursday 10 April 2025 9:48
by waltervl
For replacement the device type needs to be similar. For OZW a lot of specific types were created. Lately with the OZW to Zwave-JS-UI migration a lot has been imprived in the replacement function to also support kind of similar devices.