Make it possible to attach items to a given plugin #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(copied from mknx/smarthome#83)
Hint: this pull requests depends on the new functionality introduced in pull request #81 (plugin methods), which should be merged first.
With this patch it will be possible to restrict the item attachment to a given plugin. This is useful when you have registered a plugin multiple times.
E.g. having something like this in
plugin.conf
which configures the KNX plugin for two environments (it's just an example, don't know if it works this way):Attaching the different items to the different plugin is now possible using this in
items.conf
:This will only attach the item
home1.light
to the KNX plugin instanceknx1
andhome2.light
to the plugin instanceknx2
to make it possible to use two completely different environments using two different KNX devices (e.g. eibd on different hosts).Notice that when using the
plugin
setting, only the plugins are skipped using the same plugin class. All other plugin will be attached too. So when having multiple KNX plugin instance configured (knx1
andknx2
) and usingplugin = knx1
, only the plugin instanceknx2
will be skipped. Other plugins (like SQLite or DBLog or anything else which could be used too) will be attached too. So it depends on the plugin`s class!I don't know if SmartHome.py was designed to register a plugin multiple times, but it seems it's not forbidden at the moment. Registering a plugin two times could also solve the problem "How to use two different devices when a plugin can only handle one device?" - e.g. using two power meter devices with the SML plugin (see also my comment in pull request #63).
Further I commited a change to the plugin setup:
plugin
setting, all plugin will be attached as before (by inspecting the items configuration)plugin
setting, it works like above except that the plugins using the same class as the plugins configured will be skippedExamples: having DBLog (
dblog
), SQLite (sqlite
) and KNX (knx1
, 'knx2`) plugins configured:plugin = ...
setting not used in item: all plugins will be attachedplugin = knx1
setting in item: onlydblog
,sqlite
(both because class not listed inplugin
setting) andknx1
will be attached (because KNX class listed inplugin
setting)plugin = knx1|knx2
setting in item: all plugins will be attched (the KNX plugins are listed explicitely, so they will be configured of course)