Hey, I’m trying to find any way to change DateTime format.
In OH2 it was easy way. only changing it in item label.
But now I’m getting DateTime as
2020-11-18T20:16:12.306+0100
And now it is stored like this.
How to change it so it will be stored like before in OH2?
[%1$td.%1$tm.%1$tY, %1$tH:%1$tM] - this works only in sitemap label.
Same thing is with units of any kind of item.
For example:
Energy produced by PV panels from inverter. It is sending data as “Wh”. But normal is “kWh”.
Now it is persisitng data with this new unit and because of this charts in grafana are not accurate.
Other thing is that some of temp sensors sent data without unit.
In OH2 whe You add unit do item label it saved it to persistance.
Now it is without unit…
I think that it is possible to change this everything by using transformations.
But how?
I have tried to use JS transformations but they are not working at all…
In new UI there is something like “State description” for Item.
And there is option called “Pattern”.
There You can put format like %1$td.%1$tm.%1$tY, %1$tH:%1$tM or like %.2f kWh
I struggle with a similar issue.
I have a number item for which I want to turn the sign, when showing in a widget.
But I also want to add the UoM and set the pattern to %,.0f.
I manage to do only either or, i.e. either turn the sign directly in the widget with using the .state, or show the right format with .displayState but then with the wrong sign.
How can I manipulate the format directly in the widget?
Sure.
Item.state: -1966,73
I applied this pattern in the metadata of the item: %,.0f W
Which results in:
Item.displayState: -1 966.73 W
But what I want to see is: 1 966.73 W
So usually I would multiply by -1 and then apply the format.
I think one approach would be -
get the state
multiply by -1
use a javascript (not java) formatter
then get the displayState
strip out the unit
append the unit to the format from earlier