I have no spaces in itemnames. I forgot the underscore in my post.
The value is read from my boiler. It is dimensionless like “1034.5”. I have no idea how i could insert a “h” after the value.
Is there any chance to define this in itemdefinition or somewhere else?
I’m sorry, i thought i’m having Vitotronic binding in use.
But i “migrated” this to API calls.
So i am updating the item states with this curl:
curl -s -X PUT -H "Content-Type: text/plain" -d $value "http://localhost:8080/rest/items/"$item"/state"
So if the value from my boiler is in hours i only have to append an “h” to it? Same for pressure (add “bar” to it)?
What happens with the stored values in my influxdb? Will they be converted to openhab standard unit (e.g. hours to seconds) or will they remain as they are?
Yes, so long as they are recognised units. I think you need a space, e.g. complete string “1.25 bar”
“$value bar” maybe? I don’t know how that works.
No idea, they might get in a mess, changing current Item properties doesn’t work out well for historical data. Persistence only stores numerics, then reconstructs the Quantity value using current units,not the one that may have been in use when recorded.
Item “Vitocal_Betriebsstunden_Verdichter” is UoM Number:Time and MainUI displays unit “h”. Works perfect!
Item “Heizung_Betriebsstunden_Verdichter” is UOM Number:Time too but with the code above there is no unit displayed in MainUI. Is “deltaSince” dimensionless? If yes, how do i add the time dimension in my rule?
As already said, persistence only stores numbers and discards any units the Item state had at the moment of persisting.
It should reconstruct units at the time of retrieval, using your Item’s current default units. Does it have any? Usually you’d define that in a [state presentation] part of your Item definition.
Maybe that part is working - check your events.log to see what the Item is really getting updated to. MainUI seems to ignore state presentation sometimes.
What we need to know is exactly you define your problem Item.
The working items (which i am updating through API) are defined similar to this item. The difference is that i update them with unit “h”.
So i think i have to update the Item above with unit “h” also but i dont know how to do this within a rule.
Another item another question
I have a power meter which updates in Watts.
When i edit the stateDescription and change the Pattern from %.2f %unit%
to %.2f k%unit%
The unit is correctly displayed as “kW”. But the value is not recalulated.
When i use %.2f kW
The value is recalculated an correct.
So, how to add a prefix when using %unit%?
Sorry for the many questions… I’ve just updated to OH3 and i want to do it right.
and BTW: The state description does affec the persistence. When i remove “kW” values are stored as “W”. When i re-adding “kW” then the values are stored as “kW”.
This is a little bit confusing because i thought that they are always stored as the default unit for specific QuantityType.
You use the way that works.
If you want kW, then say kW.
Whatever units the Item state is currently in, get converted to kW.
There is no facility to specify k%unit% to get say kilo-horsepower.
That gets interpreted as text “k” plus whatever the current unit is.
That’s subtly different to
which is what I think goes on.
I believe what you are observing is that the state description is also used/abused by bindings to figure out how to update an Item.
(I say abuse because that isn’t a presentation function, but that’s what they do.)