Persistance, filter not accepting UoM

Someone please help:
In OH 4.3.3 in jdbc persistance file, I have pasted following filter (based on documentation exapmle):

“Filters {
temp_sanity : 0 427 K
}”

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 “K” to “C” and so on. When not using units of measure I get a following error in log:

Cannot compare 6.71875 °C to range 0 - 427

Any advise? I am struggling with wrong readings and the persistance/filter solution looks most promising and elegant.

Use code fences to post what you’ve done. The forum mangles code so it’s impossible to see what the filter actually is.

```
code goes here
```

Posting the full file is probably going to be needed because the error is a syntax error and the error may be elsewhere an not be a part of this small part of the config file.

The part of the code resposible for the error is:

Filters {
    temp_sanity : [] 0 427 K
}

The log points exactly to the line where “}” is. When I remove “K” it is OK but then oh doesn’t recognise item input which is Number:Temperature type. When I removed everything leaving just this portion of code, the error statement was just the same so I believe that the remaining part of the code is ok.

When I copied the example from the oh documentation webpage, the behaviour was exactly the same, so I believe that there is no error in my changes. Is it my implementation of oh (Ubuntu) or is it a bug?

Had the same in oh 4.3.2, it did not accept negative values as well. When I moved to oh 4.3.3 the negative values in the filter are accepted but still no units of measure. The same happens when I use °C or C as unit of measure.

:man_shrugging: You won’t show the full file so I can’t assess if there’s something else which migth cause the syntax error.

The code snippet looks correct in isolation. I guess file an issue.

Persistence does not handle UoM just raw numbers.
I guess this type of filter is just not implemented and isn’t going to be.

Then the docu is wrong, because there stands that unit numbers shoud be accepted…

Than this might be the answer. However:

  1. 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.

I used the example code in my oh implementation and the log error were just the same as when I used my code.

  1. When I use filter, which has no UoM stated, it compares the values of an item with UoM and says that they are uncomparable:
2025-02-28 09:06:48.916 [WARN ] [ence.filter.PersistenceIncludeFilter] - Cannot compare 5.03125 °C to range -100 - 200 

So there definitly is an unconsisancy in it.

At least in my case accepting UoM would be of a great help. Thank you for your support all.

My code is more thatn 500 lines long and it works without UoM, so I guess there is no point in pasting it here. I checked with the example code instead and it showes the same error codes.

Probably only the developer who implemented it can explain or fix.
Open an Github issue with openhab-addons repo.

Before, also check if this is only with your database. jdbc is rarely used.

OK, how do I do that:

  1. Check if it is only my database - I use jdbc with mariadb. I have been using it for years and it works just fine apart of the issue reported above
  2. Open an Github issue with openhab-addons repo.

Thanks for support.

1 just add rrd4j as your secondary db, use same filters
2 GitHub · Where software is built → new issue
mind the title use [addon-name] xxxx

Checked with the same settings with rrd4j - same errors, so it is probably not persisance type issue… I will open a github request/notification then.

It might be a openhab-core issue then rather than openhab-addons. Not sure but probably better to open the issue there.

Issue opened: [persistance] Persistance filter not accepting units of measure · Issue #18339 · openhab/openhab-addons · GitHub