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

[persistence] Persistence filter not accepting units of measure #4625

Open
mkroch opened this issue Feb 28, 2025 · 6 comments
Open

[persistence] Persistence filter not accepting units of measure #4625

mkroch opened this issue Feb 28, 2025 · 6 comments
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@mkroch
Copy link

mkroch commented Feb 28, 2025

In OH 4.3.3 in jdbc.persistance file, I have pasted following filter (based on documentation exapmle @ https://www.openhab.org/docs/configuration/persistence.html):

Filters { temp_sanity : [] -100 200 C }

After save, log shows:

Configuration model ‘jdbc.persist’ has errors, therefore ignoring it: [11,1]: mismatched input ‘}’ expecting ‘:’

The same problem is when I change “C” to "°C" or “K” and so on. When not using units of measure I get a following error in log:

2025-02-28 09:06:48.916 [WARN ] [ence.filter.PersistenceIncludeFilter] - Cannot compare 5.03125 °C to range -100 - 200

At first I thought that, as mentioned above, the documentation might be wrong because it not only says that UoM in presistance filter are accepted (and uses them in examples) but stresses that they should be used:

In case of dimensional items (e.g Number:Temperature) a unit MUST be provided.

But then no fillter is possible since comparison cannot be made.

I did contact the community (https://community.openhab.org/t/persistance-filter-not-accepting-uom/162764/6) and was directed here.

Expected Behavior

My intention was to include in database recording only readings of Number:Temperature item that are in the specified range. This way I could exclude readings that are abnormal like -1000°C which I occasionally receive due to sensor hardware connectivity issues.

Current Behavior

Everything apart of the above works fine.

Possible Solution

Is it a bug?

Steps to Reproduce (for Bugs)

I am using oh on Ubuntu. Presistance is mariadb via jdbc. Checked it with rrd4j and it looked the same

Your Environment

I am using 4.3.3 oh on Ubuntu. Presistance is mariadb via jdbc. Checked it with rrd4j and it looked the same. The issue arouse while using oh 4.3.2 update to 4.3.3. did not help apart of the fact that persistance filter started accepting negative values (as mentioned in #4400 ).

@mkroch mkroch added the bug An unexpected problem or unintended behavior of the Core label Feb 28, 2025
@openhab-bot
Copy link
Collaborator

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

https://community.openhab.org/t/persistance-filter-not-accepting-uom/162764/14

@jlaur
Copy link
Contributor

jlaur commented Feb 28, 2025

@openhab/core-maintainers - I believe this issue belongs in core, can someone move it there?

@mkroch
Copy link
Author

mkroch commented Feb 28, 2025

How do I do that? :)

@wborn wborn transferred this issue from openhab/openhab-addons Feb 28, 2025
@wborn wborn changed the title [persistance] Persistance filter not accepting units of measure [persistence] Persistence filter not accepting units of measure Feb 28, 2025
@wborn
Copy link
Member

wborn commented Feb 28, 2025

It's transferred now.

@mherwege
Copy link
Contributor

mherwege commented Mar 1, 2025

@mkroch Can you try:

Filters { temp_sanity : [] -100 200 “°C” }

Looking at the code, it expects a String for the unit, and a String needs to be in quotes. If that solves the issue, a documentation change may be needed.

@mkroch
Copy link
Author

mkroch commented Mar 1, 2025

Using either double or single quotation solves the problem - at least the *.persist file is accepted with no errors and I haven;t observed undesirable behaviour overnight. If the description is to be changed, would be nice to clarify that "°C" not "C" is needed. I don;t have kelvin sensors but it seems that "K" instead of "°K" is appropriate.

Filters { temp_sanity : [] -100 200 "°C" }
Above example seems ok.

I will observe further and if no undesirable ivents occur will close that topic maked "Solved". Thank you for quick help.

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 the Core
Projects
None yet
Development

No branches or pull requests

5 participants