Basic plugin with DomoticzEx question

Python and python framework

Moderator: leecollings

Post Reply
brjhaverkamp
Posts: 56
Joined: Wednesday 06 December 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Basic plugin with DomoticzEx question

Post by brjhaverkamp »

Hello all,

I am trying to create a plugin, based on the Basetemplate.py
I am able to create some devices (or are they called units now?

Code: Select all

BurnerSwitch = Domoticz.Unit(Name="BurnerSwitch", DeviceID="AduroHx", Unit=1, Type=244, Subtype=73, Switchtype=0).Create()
But I am not able to use the devices that are created.
It shows up under switches. But when I click the lightbulb it doesn't switch on.
It does call the onCommand callback and I can e.g. print something to the log, but I can not figure out how to change the state of the switch.
I'm pretty sure I'm missing something obvious. But most examples are still based on the old Domoticz framework, instead of DomoticzEx.

Can anyone give me a pointer?

Regards,

Bert
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Basic plugin with DomoticzEx question

Post by waltervl »

Zigbee2mqtt plugin is DomoticzEx so that could give some inspiration (I am not a programmer)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
brjhaverkamp
Posts: 56
Joined: Wednesday 06 December 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Basic plugin with DomoticzEx question

Post by brjhaverkamp »

Hi Waltervl,

Thanks. Indeed it is one of the few I could find. But the onCommand doesn't seem to have an update function. Or at least not that I could find/recognise.

I now got it working with the following code. But is this indeed the expected way? It looks quite convoluted. so any suggestion/advice is welcome.

Code: Select all

def onCommand(self, DeviceID, Unit, Command, Level, Color):
        Domoticz.Log("onCommand called for Device " + str(DeviceID) + " Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
        if Devices[DeviceID].Units[Unit].nValue == 1:
            Domoticz.Log("Switching off: ")
            Devices[DeviceID].Units[Unit].nValue= 0
            Devices[DeviceID].Units[Unit].sValue= "Off"
            Devices[DeviceID].Units[Unit].Update()
        else:
            Domoticz.Log("Switching on")
            Devices[DeviceID].Units[Unit].nValue= 1
            Devices[DeviceID].Units[Unit].sValue= "On"
            Devices[DeviceID].Units[Unit].Update()
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Basic plugin with DomoticzEx question

Post by waltervl »

Sorry, as mentioned I am not a programmer.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Basic plugin with DomoticzEx question

Post by waltervl »

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
brjhaverkamp
Posts: 56
Joined: Wednesday 06 December 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Basic plugin with DomoticzEx question

Post by brjhaverkamp »

Hi Waltervi,

Just to close this thread: Thanks for the example!!.
It helped a lot! I got my basic Aduro plugin working.
Now working on expanding and cleaning up!
Regards,

Bert
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest