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

[basicprofiles] Fix inability to filter a percent QuantityType input #18091

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Jan 11, 2025

Normally to filter the values of QuantityType inputs, the conditions are written as > min_value, e.g. > 100 W. However, when the QuantityType is a percent, writing it as > 10 % caused the statefilter parser to think it's a $DELTA_PERCENT check instead of checking the actual input value.

This is a bug and a problem, preventing the state filter from being used to filter a percent quantity type.

This PR fixes this problem by adding a new $INPUT function which can be used in this situation to help the parser, so the condition needs to be rewritten as $INPUT > 10 % to achieve "input-value-filter" instead of "delta-percent-filter".

This should be backported to 4.3

@jimtng jimtng requested a review from J-N-K as a code owner January 11, 2025 13:35
@jimtng jimtng added the bug An unexpected problem or unintended behavior of an add-on label Jan 11, 2025
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/state-filter-range-filter-profile/158025/43

@jimtng jimtng force-pushed the statefilter-input branch from e31c9f6 to d116107 Compare January 11, 2025 23:44
@jimtng jimtng force-pushed the statefilter-input branch from d116107 to 402f179 Compare January 11, 2025 23:48
@lsiepel
Copy link
Contributor

lsiepel commented Jan 17, 2025

Are you sure there is no better solution? To be clear I don’t have any 😀I suspect that it is counter intuitive for users to have a different declaration for this case.

@jimtng
Copy link
Contributor Author

jimtng commented Jan 17, 2025

The other alternative I can think of is to remove the handy > 1% syntax for delta percent.

@jimtng
Copy link
Contributor Author

jimtng commented Jan 17, 2025

Let me sleep on it first... (literally).

@jimtng jimtng marked this pull request as draft January 17, 2025 16:06
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/state-filter-range-filter-profile/158025/55

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/state-filter-range-filter-profile/158025/57

@jimtng
Copy link
Contributor Author

jimtng commented Jan 18, 2025

@lsiepel Thanks, I've created #18121 as another solution to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants