Unit deletion failed, UnitEx object is not associated with a plugin

Python and python framework

Moderator: leecollings

Post Reply
User avatar
heggink
Posts: 979
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Unit deletion failed, UnitEx object is not associated with a plugin

Post by heggink »

@dnpwwo: whilst trying to develop a new plugin I get the above error. Here are the 2 code snippets for creating and deleting:

I create 2 devices as follows:

Code: Select all

        if dev_id not in Devices:
                mySwitchUnit = Domoticz.Unit(Name=dev_id, DeviceID=dev_id, Unit=1, Type=244, Subtype=73, Switchtype=0, Options={}, Used=1, Description="")
                mySwitchUnit.Create()
                myTextUnit = Domoticz.Unit(Name=dev_id, DeviceID=dev_id, Unit=2, TypeName="General", Subtype=19, Options={}, Used=1, Description="")
                myTextUnit.Create()
Then if anyone of teh 2 gets deleted through teh domotcz interface, I want to delete the otherone myself:

Code: Select all

        def onDeviceRemoved(self, DeviceID, Unit):
                Domoticz.Log("Device onDeviceRemoved for DeviceID: " +str(DeviceID)+" and Unit: "+str(Unit))
                if Unit == 1:
                        Domoticz.Log("Device onDeviceRemoved unit 1 so delete 2")
                        Devices[DeviceID].Units[2].Delete()
                else:
                        Domoticz.Log("Device onDeviceRemoved unit 1 so delete 1")
                        Devices[DeviceID].Units[1].Delete()
What am I doing wrong?
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Unit deletion failed, UnitEx object is not associated with a plugin

Post by Dnpwwo »

@heggink,

Nothing, I reproduced your code and it didn't work for me either.

I've pushed a fix.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
heggink
Posts: 979
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Unit deletion failed, UnitEx object is not associated with a plugin

Post by heggink »

Excellent. Thanks.

Sent from my SM-G980F using Tapatalk

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Unit deletion failed, UnitEx object is not associated with a plugin

Post by JanJaap »

Hi,

It is not only the deletion that doesn't work, any referencing of units in this way (or calling methods) doesn't work. Is all that fixed? Which version will it be pushed into?

see also: topic Deleting units in DomoticzEx framework
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Unit deletion failed, UnitEx object is not associated with a plugin

Post by Dnpwwo »

@JanJaap,

I have responded in the other thread, but for clarity: The dictionary containing a device's units is 'Units' not 'Unit'.

That is why Domoticz is correctly reporting:

Code: Select all

2022-04-24 16:26:25.867 Error: testplug: AttributeError: 'DomoticzEx.Device' object has no attribute 'Unit'
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest