What is the best strategy to add multiple instances of devices supported by the same plugin?
Think about a plugin implementing a special type of switch device. I don't know how many switches I need from the beginning, and I want to add more switches later.
I guess one way to do this is to add more instances of the same hardware. With this approach the obvious question is if all variables in the plugin module are unique and bound to each instance of the module, or if global variables are shared between the instances.
What I look for is a way to create new Domoticz devices by incrementing the unit identifier. But how should I trigger this event? I lack a callback function for this kind of operation.
Any advice on this topic is appreciated.
Strategy for multiple device instances
Moderator: leecollings
- Dnpwwo
- Posts: 820
- Joined: Sunday 23 March 2014 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Melbourne, Australia
- Contact:
Re: Strategy for multiple device instances
@ubee,
Personally I just use more instances of the same hardware. The plugins are completely separate from each other so you don't need to do anything special, all variables are local to a particular plugin instance. I run 3 Kodi plugins and they have no visibility of each other.
Each plugin gets its own hardware ID so you can create Unit #1 in every plugin instance and Domoticz will handle it. The Devices dictionary will contain only the devices for the specific plugin instance.
Personally I just use more instances of the same hardware. The plugins are completely separate from each other so you don't need to do anything special, all variables are local to a particular plugin instance. I run 3 Kodi plugins and they have no visibility of each other.
Each plugin gets its own hardware ID so you can create Unit #1 in every plugin instance and Domoticz will handle it. The Devices dictionary will contain only the devices for the specific plugin instance.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
-
- Posts: 66
- Joined: Tuesday 10 February 2015 20:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Sweden
- Contact:
Re: Strategy for multiple device instances
@dnwpoo,
Thanks for your reply. Good to know all data is privat to each instance of the plugin and I can reuse unit=#1 in every instance. I will follow your advice.
Thanks for your reply. Good to know all data is privat to each instance of the plugin and I can reuse unit=#1 in every instance. I will follow your advice.
Who is online
Users browsing this forum: No registered users and 1 guest