Parameter value in one Python plugin that is different when used more than once

Python and python framework

Moderator: leecollings

Post Reply
freekdk
Posts: 33
Joined: Monday 01 February 2021 16:33
Target OS: Linux
Domoticz version: V2025.1
Location: Netherlands
Contact:

Parameter value in one Python plugin that is different when used more than once

Post by freekdk »

I have two HomeWizard 1F kWh devices and in domoticz I have two hardware devices using the same plugin. I activated a Mode3 parameter which shows in the two lines in the Hardware window to have two different values for that parameter.

I declared that parameter under the class BasePlugin and use it in the functions with the prefix "self." So in onStart(self) it gets the value of the Mode3 parameter. I would expect that device one gets 0 as that value, because that's shown in the window with all Hardware and the other device gets the non-zero value.

It turns out that both devices use the same non-zero value.

How do I implement this the way I expect it?
freekdk
Posts: 33
Joined: Monday 01 February 2021 16:33
Target OS: Linux
Domoticz version: V2025.1
Location: Netherlands
Contact:

Re: Parameter value in one Python plugin that is different when used more than once

Post by freekdk »

Apparently when declaring a variable in class BasePlugin, that value is used in both used hardware device in Domoticz. To distinguish between the different hardware devices one needs to use the parameter Parameters["Mode3"], which is assigned to the parameter in class BasePlugin, but get reassigned when the following hardware device, using the same plugin, gets initialized.

This also means that other parameters set from Parameters["ModeX"] should not be used from the value declared under BasePlugin, but be used as Parameters["ModeX"] in case de plugin is used for more than one hardware device.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest