Bug with Replace Device and Python Plugin

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
fleinze
Posts: 9
Joined: Wednesday 19 April 2017 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Bug with Replace Device and Python Plugin

Post 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.
User avatar
waltervl
Posts: 5779
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fleinze
Posts: 9
Joined: Wednesday 19 April 2017 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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.
User avatar
waltervl
Posts: 5779
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fleinze
Posts: 9
Joined: Wednesday 19 April 2017 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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.
lost
Posts: 660
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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.
User avatar
waltervl
Posts: 5779
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Bug with Replace Device and Python Plugin

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest