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

Thanks for some hints.

I tried everything, no success.
localCurrentHumidity is Number:Dimensionless as per documentation on the OH3 web site.

Item:

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

Thing:

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

Error in KNX-Debug Log:

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

I also tried to remove (on the Thing) the KNX data type, so no 9.007. Exactly the same error message.
OH cache was cleared, even services restarted. No change.
I found a bunch of requests in GitHub for 9.007 and KNX Binding, so maybe this also somehow a bug.

Your issue might be related to using a control channel without using the Follow profile, but sending a command to it.
From my knowledge when sending a command to the virtual item it will be converted to an update and vice versa. Thus nothing is written to the but as your command results in an update.

  • Use knx:number-control as you knx channel definition. The state/value is not owned by knx but by OH. This is what you have done, fine.
  • Now link your OW humidity item to the knx channel (you already have the item linked to the corresponding OW Thing channel, don’t change that)
  • Link your knx item to the same knx channel but make sure you select the “Follow” profile
  • This allows you to get rid of the rule coding, disable it

Now the flow would be like this:

  • OW item gets an update through the OW channel
  • As the item is linked to your virtual knx device control-channel this channel receives an update. This update is posted as a command to the knx item linked to the same channel due to the “follow” profile.

The result should be that the value is written to the bus without any coding involved.

Example from my system:
I receive the outdoor temperature through MQTT from by Junkers heating. So there is an item linked to the mqtt Things channel.
The virtual device has a number-control channel.
It has linked its “own” knx item by follow profile and in addition the item linked to mqtt.
The “knx item” then provides the incoming values to the bus where my “Glastaster Smart II” receives it as the temperature value.

Advantage:

  • No cron rule required (This value does not change that often, so you do not flood the knx bus)
  • Ensures I have no annoying conversion issues in coding
  • Updates whenever the outdoor temperature changes

Maybe give it a try.

`

I think the problem with that will be where we came in - the OW Item is (correctly) a Quantity type Number:Dimensionless with units, % as it happens.
KNX channels did not deal with Quantities properly in the past, so a rule and proxy Item can be used to extract a numeric-only version for state. (I don’t know if that has changed at all or in part)

Yes, “Dimensionless” could be the cause.
In my above example the source item is a “Number:Temperature” which is handled properly.
But still I doubt that sending a command to a number-control results in data being written to the bus as the logic for that is reversed. “postUpdate” instead of “sendCommand” might be worth a try here.

I fully agree. However unless autoupdate is disabled it would usually result in an Item state change, which in its turn should be transmitted by xxx.control channel.
The error messages back up the theory that is trying to send ‘something’, but doesn’t like the shape of the something.

The amended rule got rid of the % problem, but there is more to it than just that.

Many thanks for all your ideas.

I tried it with the follow profile as well:

Number    localCurrentHumidity                        "Current atmospheric humidity [%d %unit%]"             <humidity>       (gOpenWeatherMap)    {channel="openweathermap:weather-and-forecast:api:local:current#humidity"[profile="follow"], channel="knx:device:bridge:knx_virtual:GT2info_120_outfeuchte"[profile="follow"]}

When I press read in group monitor in ETS for GA 7/3/248 I see the same in the logs:

2022-11-30 15:09:01.309 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '79' of type 'DecimalType'

When I use switch the item from Number to Number:Dimensionless (OH default for this attribute):

Number:Dimensionless    localCurrentHumidity                        "Current atmospheric humidity [%d %unit%]"             <humidity>       (gOpenWeatherMap)    {channel="openweathermap:weather-and-forecast:api:local:current#humidity"[profile="follow"], channel="knx:device:bridge:knx_virtual:GT2info_120_outfeuchte"[profile="follow"]}
2022-11-30 15:12:33.919 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '79 %' of type 'QuantityType'

I have removed the follow profile again.
So I think a rule is required (for conversion), but unclear from what to what.
The cool thing with the follow profile would be, that I can really trigger to read the object from the KNX bus!

postUpdate & sendCommand make no difference. It’s triggered.

So I switched back to my normal config, this would stay:

Number:Dimensionless localCurrentHumidity
Number KNXlocalCurrentHumidity
KNX-Thing : number-control, group adress format ga=“9.007:7/3/248”
Rule: KNXlocalCurrentHumidity.sendCommand((localCurrentHumidity.state as Number).doubleValue)

Error with that:

2022-11-30 15:16:10.699 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '79.0' of type 'DecimalType'

I checked the GitHub bug reports and found this:
[KNX2] KNX DPT 9.007 is not supported · Issue #3416 · openhab/openhab-addons · GitHub but seems 9.007 DPT is now supported.
[KNX] DPT 9.007 is wrongly reported · Issue #12922 · openhab/openhab-addons · GitHub
… shows the expected format would be 0.6 (what is shown as 60%).

So I changed my rule, that the value I have is divided by 100:

KNXlocalCurrentHumidity.sendCommand((((localCurrentHumidity.state as Number).doubleValue) / 100).doubleValue)

… but the problem does still exists:

2022-11-30 15:29:00.680 [DEBUG] [.internal.handler.DeviceThingHandler] - None of the configured GAs on channel 'knx:device:bridge:knx_virtual:GT2info_120_outfeuchte' could handle the command '0.79' of type 'DecimalType'

Might the problem related to the .doubleValue? As 9.007 DPT is maybe not a double?
Unbelievable…

Use 9.001 DPT istead 9.007.

You do not need the rules. Just try to connect your humidity items from UI.
There are some picture for my project for example. I get time from NTP and send it to KNX:


image