Hello everyone,
im configuring the display of my solar roof plant. I got several NUMBER and STRING typed items with some beeing just pure NUMBER and other beeing NUMBER:ENERGY. Reading the values makes most of them show in Watt which reads a biiiiig number if you are looking up daily production e.g… So i would rather like it to convert to showing in KWh but dont know how…
my original item looks like this:
Number Production "Produktion [%.2s kWh]" <solarplant> (gSolaranlage){channel="solaredge:generic:cb124819:live#production"}
I am totally overwhelmed understanding the Java formatter calss syntax, perhaps someone has a useful link for a self tutorial?
Yes, i saw that. But when changing the item to Number:Power Number:Power Production "Produktion [%.2s %unit%]" <solarplant> (gSolaranlage){channel="solaredge:generic:cb124819:live#production"}
i get an error report of Eclipse SmartHome Designer:
reading carefully your provided links i think i might be missing the " Defining ChannelTypes" but dont know if i have to define them manually (and where) or if it is provided by the channel itsself automatically.
VSCode with openHAB extension is the current file editing tool.
For your original problem, once you’ve got the correct Item type, just give the (appropriate type of) units that you want in the [state presentation] part of the label, e.g. kW, and it will auto convert for display.
thanks for that. i managed the transformation process, not too difficult.
I ran through a problem with the Java formatter class syntax nevertheless. i am unsure what values to use in the [] brackets and cant find out the differences between %s, %f and so on… the help page isnt too useful. And what does number:dimensionless mean?
The java formatter is well documented all over the web. No idea which “help page” you are looking at.
%s is simple enough, “show me the string”. Transformation services always return strings so that’s all you need in this context. If you need to prettily some transform result you need to it in the transform itself.
Number:Dimensionless is a Quantity Type without dimensions. But it does have units. What? Think of ratio or proportions. Commonly we use units of % or db for quantities like that.
For one that’s one version too old for OH 2.5. Those are the Java 7 docs and you need the Java 8 docs. https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#syntax But I suspect there isn’t anything significantly different between the two in this case, paying attention to that sort of thing will save you a ton of grief in the long run.
As for how to read it, scroll down to the relevant section to find the right flag. Then search the internet for examples using that flag.