-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin methods to smarthome #81
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
and get_plugin_ident() to return the thead ident for a given plugin instance
This was referenced Feb 2, 2014
… register this plugin multiple times # e.g. when having more than one power meter device and serial devices
Just made the SML plugin able to register multiple times (e.g. when having multiple power meter devices or serial devices connected). |
…trieve the plugin name for given plugin instance # can also be used instead of plugin ident (which is the thread`s identifier) for # better readability
…eduler with the plugin name instead of plugin ident, which can not be used to identify the plugin instance
Created new PR smarthomeNG/smarthome#50 in new project and will close this issue now. Thanks for your great application! |
18 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This patch will add the following function to smarthome instance:
return_plugin(name)
- returns the plugin instance for given plugin nameget_plugin_ident(instance)
- returns the thread identifier of the given plugin instance, which should be uniqueget_plugin_name(instance)' - returns the plugin name (which is the section name in
plugin.conf`)These function may help when running multiple instances of one plugin and each want to add a scheduler task. Usually you do something like
sh.scheduler.add("PluginName", ...)
. But when registering a plugin multiple times, only one scheduler task will be registered.E.g. having something like this in
plugin.conf
:In this case the plugin is registered two times (one with
sh.name1
and another one withsh.name2
). When this plugin is registering a scheduler task, usually it will do something like thissh.scheduler.add("ThePlugin", ...)
- but this will only register one scheduler task, since the other will overwrite the previous scheduler task because it uses the same name!To solve this problem, the plugin can use the thread identifier and can do something like this:
sh.scheduler.add("ThePlugin-" + str(sh.get_plugin_name(self)), ...)
, which will register two scheduler tasks now since both includes the unique thread identifier in the scheduler task.I don't know of any other solution how to configure a plugin multiple times (e.g. for different devices) and having a scheduler task for each of them.