i am using the openHAB 3.3 Version with a HTTP-Binding to read out data from a HTML page with x-path.
Now i read in the value 123 rpm. But now i cannot declare this in the Channel as “Number” because it contains not only the 123 rather also rpm. Now the question if there is a possibility to remove all except numbers from the read in x-path?
Can anybody helps me? if i define the x-path as “String” all working fine. when i define as “number” i get NULL back.
The you should be getting a reasonable error in the logs indicating why it didn’t work. Number:Frequency explicitly supports rpm as a unit.
There are XPath testers online. You can experiment there. The intricacies of XPath syntax and usage is outside the scope of this forum. Few if any of us are experts on XPath.
For the most part, screen shots are useless to us. Please click on the code tab and paste what you find there when trying to show what you’ve done.
But like I said above, you can chain transformations so chain youer XPath to a REGEX (something like REGEX:(.*) rpm should work assuming the XPath is returning what you think it is).
You will have to look openhab.log on the machine where openHAB is running or, if you have openHABian, Frontail in the browser. Errors are not going to appear in the Developer Sidebar.
Thank you @rlkoshak but nothing with Maico or the Channel will be logged.
I have much other logs from my other components, but no log for the changed channel.
maybe OH 3.3 its too old? how i can maybe enable debug logging? did you have another idea how i can check the log why this happenes?
The one and only what i see in the logs when i change it from string to number.frequency, this (and then no update happens until i change it back to string):
2023-12-20 20:15:27.747 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Maico_WS320KB_DrehzahlAb' changed from NULL to 787 rpm
2023-12-20 20:15:41.810 [INFO ] [openhab.event.ItemUpdatedEvent ] - Item 'Maico_WS320KB_DrehzahlAb' has been updated.
here then after the last line, no update in log appears. and in web interface i only see NULL.
when i change back, then its updating correct with the value and rpm.
You should see an error when a message is processed and passed to the Item along the lines of “Failed to update Item BlahBlahBlah 123 rpm is not a valid state for a Number Item” if the problem is the data being passed to the Item. If not, the problem isn’t the Item type but the value being returned by the transform.
If I recall, rpm was a more recent addition to the UoM lists. OH 3.3 (which is pretty old at this point) might be too old to support rpm as a unit.
As for getting just the value, XPath does have some basic string functions you should be able to use (search for substring-before I think it’s called), but personally I would fine it quicker and easier to use regex instead of xpath in this situation.
The default conversion the framework will use is locale-based: The framework tries to convert a QuantityType to the default unit of the configured locale.
This means that the units used by an Item, without the unit metadata is the system default. For many units that default depends on your region but others are not specific to regions and something needs to be the default. Apparently Hz is the default for Frequency (that makes some sense, Hz is likely to be more commonly used in a home automation context than rpm).