[sagercaster] Simplify Thing configuration#19574
Merged
lsiepel merged 4 commits intoopenhab:mainfrom Oct 31, 2025
Merged
Conversation
Adapt to Java 21 and OH5 Signed-off-by: gael@lhopital.org <gael@lhopital.org>
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the SagerCaster binding to improve code quality and modernization. It adds a new reliability channel that indicates the algorithm's confidence based on historical data accumulation, removes the configurable observation period (now fixed at 6 hours), and modernizes the codebase with Java pattern matching, records, and switch expressions.
Key changes:
- Adds a new "reliability" channel that shows algorithm confidence as historical data accumulates (0-100%)
- Removes the
observation-periodconfiguration parameter, fixing the observation window at 6 hours - Refactors code using modern Java features (pattern matching, switch expressions, records)
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| instructions.xml | Adds update instructions for the new reliability channel migration |
| thing-types.xml | Adds thingTypeVersion property, reliability channel definition, and removes observation-period parameter |
| sagercaster.properties | Adds labels/descriptions for the reliability channel |
| SagerCasterHandler.java | Refactors to use modern Java patterns, implements reliability calculation, removes observation-period config |
| ExpiringMap.java | Refactors to use fixed window duration, returns Optional on put(), adds age tracking method |
| SagerCasterDiscoveryService.java | Modernizes with pattern matching instanceof and formatted strings |
| SagerWeatherCaster.java | Converts to use switch expressions and nullable returns instead of UNDEF constant |
| SagerPrediction.java | Converts from class to record with nullable getWindDirection2() |
| SagerCasterHandlerFactory.java | Updates imports to use wildcard and adds final modifiers |
| SagerCasterBindingConstants.java | Changes THING_TYPE_SAGERCASTER initialization and adds SUPPORTED_THING_TYPES_UIDS |
| README.md | Updates documentation to reflect removal of observation-period and addition of reliability channel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ster/src/main/java/org/openhab/binding/sagercaster/internal/SagerCasterBindingConstants.java
Outdated
Show resolved
Hide resolved
....sagercaster/src/main/java/org/openhab/binding/sagercaster/internal/handler/ExpiringMap.java
Outdated
Show resolved
Hide resolved
...aster/src/main/java/org/openhab/binding/sagercaster/internal/handler/SagerCasterHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
lsiepel
reviewed
Oct 30, 2025
lsiepel
requested changes
Oct 30, 2025
Contributor
lsiepel
left a comment
There was a problem hiding this comment.
Just one comment, otherwise LGTM
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
This file contains hidden or 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
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 removes the 'observation-period' configuration element.
Adaptations to Java 21 and OH5
Solves #19564