Sending Temperature from OH3 (openweather) to KNX

Hi everyone,

I am trying to send the current outside temperature to my KNX bus.

in my KNX binding I’ve created the item and connected it to a group address. This works well. If I write a number to the BUS, it is received on OH3:

UID: knx:device:2d31fe47b2:cd60c6c358
label: KNX Device - openHAB
thingTypeUID: knx:device
configuration:
  pingInterval: 600
  address: 1.2.4
  readInterval: 0
  fetch: false
bridgeUID: knx:ip:2d31fe47b2
channels:
  - id: Aussentemperatur2
    channelTypeUID: knx:number ##edit: original post said number-control but this is now the correct code
    label: Außentemperatur (to KNX)
    description: ""
    configuration:
      ga: 9.001:12/2/0

I’ve created a script to update the corresponding item of the channel based on the openweather item.

var KNX_AT = OneCallAPIWeatherandForecast_Aussentemperatur.state as Number
KNXDeviceopenHAB_AussentemperaturtoKNX.postUpdate(KNX_AT)

This updates the item on openhab with the correct value, but I don’t get anything on the BUS.

When I run the following script as a test, I get both the item and the KNX updated.

KNXDeviceopenHAB_AussentemperaturtoKNX.postUpdate(20)

I’ve been trying to change the definition of the Variable, but I couldn’t find any setting that would help.

Thank you for your help!
MA

Pay attention to the difference between an update and a command. Rules | openHAB. Updates remain within OH and don’t go out to the devices.

Neither one of your examples should have worked. The fact that you saw the 20 on the KNX Bus is in fact an error/bug and should not have happened.

In truth, KNX xxx-control type channels are “special”, and work in reverse.
Messages from KNX are passed to openHAB as commands, Item state changes are passed to KNX.

It’s meant for use with e.g. glass control panel not an actuator, and mimics the way a GUI works.

Does it, may we see your events.log of that update?
There is scope here for you to post units that the binding won’t like.

Here is what I get in events.log when I run the command:

KNXDeviceopenHAB_AussentemperaturtoKNX.postUpdate(122)
2021-12-16 18:49:33.511 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'KNXDeviceopenHAB_AussentemperaturtoKNX' changed from 7.36 °C to 122

This updates my value on my KNX bus

If I use the value from openweather:

var KNX_AT = OneCallAPIWeatherandForecast_Aussentemperatur.state as Number
KNXDeviceopenHAB_AussentemperaturtoKNX.postUpdate(KNX_AT)
2021-12-16 18:50:45.919 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'KNXDeviceopenHAB_AussentemperaturtoKNX' changed from 122 to 7.36 °C

This does not update on KNX. So I understand I need to remove the °C. How can I do that?

Also, on a sidenote, the correct configuration is using number and not number-control to get the temperature to be updated on KNX.

UID: knx:device:2d31fe47b2:cd60c6c358
label: KNX Device - openHAB
thingTypeUID: knx:device
configuration:
  pingInterval: 600
  address: 1.2.4
  readInterval: 0
  fetch: false
bridgeUID: knx:ip:2d31fe47b2
channels:
  - id: Aussentemperatur2
    channelTypeUID: knx:number
    label: Außentemperatur (to KNX)
    description: ""
    configuration:
      ga: 9.001:12/2/0

Thank you to everyone who chipped in (here and sharing their solutions in other threads)
.
I managed to get this to work by setting the openweather source item to Number:Dimensionless.

Don’t do that, you are storing up trouble. Number:Dimensionless is not “just a number”, it is a ratio like 95% or 15dB or 3-to-1. It is a Quantity, with units. That ‘1’ ratio has a magic property of being invisible, but this is not a regular number.

Openweather wants you to use a Number:Temperature, with units, so do that.

As you have for some reason changed your KNX channel type, you’ll need to send a command not a postUpdate.
Beware that small Thing edits may not be acted on until the next binding restart.

So to adapt your original rule -

var KNX_AT = (OneCallAPIWeatherandForecast_Aussentemperatur.state as QuantityType<Temperature>).toUnit("°C").toBigDecimal
KNXDeviceopenHAB_AussentemperaturtoKNX.sendCommand(KNX_AT)
1 Like

Thank you very much!