Announcement

Collapse
No announcement yet.

devices owned by a plug-in

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • devices owned by a plug-in

    I'm trying to understand the preferred way a plug-in can create and find devices it owns. My plug-in will have about 10 devices.

    1) Should it create one root device with 10 child devices or 10 root devices? With 1 root device, the plug-in has found all of them once it finds the root device.

    2) How should the plug-in determine if any devices exist that were previously created by the plug-in? It looks like this is based on the name of the plug-in, so how can I ensure my plug-in name is unique? If I pick a name like 'weather', it seems the system will not be able to run another plug-in someone calls 'weather'. I see where the plug-in should not use the address or code fields to attempt to create a unique device name. I envision ending up with some plug-in's that I don't publish (not useful to anybody but me) and some plug-in's from the community. Thus, HST can not be the gatekeeper to ensure unique names.

    Thanks for any insight.

  • #2
    My interpretation;

    1) One root, ten children - although with your plugin you may want to create more roots with more children, I have a plugin for an energy meter and make sure each sensor has a root device and then the data is on the children devices - 1 sensor = 1 root device.

    2) There are numerous ways you can do this but the way I have always seen is to test the interface property matches the name of your plugin. I then use the PlugExtraData to store something like a unique number for the device but you could also use the address/code fields. You would like to hope no one comes along and names their plugin as exactly the same as yours, it will probably bounce and fail to connect if you try and connect two plugins with the same name that are not setup as multi instance plugins.
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      It sounds like I should put some unique characters at the front of the name like Blade does with "BL" and then put the true name after that. I don't see any other way to avoid name collisions.

      Comment

      Working...
      X