I am developing a binding and want to show a percentage value.
However, the value shows in the UI as a number between 0 and 1.
I have defined my item…
<channel-type id="airconditioner-zone-flow">
<item-type>Number</item-type>
<label>Zone AirFlow</label>
<description>The Zone Flow (percentage damper open).</description>
<category>Slider</category>
<state min="5" max="100" step="5" pattern="%d %%" readOnly="false"/>
</channel-type>
and set it in my handler…
updateState(new ChannelUID(channelGroupUID, CHANNELUID_AIRCONDITIONER_ZONE_FLOW),
new PercentType(zone.getOpenPercentage()));
The value returned from zone.getOpenPercentage()
is an integer between 0 and 100.
The data I get from the AC unit is whole numbers
ZoneStatus [messageType=ZONE_STATUS, openPercentage=50, powerstate=OFF, zoneNumber=3, controlMethod=TEMPERATURE_CONTROL, batteryLow=false, turboSupported=false, targetSetpoint=17, hasSensor=true, currentTemperature=16, spill=false]
When it shows in the UI it shows as 0.5 %
.
I am expecting it to show as 50 %
Looking at the items in the REST API, I can see the following…
{
"link": "http://openhab:8080/rest/items/AirTouch4_Zone_AirFlow__Fred",
"state": "0.5 %",
"stateDescription": {
"minimum": 5,
"maximum": 100,
"step": 5,
"pattern": "%d %%",
"readOnly": false,
"options": []
},
"editable": true,
"type": "Number:Dimensionless",
"name": "AirTouch4_Zone_AirFlow__Fred",
"label": "Zone AirFlow - Fred",
"category": "flow",
"tags": [
"OpenLevel",
"Opening"
],
"groupNames": [
"FirstFloor",
"FredBedroom"
]
},
How can I get OH to display the value correctly?
I don’t want my users to have to go and add rules or scripts just to render the values correctly.