Page 3 of 3
Re: Python Plugin Framework limitation to 256 Units
Posted: Tuesday 06 July 2021 13:29
by Dnpwwo
@pipiche,
I've pushed another version tonight that has a number of fixes and added a new Domoticz.Dump() function which will write out the full Python context at the point of invokation.
Have you struct any more issue with testing?
Re: Python Plugin Framework limitation to 256 Units
Posted: Monday 02 August 2021 16:50
by pipiche
hi man,
Still didn't started as it looks quiet some heavy work on my plugin, but I'm still preparing myself and there is an area where I don't understand how it will work ?
Some of the callbacks like onCommand, onRemove ... are providing Unit as the parameter. How does it works with the DomoticzEx (as Unit won't be enought to find the right Device ?
We need Devices[ device_id "].Unit[ unit_id ]
Re: Python Plugin Framework limitation to 256 Units
Posted: Thursday 05 August 2021 5:44
by Dnpwwo
@pipiche,
I went back to the wiki page and realised I had done a very average job of documenting the changes and have made a number of updates. I have also pushed a code change today which cleans up the event API so if you are thinking of starting then please make sure you have this version.
The event handling for onDeviceAdded, onDeviceModified, onDeviceRemoved and onCommand
CAN be quite different in the extended plugin framework, have a look at
https://www.domoticz.com/wiki/Developin ... ugin#Units. Basically you can choose where these events go depending on your requirements but to do so you need to create your own classes that override the default Domoticz objects using the 'Register' function.
When you are using the extended framework and one of these events arrives, rather than just dispatching it to the base plugin, it will do this:
- Check the Python object type being used to represent Units and see if it supports the event. If it does, send the event to the object with appropriate parameters.
- If the above check failed, check the Python object type being used to represent Devices and see if it supports the event. If it does, send the event to the object with appropriate parameters.
- If both preceding steps failed, attempt to dispatch the event to the base plugin itself
Superfluous parameters are removed in this process so, for example, the onCommand functions will look like this:
- Unit: def onCommand(self, Command, Level, Hue). The onCommand target is 'self' so no DeviceID or Unit is supplied.
- Device: def onCommand(self, Unit, Command, Level, Hue). The onCommand target is 'self->Units[Unit]' so no DeviceID is supplied.
- Base: def onCommand(self, DeviceID, Unit, Command, Level, Hue). The onCommand target is 'Devices[DeviceID].Units[Unit]'.
The example I have put in the wiki page shows this (hopefully

), it shows onDeviceModified declared at the 3 possible levels an indicates which will be called:
Code: Select all
import DomoticzEx as Domoticz
...
class hvacDevice(Domoticz.Device):
def __init__(self, DeviceID):
super().__init__(DeviceID)
def onDeviceModified(self, Unit):
# This will never be called because the Unit specific version overrides it
Domoticz.Log("Device onDeviceModified for Unit: "+str(self.Units[Unit]))
class hvacUnit(Domoticz.Unit):
def __init__(self, Name, DeviceID, Unit, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="", Used=0, Description=""):
super().__init__(Name, DeviceID, Unit, TypeName, Type, Subtype, Switchtype, Image, Options, Used, Description)
def onDeviceAdded(self):
Domoticz.Log("Unit onDeviceAdded for "+str(self.Name))
def onDeviceModified(self):
Domoticz.Log("Unit onDeviceModified for "+str(self.Name))
def onDeviceRemoved(self):
Domoticz.Log("Unit onDeviceRemoved for "+str(self.Name))
def onCommand(self, Command, Level, Hue):
Domoticz.Log("onCommand called for '" + str(self.Name)+ "': Parameters '" + str(Command) + "', Level: " + str(Level))
Command = Command.strip()
action, sep, params = Command.partition(' ')
action = action.capitalize()
# Override the default Domoticz objects with custom ones
Domoticz.Register(Device=hvacDevice, Unit=hvacUnit)
def onDeviceModified(self, DeviceID, Unit):
# This will never be called because the Unit specific version overrides it
Domoticz.Log("Device onDeviceModified for Unit: "+str(Devices[DeviceID].Units[Unit]))
Re: Python Plugin Framework limitation to 256 Units
Posted: Thursday 05 August 2021 8:45
by pipiche
Not sure I found what I was looking but I think I need to build a new plugin to better understand.
On the other side, I think this is very sad, because there is no chance to get an easy path from the legcay plugin to the new one. I think on one side, the DomoticzEx enhance a lot the framework, make it more modern ..., but too much work to get a plugin compatible with the 2 modes.
I really need to understand the consequences to the Domoticz-Zigate plugin
Re: Python Plugin Framework limitation to 256 Units
Posted: Saturday 07 August 2021 8:38
by Dnpwwo
If you just want to be able to do 'Devices[DeviceID].Units[Unit]' then you don't need to override anything, just use:
Code: Select all
def onCommand(DeviceID, Unit, Command, Level, Hue):
that will give you what you want
Re: Python Plugin Framework limitation to 256 Units
Posted: Tuesday 31 August 2021 7:22
by Derik
Hi to all.
Looking forward this problem.
I do have also the z2m plugin running with more then 255 idx.
My question is there a solution?
Or this not getting better?
Like to hear, or can test if you want.
Thanks for the great work!!
Re: Python Plugin Framework limitation to 256 Units
Posted: Tuesday 31 August 2021 17:15
by pipiche
You need to update the z2m plugin and use the new DomoticzEx module.
Envoyé de mon iPhone en utilisant Tapatalk
Re: Python Plugin Framework limitation to 256 Units
Posted: Tuesday 31 August 2021 18:10
by Derik
pipiche wrote: ↑Tuesday 31 August 2021 17:15
You need to update the z2m plugin and use the new DomoticzEx module.
Envoyé de mon iPhone en utilisant Tapatalk
Thanks...
Please a how to?
Or how is this solution work?
Developr of the z2m says.. no solution:
https://github.com/stas-demydiuk/domoti ... -908921117
Re: Python Plugin Framework limitation to 256 Units
Posted: Wednesday 08 September 2021 15:19
by pipiche
@Dnpwwo
just to keep you posted, we are making good progress to reach a solution to our plugin where we would maintain compatibility between the 2 worlds ( Legacy and Extension). This requires a bit more testing, but so far so good.
I have posted some new posts here:
viewtopic.php?f=65&t=36953
viewtopic.php?f=65&t=36951
Re: Python Plugin Framework limitation to 256 Units
Posted: Saturday 28 October 2023 18:42
by Thorgal789
Internally Domoticz uses a byte for the Unit in some code so higher numbered units would not work properly.
And this can't be corrected ? It's the logic corrective no ?
Because the extended framework look more a "workaround" than an corrective.
And just to be sure, there is no more 255 limit with the new framework, no limit in Unit and no limit in DeviceID ?
Re: Python Plugin Framework limitation to 256 Units
Posted: Monday 30 October 2023 9:06
by Dnpwwo
@Thorgal789,
The extended framework is not a workaround but but a better implementation for certain types of plugins, specifically those where multiple 'device's (physical or virtual) that have more than one attribute that can be exposed to Domoticz. It is much easier to code the plugin for these because each 'device' tends to come with a DeviceID (IP Address, UUID, ...) and therefore the attributes (i.e. Units) can be grouped together.
For example, I have a plugin that handles ZWave devices on my network
https://github.com/dnpwwo/Domoticz-ZWav ... /plugin.py that will handle unlimited devices although the restriction of 255 Units
per device is still there.
Re: Python Plugin Framework limitation to 256 Units
Posted: Monday 30 October 2023 17:49
by Thorgal789
Thx for informations.
I m starting to fight with it, since yesterday, not a problem for new plugin, but for older, it's harder to keep all the already created stuff working