Number:time with hour as Item value

Hi!

I have an Item named “Betriebsstunden Verdichter”.
This is a measurement of my Boiler.

I get the values of this Item as hours.
Item is defined as
Number:time.

I think openhab expects Seconds as Input for time calculations.
How do i Tell openhab that the value is hours Not seconds?

I have the same problem with Number:pressure. The values are in “bar” and i think oh3 expects “hPa”.

BR

How are you telling it?
If you were updating from a DSL rule, you might use
Betriebsstunden_Verdichter.postUpdate("3.5 h")

(note that spaces are not allowed in Item names, don’t confuse name with text label)

Thanks for your answer!

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?

What binding is in use here?

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.

Seems to work. Thanks!

Last Question

Heizung_Betriebsstunden_Verdichter.postUpdate(Vitocal_Betriebsstunden_Verdichter.deltaSince(start_of_day))

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.

In event.log the item is updated dimensionless.

Item is defined as followed (through MainUI):

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 :confused:

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.

yourItem.postUpdate( yourValue.toString + " h")

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

Understood!
Thanks for your help.

Little bit offtopic:
How can i add a map on an item through MainUI? Seems it is only possible on a link.
In items file i have an item:

String Garagentor_Status_L "Licht [MAP(garage.map):%s]"

but cannot rebuild this with MainUI.

There’s a fairly lengthy discourse here.

In OH2 the UI’s always honoured a transform in the Item’s label [state presentation] box.
MainUI does not,you have to tinker with metadata.

1 Like

Thanks for your help!