Problems with sending humidity from OH3 to KNX

Hello all,

I was trying to solve this by myself for three days.
I looked into many forums, but there is much old information about OH2 and KNX1 binding which does not work here.

I am running the latest stable of OH3 on a Raspi-4 on Raspbian 11 (Debian).

Use-case: I want to use the outdoor humidity information from OpenWeatherMap binding and send this to the KNX bus (using knx(2) binding). It shall be displayed as status value (object 122/123) on the MDT Glastaster II Smart. The MDT status value requires DPT 9.007.

KNX-Things:

Type number-control : GT2info_120_outfeuchte "Außenfeuchte von OpenWeatherMap"   [ ga="9.007:7/3/248" ]

Items:

Number:Dimensionless    localCurrentHumidity                        "Current atmospheric humidity [%d %unit%]"             <humidity>       (gOpenWeatherMap)    {channel="openweathermap:weather-and-forecast:api:local:current#humidity"}
Dimmer                  KNXlocalCurrentHumidity                     "Außenfeuchte [%.1f %%]"                               <humidity>                            {channel="knx:device:bridge:knx_virtual:GT2info_120_outfeuchte"}

Rule:

rule "myrule"
when
    Time cron "0/10 * * ? * * *" //for testing purposes only in 10 intervals
then
        KNXlocalCurrentHumidity.sendCommand((localCurrentHumidity.state as Number).doubleValue)
end

ETS group monitor is running but nothing receives on the BUS from OH3.
I do not paste the full config, as this is working for temperature in similar way, so in general the config is fine.

Where I am confused is: Do I need to use Item type Dimmer or Number.
For the Thing, so I need to use number-control or dimmer-control.
Others wrote I shall use 5.001 instead of 9.007.
And with the rule I am also not sure, if the conversion is fine.
According to KNX documentation 9.007 shall be in F16 format, what as I double data type in my pov.
I tried all combinations, but it’s not working.

When I add this to the rule:

logInfo ("knx.rules", localCurrentHumidity.state.toString)

I get this output:

2022-11-24 08:04:10.630 [INFO ] [.openhab.core.model.script.knx.rules] - 88 %

My event.log shows the following:

2022-11-24 08:04:30.371 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'KNXlocalCurrentHumidity' received command 88.0
2022-11-24 08:04:30.375 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'KNXlocalCurrentHumidity' predicted to become 88.0
2022-11-24 08:04:40.370 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'KNXlocalCurrentHumidity' received command 88.0
2022-11-24 08:04:40.373 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'KNXlocalCurrentHumidity' predicted to become 88.0

So I really assume this is something with data type conversion…

Many thanks for any help on this …

Best Regards,
Divi

Not taking account of units

includes how-to extract numeric value in given units

Thanks for your links!
Unfortunately there is no QuantityType for Humidity existing, but I will try to play around ti understand how QH3 works internally.
Maybe I find the solution.

Thats correct. Other things also use %, dB, ppm, etc., all ratios. The appropriate type is Dimensionless - this is mentioned in the post I linked to.

You can inspect your Item type to see what Quantity it represents, your humidity should be Number:Dimensionless

More -

Many thanks rossko57.

I enabled debug logging for KNX Binding and see now more as well.

2022-11-25 07:58:13.179 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '94 %' of type 'QuantityType'

So even 94% is correct, this is not a value/format KNX binding accepts.

After changing the item back from Number:Dimensionless to Number, and using the thing number-control I get these warnings:

2022-11-25 08:07:30.695 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '94.0' of type 'DecimalType'

When I further change the item to Dimmer I am very close to what I need:

2022-11-25 08:02:20.736 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '0.94000000' of type 'DecimalType'

When try to send this value to the KNX-Bus from ETS I get an error.
It must be in the format 0,94000000 but not 0.94000000.
So now it also comes to localization…

I am running the raspi-4 as well OH3 with German locale, thus I am wondered why this is still not correct format.

I tried to work with this replace function but it does not work so far:

KNXlocalCurrentHumidity.sendCommand((localCurrentHumidity.state as QuantityType<Number>).doubleValue.replace(',','.'))

leads to

2022-11-25 08:20:50.888 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'knx-2' failed: 'replace' is not a member of 'double'; line 48, column 45, length 81 in knx

I tried this (I found in google) as well, but seems this is not OH3/KNX2 format:

KNXlocalCurrentHumidity.sendCommand(Float::parseFloat(String::format("%s",localCurrentHumidity.state).replace(',','.')))

leads to

2022-11-25 08:18:50.389 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'knx-2' failed: For input string: "94 %" in knx

Keep you posted!
Really annoying that you need to be a real developer to be able to make simple things in OH3…

That’s correct. I addressed your rule problem. I did not notice that for some reason you linked a Dimmer type Item to a number type KNX channel. I have no idea why.

Have you tried leaving your “input” Item as Number:Dimensionless, accepting data from weather binding, having your rule derive the “plain number” value and updating your intermediate Item, but having the intermediate Item as a Number Item.

i know it sounds correct but dimmer is not the way to go. use number for the channel knx like 9.001:<1/2/3