-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[pwm] Initial Contribution #10205
[pwm] Initial Contribution #10205
Conversation
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
The higher the control percentage (duty cycle), the longer the ON phase. | ||
|
||
Example: If the fixed interval is 10 sec and the duty cycle is 30%, the output is ON for 3 sec and OFF for 7 sec. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel a warning is necessary about relay contact life expectancy. If this example was done for a full year it would be over 1.3 Million contact cycles which would wear most cheap devices out and make even quality units fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fwolter,
Many thanks for this contribution!
I am very sorry that this PR was unregarded for such a long time, despite you yourself reviewing and merging so many other PRs continuously. Feel free to nag all maintainers in such cases, you do not deserve to have your PRs not being processed quickly.
Overall, it looks good to me and I like the approach.
I was actually first wondering whether a profile might have been a better choice (and easier to use), but I think this solution here has the benefit that the input does not have to come from a binding/channel, but can be any item (like a totally virtual one that is just set by a slider in the UI).
I have a few comments below, though, happy to discuss.
...g.openhab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/PWMConstants.java
Show resolved
Hide resolved
...tion.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/state/AlwaysOffState.java
Outdated
Show resolved
Hide resolved
public static final String MODULE_TYPE_ID = AUTOMATION_NAME + ".trigger"; | ||
private static final Set<String> SUBSCRIBED_EVENT_TYPES = Set.of(ItemStateEvent.TYPE); | ||
private final Logger logger = LoggerFactory.getLogger(PWMTriggerHandler.class); | ||
private final ScheduledExecutorService scheduler = Executors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we do not offer a scheduler
for ModuleHandlers as we do for ThingHandlers.
I do not feel good about every ModuleHandler therefore creating it's own thread for scheduling tasks and wonder if we shouldn't change this in the framework. We could e.g. add some suitable method (like getScheduler()
or maybe directly schedule()
) to it and make it use a thread pool. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same when implementing this. And I was dreaming of a schedule()
that cancels all scheduled and still active tasks in dispose()
of the super class :) Like in the modbus binding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a look. The TriggerHandlerCallbackImpl
actually already has an executor
internally, which is even shut down when the handler (or rather the callback) is disposed.
How about making it a scheduled executor and expose it through a method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll file a PR.
...omation.pwm/src/main/java/org/openhab/automation/pwm/internal/handler/PWMTriggerHandler.java
Outdated
Show resolved
Hide resolved
* @author Fabian Wolter - Initial Contribution | ||
*/ | ||
@NonNullByDefault | ||
public class PWMRuleTemplate extends RuleTemplate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to also see a rule template being defined.
I noticed that our Main UI is still lacking support for rule templates, is that correct?
If so, I think we should have that added asap as it is a very powerful feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I copied that from the PID controller, which copied it from Hilbrand's PID code without knowing what I was doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghys Did you already spend any thoughts on adding support for rule templates in the Main UI? After all, the Paper UI already had that feature - would be awesome to have it in the Main UI, too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vaguely, but I didn't look into them in detail, only saw a video or two about them and a couple examples on the Eclipse Marketplace. And didn't ever see anything but an empty list in Paper UI so kind of still considered them an experimental-grade/proof-of-concept feature, didn't know they were in actual use.
IMHO it's rather limiting to have only Java code able to contribute rule templates, they themselves should be able to be defined by the user and shared on whatever will become the new community marketplace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it's rather limiting to have only Java code able to contribute rule templates
This is not the case. You can also add templates as JSON files in your conf folder and it should be possible to also add a provider that stores stuff in the db, so that templates can also be managed through the UI. Would be actually cool to add a feature to convert an existing rule into a template and let the user share it (for the start as JSON on the forum, later than through a marketplace).
But the starting point would be to be able to at least use existing templates in the UI. This should actually be fairly easy to do. I can create an issue with some details, if that's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghys, as promised: openhab/openhab-webui#1082
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Thanks for your feedback and your words! Not a problem that it is in the backlog for some time. |
...ab.automation.pwm/src/main/java/org/openhab/automation/pwm/internal/type/PWMTriggerType.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Build failed with 1 SAT error. Could you please check? |
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray, finally the build is green - thanks for the contribution!
Thank you for your review! |
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de> Signed-off-by: Luca Calcaterra <calcaterra.luca@gmail.com>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de> Signed-off-by: Luca Calcaterra <calcaterra.luca@gmail.com>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This introduces a Pulse Width Modulation module for openHAB.
PWM can be used to control actuators continuously from 0 to 100% that only support ON/OFF commands. E.g. valves or heating burners. It accomplishes that by switching the actuator on and off with a fixed interval. The higher the control percentage (duty cycle), the longer the ON phase.
https://community.openhab.org/t/new-automation-pulse-width-modulation-pwm/117498