Percentage values interpreted inconsistently in OpenHAB sitemap and Alexa binding

Hi!
I’ve been experimenting with the Alexa skill on 4.3.3 for MQTT relayed information quite happily.
However, I seem to have hit an inconsistency in how the binding and OpenHAB itself deal with “Number:Dimensionless” or “Number” items that carry the “CurrentHumidity” (or any other) percentage, e.g. of an AirQualityMonitor device, such as a thermometer.

  1. OpenHab expects a range between 0 and 1 (matching 0% to 100%) to display a percentage properly (e.g. in a sitemap), but …
  2. the Alexa binding expects it to be between 0 and 100 to be properly transmitted to Alexa.

As a workaround I had to create 2 disctinct items, but thats probably not the proper or best solution…:

...
Group  gBresser1    "Bresser1" (gGarten)  ["Thermometer"] {alexa="AirQualityMonitor" [name="Gartenseite", description="Thermometer am Küchenfenster"]}
Number:Temperature   Bresser1_Outside_Temp "Bresser 1 Temperature  [%.1f %unit%]" <temperature>  (gBresser1,Outside_Temp_Avg) {alexa="CurrentTemperature", channel="mqtt:topic:openhab:bresser1:temp" [profile="transform:JS",toItemScript="significant.js"], expire="30m"}
Number:Dimensionless Bresser1_Outside_Humid "Bresser 1 Humidity [%.0f %%]"  <humidity> (gBresser1,Outside_Humid)    {channel="mqtt:topic:openhab:bresser1:humid" [profile="transform:JS",toItemScript="significant.js"], expire="30m" }
Number:Dimensionless Bresser1_Outside_Humid_Alexa  "Bresser 1 Humidity A [%.0f %%]"  <humidity> (gBresser1)    {alexa="CurrentHumidity", channel="mqtt:topic:openhab:bresser1:humid" [profile="transform:JS",toItemScript="significant.js?div=0.01"], expire="30m" }

(N.B. my significant.js script only does rounding and multiplying/dividing)

So now in case of an humidity of, e.g., 44% this puts 0.44 in Bresser1_Outside_Humid (displaying 44% in a sitemap) and 44 in Bresser1_Outside_Humid_Alexa , thus making Alexa answer 44%.

I hope that for this to be fixed, there is no braking change required, but still I’d really suggest to have that fixed since the inconsistency is hard to find out about at first, when making percentages available through the Alexa skill…
IMHO at least it should be immediately mentioned explicitly in the skill’s documentation in the section about CurrentHumidity
Or a percentage should be between 0 and 100 throughout OpenHAB, but then the display of percentages might need to be changed (and it seems wrong to me)…

What do you think? I created issue 18426 for tracking this: [alexa] Number:Dimensionless (percentage values) (from 0.0 to 1.0) should be multiplied by 100 before transmission to Alexa skill · Issue #18426 · openhab/openhab-addons · GitHub

Addition: another fix avoiding a breaking change might involve the introduction of a new Number:Percentage as a special variant of Number:Dimensionless ?

  1. BTW: to duplicate the problem in a sitemap define these two items:
Text item=Bresser1_Outside_Humid label="Nordseite Humid" // displays 44% for a value of 0.44
Text item=Bresser1_Outside_Humid_Alexa // diplays 4400% for a value of 44
  1. Another (non-breaking) fix that could be implemented within the Alexa binding:
    If the item is Number:Dimensionless AND if it’s display unit is “%%” (indicating a percentage),
    then multiply the number by 100 before passing it on to the Alexa API…

  2. The problem seems to hold for other Percentage types, too: E.g. BatteryLevel. The corresponding OpenHAB item (fed from MQTT in my case) must be 100 (instead of the given 1.0) to display 100% in Alexa.

  3. Checked: Could it be that the problem arises because the MQTT binding doesn’t feed a unit of “%” into the item? (I noticed that humidity values coming in from a weather bindings actually have “%” as a unit.) → No, a humidity value of 0,47 (from the weather binding) with a unit of “%” is also wrongly displayed as 0.47% in Alexa.