Hello all,
I already have developped a couple of simple python plugins (very specific, fixed and predifined number of devices), but I'd like to create a more flexible hardware device. A good starting point for me would be to buil a plugin based on pyShelly (I have plenty of those and already have a good knowledge of this library).
Since I coulnd't find a way to provide then store information relative to the devices that would be created through this plugin, here are my questions:
One way to do things would be to have one instance of the plugin for each and every device I want to create.
??? Is this the way to go? ???
It would definitely work, but how efficient would it be? I would have to run several instances, possibly leading to a lot of resources, more than if I could manage everything in the same session.
Any help or advice will be really appreciated. Thank you in advance.
python hardware plugin - one instance per device ?!?
Moderator: leecollings
-
- Posts: 14
- Joined: Wednesday 17 February 2021 9:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
- waltervl
- Posts: 5843
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: python hardware plugin - one instance per device ?!?
Running a plugin instance per Shelly device seems not logical, especially if you have a lot of devices.
You can look at the abandoned Shelly MQTT plugin how the author has set it it up to identify each shelly device. https://github.com/enesbcs/Shelly_MQTT
Sometimes you also see that the plugin maintaines a simple text device list with some extra information. See for example the Zigbee4Domoticz plugin. But that is a very big plugin so be warned...
You can look at the abandoned Shelly MQTT plugin how the author has set it it up to identify each shelly device. https://github.com/enesbcs/Shelly_MQTT
Sometimes you also see that the plugin maintaines a simple text device list with some extra information. See for example the Zigbee4Domoticz plugin. But that is a very big plugin so be warned...

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 356
- Joined: Saturday 27 February 2016 0:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: python hardware plugin - one instance per device ?!?
Anyway, even if this is not the best solution, it's always possible for a plugin to read/store data into a json file in plugin's folder.
- waltervl
- Posts: 5843
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: python hardware plugin - one instance per device ?!?
Also check this Shelly Cloud plugin for a start: https://github.com/mario-peters/ShellyCloudPlugin2
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 14
- Joined: Wednesday 17 February 2021 9:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
Re: python hardware plugin - one instance per device ?!?
Thank you all for your replies. I needed that little push to really get into this. I'll look into these examples.
-
- Posts: 215
- Joined: Thursday 12 October 2017 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Dev
- Location: the Netherlands
- Contact:
Re: python hardware plugin - one instance per device ?!?
it really depends on the type of info you want to store. If this info is obtained at startup you can simply do it in memory. I contributed to the sOMFY PLUGIN where the device id is storing the device address which is not visible on the UI (you do see it in the device list page) which provides a nice scalable setup for a variable devicelist (the mentioned zigbee2mqtt plugin does something similar but then more elaborate/complicated)
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
Who is online
Users browsing this forum: No registered users and 1 guest