Multiple representations of an Item's value

I’ve got a battery that I’m monitoring and want to do some basic stuff with.

Currently, I receive the voltage via MQTT and have it displayed on dashboards. I noticed that when I display the battery’s voltage (12V lead acid battery, so ~13V), I get a red, empty indicator, so I transformed this to a percentage. This isn’t quite what I want, though.

I’ve got the following item configs:

Number Gate_Battery_Level "Battery [%.0f%%]" <battery> (Gate, oroBattery, TimeoutGroup) {mqtt="<[eve:oro/gate/reading:state:JS(12v.js)]", expire="4h"}
Number Gate_Voltage "Battery [%.2fV]" <battery> (Gate) {mqtt="<[eve:oro/gate/reading:state:default]", expire="4h"}

Ideally, I’d like to see and use percentage for my alerting rule and battery icon, but display the voltage. Is something like this possible?

Bonus question: If I can’t have an item label and “value” be separate concepts, can I define an item’s value in terms of another item? i.e., instead of using the same mqtt source in both cases, get the raw reading once, and then just use Gate_Voltage to define Gate_Battery_Level?

So what you are really asking for is to show two Items on one line, and sadly that is not possible. There is a work around that is feasible when you only have two or three alternatives (e.g. a garage door with a button that says “Open” when the door is closed and “Close” when the door is open) but it is not really feasible when you have 10 versions of the icon like you would with the battery icon.

The icon is based on the state of the Item. So if your Item is representing voltage, that value is what will drive the icon. You can’t have the voltage shown in the label but the state of the level Item drive the icon.

I can understand that, but it seems like unnecessarily tight coupling. Perhaps being able to add transformations for different display mechanisms would be beneficial here. i.e., just later binding of transformations.

I guess this question forks out a bit, then if you don’t mind.

  1. Can I use dynamic icons named with voltage ranges? e.g.,
    a. If so, where do I find the current icon set, because it seems pretty good for my needs.
  2. Can I derive the Gate_Battery_Level item’s value from Gate_Voltage rather than mqtt?
  1. https://www.openhab.org/docs/configuration/items.html#item-definition-and-syntax and https://www.openhab.org/docs/configuration/iconsets/classic/#icons

  2. Voltage is mostly independent from the battery level. You cannot derive one from the other.

I’ve read the Item and icons docs, but I can’t find the actual files. E.g., the various battery levels that are being shown. I can reuse the same icons, but I can’t find them on my actual system. Should I be able to find them on my filesystem somewhere?

Voltage must be derivable from battery level, as it’s the only value I have, so I’m mapping it to a reasonable percentage based on data sheets and observations to determine the charge level of a deep cycle backup battery that’s sitting on charger. Desirable voltage ranges are mapped to 0%-100% (where 0% is the lowest possible tolerable voltage and 100% is the highest it should generally get based on the charging setup).

The actual item configuration I’ve shown is using the same mqtt input for both. I’m just asking if I can receive the value from mqtt as Gate_Voltage and then reuse that item instead of having two things watching the same value (or a rule, I guess).

They are buried inside one of the .kar files somewhere in the OH install. I’m not sure where. They used to be all there on the icons page and you could just right click and download. I guess not anymore?

Just change the label config with a different transform. But be aware that the icon will be chosen based on the state of the Item, not the transformed value in the label. If you need to do some math then use the JS transform.