Is there a way to combine batteryvoltage as percentage and absolute value in one line?
I have an ESP measuring batteryvoltage and it sends that via 2 MQTT payloads as actual voltage as wel as percentage.
In Openhab I can easily display both by Number battery_garden "Batterij Tuin [%.1f V]" <battery> (Garden) {mqtt="<[mosquitto:home/garden/BatteryVoltage:state:default]"}
for the actual voltage and
Number batter_garden_pct "Battery tuin [%.0f %%]" <battery> (Garden) {mqtt="<[mosquitto:home/garden/batterpct:state:default]"}
for the percentage
In the first case however, the icon always shows the 'empty battery’
is there a way that I in ONE line can make the icon react to the percentage and the actual number the absolute value
That is the only way to combine Items but the problem is the icon is chosen by the state of the Item. The battery Icon needs to be used with a numerical state. If you combine the two you no longer have a numerical state.
You could theoretically make it work but you would have to create a version of the battery icon for every possible value for the combined percent and raw value that is possible.
According to Classic Icon Set there are battery icons for 0, 10, 20, … 90, 100 %, so eleven in total. In your sitemap using the visability parameter you could show the correct icon and hide the incorrect ones. This will then require a 11 similar lines in your sitemap of which only one is shown. So not exactly one line in your sitemap if that is what you meant with ONE. It will however show as one line in your GUI (e.g. Basic UI, Habdroid or the iOS app).