-
-
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
[hdpowerview] Add support for enabling/disabling automations #11637
Conversation
@jlaur, this looks like a nice set of new features. I don't use automations, but the improvements to the dynamic channels, like automatic renaming, are things I am looking forward to. I had one thought about how to address the breaking change of moving scene channels into a channel group. I don't fully understand OpenHAB's internals and channel handling, so sorry if this doesn't make sense, but if a user has an item linked to the old (non-grouped) scene channel, will commands from that item still get sent to the hub Thing, but then dropped/ignored? I guess what I'm wondering is rather than making deprecated channels to handle the old item links (which I think you tested but didn't work?), could you still handle the old channels and issue a warning? The section of the code that I'm thinking about is in
In |
@arroyoj - thanks for your comments. If you are right, the current version of the code would already work. However, |
@arroyoj - unfortunately it doesn't work, |
@jlaur, thanks for testing it. I tried it out too, and I realized that I was misunderstanding how channels are handled. I was thinking any channel with the right "prefix" would be forwarded to the Thing, but clearly not. It would be great if there was some way to create a "catch-all" channel, but I could find no evidence of that in the core code. I did have another thought about how you could structure the logic of channel creation to maintain backwards compatibility while avoiding the situation described in Naming convention for channels?. If I understand the problem you described in that post, items linked to channels with a group ID (ie, If that is correct, could the following logic (expressed as pseudocode) work for dynamic channel creation while keeping backwards compatibility?
The two The assumption here is that if the user has created at least one new channel link for a given scene, they no longer need the deprecated channel. On the other hand, if they have only an old channel link for the scene, a deprecated channel is needed to keep it working, but the new channel should also be available. If someone had two items linked to the same scene, it is possible only one would be updated and the other could stop working, but my guess is most people make a single item for each scene. And, if someone has not linked a scene at all, only the new channel should be created. Sorry if you have tried this already or if this won't work out as I thought. Unfortunately, I don't have a way to test this myself. |
@arroyoj - thanks, that's a simple and quite reasonable approach - the missing piece in the puzzle, I would say. I've implemented it and this logic works and seems straight-forward. JAR updated. |
Two comments from my side..
|
I'm preparing to create an issue for openhab-core for supporting channel migrations. See also: Currently it's hard to manage, but with @arroyoj's suggestion I believe the current logic is quite acceptable. See also #11668.
I did a first quick around of your PR, and as far as I can see we only collide in |
Created openhab/openhab-core#2590 |
...ew/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java
Outdated
Show resolved
Hide resolved
...ew/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java
Show resolved
Hide resolved
Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
75bba9e
to
aaf4a18
Compare
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@andrewfg - do you have more comments, or do you think it's in a state ready for being merged? |
…ng channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
I don't have any more comments. (But -- to be honest -- since I do not actually have automations in my system, I have not fully tested it. Therefore please take my lack of comments as a 'no objection' rather than an 'active approval').. |
I have been using this version in production all the way, and have tested the following:
@lolodomo - would you consider this PR for 3.2? The advantage of including it would be less backwards compatibility struggles as scene groups were not part of 3.1. Otherwise will have to create some additional logic for scene group backwards compatibility. |
I just tested out the latest JAR from @jlaur on my system. From a user perspective, it all looks good to me. Here is what I tested:
I think that covers the features described in the PR, and I didn't see any issues arise. Thanks @jlaur for adding these features. |
Thanks a lot for verifying the functionality, @arroyoj. |
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.
LGTM
@lolodomo, @kaikreuzer - any chance of this getting into 3.2? |
@lolodomo / @kaikreuzer -- it would be super cool if you could squeeze in #11698 as well ;) |
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Nick Waterton <n.waterton@outlook.com>
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Michael Schmidt <mi.schmidt.83@gmail.com>
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
…#11637) * Add support for enabling/disabling automations. Fixes openhab#11516 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix class description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document automation channel and channel groups. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene example in documentation. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Consolidate method for getting channel map. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Extract channel updating from data fetching methods. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Draft implementation of better automation description. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify and optimize building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Further simplify building weekday string. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scheduled event channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update scene group channels when modified. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix cache synchronization during initialization. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Reduced code duplication. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Shorten time formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Danish translations for dynamic channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Simplify, optimize and fix dynamic channel creation. Channel order is now preserved when updating an existing channel. Scenes and scene collection are sorted correctly. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Provide backwards compatibility for deprecated channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Document purpose of createDeprecatedSceneChannels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Cleaned up poll method for improved readability. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix potential race condition when initialize() is called while updating channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Fixes #11516
Signed-off-by: Jacob Laursen jacob-github@vindvejr.dk
This pull request adds automation support to the Hunter Douglas PowerView binding. This can be useful for keeping as much logic in the PowerView Hub as possible to reduce dependencies. A typical use-case would be switching between winter and summer automations. In the summer one might want the shades up on weekdays at a fixed time. In the winter when still dark at this time, an offset relative to sunrise might be more appropriate. It will now be possible with rules to switch between such two automations when the sun will start to rise before or after some fixed time.
Channel groups have been introduced for:
Visual example:
Additional changes