Deleting units in DomoticzEx framework

Python and python framework

Moderator: leecollings

Post Reply
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Deleting units in DomoticzEx framework

Post by JanJaap »

Hi,

I've been trying to delete units in a plugin using the example given here: Developing a Python plugin

Code: Select all

        Devices["test_device"].Unit[1].Delete()
        Devices["test_device"].Unit[2].Delete()
The 2 units were created before so they do exist. This results in the error:

Code: Select all

2022-04-24 16:26:25.865 testplug: onStop called
2022-04-24 16:26:25.865 Status: testplug: Stop directive received.
2022-04-24 16:26:25.865 Error: testplug: Call to function 'onStop' failed, exception details:
2022-04-24 16:26:25.867 Error: testplug: Traceback (most recent call last):
2022-04-24 16:26:25.867 Error: testplug: File "/home/pi/domoticz/plugins/domoticz-test-plugin/plugin.py", line 107, in onStop
2022-04-24 16:26:25.867 Error: testplug: _plugin.onStop()
2022-04-24 16:26:25.867 Error: testplug: File "/home/pi/domoticz/plugins/domoticz-test-plugin/plugin.py", line 74, in onStop
2022-04-24 16:26:25.867 Error: testplug: Devices["test_device"].Unit[1].Delete()
2022-04-24 16:26:25.867 Error: testplug: AttributeError: 'DomoticzEx.Device' object has no attribute 'Unit'
What am I doing wrong? Running latest beta on RPi 3 with Buster, python 3.7.x
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: Deleting units in DomoticzEx framework

Post by Dnpwwo »

@JanJaap,

You need to refer to 'Units', not 'Unit'.

Code: Select all

Devices["test_device"].Units[1].Delete()
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
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: Deleting units in DomoticzEx framework

Post by JanJaap »

Right that makes sense...... Tnx
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest