-
-
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
[somneo] Add alarm support and other improvements #14882
Conversation
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
@@ -58,6 +58,21 @@ public class SomneoBindingConstants { | |||
public static final String CHANNEL_SUNSET_REMAINING_TIME = "sunset#remainingTime"; | |||
public static final String CHANNEL_SUNSET_SWITCH = "sunset#switch"; | |||
public static final String CHANNEL_SUNSET_VOLUME = "sunset#volume"; | |||
public static final String CHANNEL_ALARM_SNOOZE = "alarm#snooze"; |
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.
Group id alarm
should be separated from channel id snooze
.
This applies to all these channels.
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.
Thank you for the review. What exactly do you mean by separate? Rename the group id alarm because it is too similar to the other alarm groups ids with an index (alarm{index})?
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.
@clinique - can you help clarifying this?
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.
@clinique - gentle ping.
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.
alarm
is the group name, while snooze
is the channel itself. You could directly target it using channelUID.getIdWithoutGroup();
in your handler.
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.
For handling the commands it would be enough in most cases to check only the channel id. I would then have to divide the logic on several switchs, since not all ids are unique. The variables are also used for updateState(...)
. There I would have to build the id together with the group, or is only the channel id enough if it is unique? But then I would have to rebuild the id with the group for the channel ids that are not unique.
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.
@0x4d4d - did you see @clinique's reply?
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.
@jlaur Sorry, I had commented but it had the pending label and don't saw it.
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 don't see any issues with the current approach that should block this PR longer.
@clinique - considering @0x4d4d's latest comment, please continue and conclude the discussion here and do a follow-up PR if there is anything that can be improved without introducing unnecessary complexity or redundancy. I have seen similar comments from you in other PR's, so I think it would be nice to reach a conclusion/consensus.
You are also welcome to have a look at #14376 where I have something similar and couldn't find a better solution:
public static final String CHANNEL_ALARM_VOLUME = "alarm%d#volume"; | ||
|
||
// Regex for alarm channels | ||
public static final String CHANNEL_ALARM_PREFIX_REGEX = "^alarm(\\d{1,2})#\\w+$"; |
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.
Separating group id from channel id would avoid having to use a regex. This is provided directly by then channel id ( getIdWithoutGroup
)
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.
The regex is mainly needed to extract the alarm index from the group id.
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.
Is the regex with the use case in ok or is there something that needs to be done here?
....openhab.binding.somneo/src/main/java/org/openhab/binding/somneo/internal/SomneoHandler.java
Outdated
Show resolved
Hide resolved
....openhab.binding.somneo/src/main/java/org/openhab/binding/somneo/internal/SomneoHandler.java
Outdated
Show resolved
Hide resolved
...inding.somneo/src/main/java/org/openhab/binding/somneo/internal/model/AlarmSettingsData.java
Outdated
Show resolved
Hide resolved
...inding.somneo/src/main/java/org/openhab/binding/somneo/internal/model/AlarmSettingsData.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
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.
Thanks for the improvements! 👍 The code looks good, I have added only some minor comments.
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
....openhab.binding.somneo/src/main/java/org/openhab/binding/somneo/internal/SomneoHandler.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/i18n/somneo_de.properties
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somneo/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
...binding.somneo/src/main/java/org/openhab/binding/somneo/internal/SomneoBindingConstants.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Jacob Laursen <[email protected]> Signed-off-by: 0x4d4d <[email protected]>
Co-authored-by: Jacob Laursen <[email protected]> Signed-off-by: 0x4d4d <[email protected]>
Co-authored-by: Jacob Laursen <[email protected]> Signed-off-by: 0x4d4d <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
Signed-off-by: Michael Myrcik <[email protected]>
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
* [somneo] Add alarm clock channels Signed-off-by: Michael Myrcik <[email protected]> Signed-off-by: Thomas Burri <[email protected]>
* [somneo] Add alarm clock channels Signed-off-by: Michael Myrcik <[email protected]> Signed-off-by: Matt Myers <[email protected]>
* [somneo] Add alarm clock channels Signed-off-by: Michael Myrcik <[email protected]> Signed-off-by: Jørgen Austvik <[email protected]>
Description
Testing
org.openhab.binding.somneo-3.4.4-SNAPSHOT.jar
org.openhab.binding.somneo-4.0.0-SNAPSHOT.jar