openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[KNX2] wrong value for DPT 9.007 #3408

Closed pdcemulator closed 6 years ago

pdcemulator commented 6 years ago

Hello,

I am using items with DPT 9.007 (relative humidity in %).

Expected Behavior

value of 44% is shown as 44%

Current Behavior

value of 44% is shown as 0.44%

Possible Solution

?

Steps to Reproduce (for Bugs)

In OH1 I used Number Hum_rel "Luftfeuchte rel. [%.1f %%]" <humidity> (gHumidity) knx="5.001:<5/2/4"}

In OH2 Type number : Hum_rel [ ga="5.001:<5/2/4" ] Number Hum_rel "Luftfeuchte rel. [%.2f %%]" <humidity> (gHumidity,) #{channel="knx:device:bridge:wg:Hum_rel"}

Without DPT or even 9.007 in channel config I get en error.

ETS capture, DPT is shown as 5.001, value is 44% capture

Your Environment

sjsf commented 6 years ago

The root-cause is that the KNXCoreTypeMapper (correctly) creates a PercentType state for DPT 5.001 but the number channel type has a preference for DecimalType, therefore it gets converted to the 0.x format.

The binding is clearly missing a "percent" channel or the like.

For the record: As a workaround - until this is fixed - you may use a Dimmer item as @MichaelFink pointed out here. It prefers PercentType and therefore the value gets converted back to the notation everybody would expect.

lewie commented 6 years ago

@sjka, DPT 9.007 is NOT correctly mapped to DecimalType.class in KNXCoreTypeMapper.java at the moment. I overlooked the last correction: Therefore this PR.