Page 1 of 1

Deleting units in DomoticzEx framework

Posted: Sunday 24 April 2022 16:28
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

Re: Deleting units in DomoticzEx framework

Posted: Friday 29 April 2022 10:16
by Dnpwwo
@JanJaap,

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

Code: Select all

Devices["test_device"].Units[1].Delete()

Re: Deleting units in DomoticzEx framework

Posted: Friday 29 April 2022 14:28
by JanJaap
Right that makes sense...... Tnx