the String contains a number but with a comma instead of a decimal point , e.g. “12,2”
Is there a way to use the channel with a number item and transform the string to “12.2” ?
Are you using OH3?
This method won’t work in OH2 - use a transform profile on the Item-channel link to substitute “.” for “,”, probably a REGEX. See if it works on a String, then use on Number type Item. Add units if you like for a Number:Quantity type.
Yes, that is exactly what the state presentation part in the is for. Giving a modified display without altering the real Item state. https://www.openhab.org/docs/configuration/items.html#label
This is neither a profile nor a channel based transformation.
I suggested either using a transform profile
which in OH3 will allow you to marry a channel to a different Item type
or
use a channel transformation in your binding setup
Thanks. I tried that but so far no luck.
OH Regex behaves very special. I do manage to get get the number from the html page but replace does not work. At least not as it is described in the link above.
Yes, it is “greedy” and you have to match the whole string, which usually involves * at either end…
I don’t know much about regex at all, I don’t know if you can construct one expression to both select your field and replace the comma.
But you are allowed to chain transforms in HTTP binding -
so you can do it two steps with magic character ∩ like
as item transformation seems pretty straight forward, it is not working on my end. Neither does it work when I use ∩ to add a second RegEx to the channel. It seems like I miss some crucial detail when it comes to the replace function.
Do you know if I need to place any parenthesis () like it is required for the RegEx capture ? Or match the whole string ? Not that I have not tried that…
There’s some glitch where editing profiles does not take immediate effect. Seeing as you have been editing, try to rule this out.
Create a brand new String Item, link to same http channel with profile.
Note that ‘caching’ of profiles postponing immediate effects of edits should be fixed in >OH3.0
Thing edits can be more or less dynamic, very much depending on each binding. Small edits to polling services (like http) may be especially problematic. General advice is to restart the binding bundle in case of a Thing edit apparently being ignored.