Skip to content
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

update persistence, add more functions #213

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

querdenker2k
Copy link
Collaborator

@querdenker2k querdenker2k commented Jan 1, 2025

This will add all available persistence functions which are currently available in openHAB core.
The usage is now more like the original usage from the core (return types, parameters, etc).
Some of the methods are optimized for easier usage, but some of them require extra doing as before like sumSince returned a double before. The original openhab persistence function returns an abstract State.
The JRulePersistence provides now

    default Optional<JRuleDecimalValue> sumSinceAsDecimal(ZonedDateTime timestamp, @Nullable String serviceId) {
        return sumSince(timestamp, serviceId).map(v -> (JRuleDecimalValue) v.as(JRuleDecimalValue.class));
    }

    default Optional<JRuleDecimalValue> sumSinceAsDecimal(ZonedDateTime timestamp) {
        return sumSinceAsDecimal(timestamp, null);
    }

    default Optional<JRuleValue> sumSince(ZonedDateTime timestamp) {
        return sumSince(timestamp, null);
    }

    Optional<JRuleValue> sumSince(ZonedDateTime timestamp, @Nullable String serviceId);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant