I’m adding an enhancement to the tesla binding to report distance to travel to the destination.
The distance is reported by the upstream API as miles, though. I would like to properly annotate this with an unit and keep also the SI unit (kilometers in this case) in the item. The channel configuration is as follows
<channel id="ar_destination" typeId="ar_destination"/>
<label>Distance to arrival</label>
<description>Distance to drive to the destination</description>
<state pattern="%.1f %unit%" readOnly="true"></state>
How would I go about converting the incoming data? Simply multiplying the number 1.6 does not feel like the proper way to go.
Binding can report data as-is, the conversion is done above it. It means that all you need to do is pushing QuantityType using miles. Then, user can define which unit he wants to use through system configuration.