KNX Example for Openhab 3 with UI

i am coming from openhab v1.
I decided to do a new setup with openhab v3

i created a thing - the ip gateway to knx.
This appears online. But cannot add channels there.

So i added a KNX actuator (switch) and added there channels to switch the light on/off with group address 0.2.4 (this address is existing for switching the desired light on/off)

UID: knx:device:586ef8f359:caaf6a5c63
label: KNX Gerät Schaltaktor 12fach SA1
thingTypeUID: knx:device
configuration:
pingInterval: 600
address: 1.1.6
readInterval: 30
fetch: true
bridgeUID: knx:ip:586ef8f359
location: Schaltschrank
channels:

  • id: balken
    channelTypeUID: knx:switch
    label: Schalten Balken
    description: “”
    configuration:
    ga: 0.2.4
  • id: balkensteuer
    channelTypeUID: knx:switch-control
    label: Balken schalten Steuerung
    description: “”
    configuration:
    ga: 0.2.4

But this doesn`t work…
Is this the right way to add the KNX actuator this way?
Any other hints?

Thank a lot

Unfortunately I don’t use KNX so I can only offer generic advice.

  1. Use code fences. The code you see treats white space as meaningful (i.e. the indentations mean something). By using code fences you preserve the white space and the code (and logs) are easier to read.
    ```
    code goes here
    ```
  1. KNX is one of those few bindings where configuring the Things can be easier through files than it is through the UI. Once you do get this working you might consider that option.

  2. You’ve shown the Thing but not the Item. Show the Item configuration and how you are trying to command that Item.

Hmm :thinking:

The first obvious mistake is 0.2.4 should be 0/2/4 and all switch type should have also a status group adress and also why are using switch-control aswell ?

Example

- id: lights_wc_down
    channelTypeUID: knx:switch
    label: lights wc down
    description: null
    configuration:
      ga: 0/0/29+<0/0/30

If coming from openHAB1, it’s almost straight forward to change configuration to the v2-type.

  • openHAB1: There is a binding configuration section in the openhab.cfg file. This is about the connection to the bus.

  • openHAB2 ff: no more openhab.cfg, no section for this sort of configuration, instead, you have to create a “bridge” to the bus which will contain the configuration for the connection. The idea behind that is, you now are able to use more than one knx universe, as you can create more than one bridge.

  • openHAB1: you’ll configure the Group Addresses right in the item.

  • openHAB2 ff: you’ll have to create a Channel for each function, which itself are part of a Thing.
    The “Thing” is the equivalent to a real piece of hardware, let’s say an actuator.
    As openHAB1 was built around knx (well, at least sort of), an Item is really near the function of an knx actuator, and therefor the Thing channels are almost the same as the items, with some big differences :wink:

openHAB1, part of openhab.cfg:

################################ KNX Binding ##########################################
#
# KNX gateway IP address
# (optional, if serialPort or connection type 'ROUTER' is specified)
#knx:ip=

# KNX IP connection type. Could be either TUNNEL or ROUTER (optional, defaults to TUNNEL)
# Note: If you cannot get the ROUTER mode working (even if it claims it is connected), 
# use TUNNEL mode instead with setting both the ip of the KNX gateway and the localIp.
#knx:type=

# KNX gateway port (optional, defaults to 3671)
#knx:port=

# Local endpoint to specify the multicast interface, no port is used (optional)
#knx:localIp=

# Serial port of FT1.2 KNX interface (ignored, if ip is specified)
# Valid values are e.g. COM1 for Windows and /dev/ttyS0 or /dev/ttyUSB0 for Linux
#knx:serialPort=

# Pause in milliseconds between two read requests on the KNX bus during
# initialization (optional, defaults to 50)
#knx:pause=

# Timeout in milliseconds to wait for a response from the KNX bus (optional, 
# defaults to 10000)
#knx:timeout

# Number of read retries while initialization items from the KNX bus (optional,
# defaults to 3)
#knx:readRetries

# Seconds between connect retries when KNX link has been lost
# 0 means never retry, it will only reconnect on next write or read request
# Note: without periodic retries all events will be lost up to the next read/write
#       request
# (optional, default is 0)
#knx:autoReconnectPeriod=30

knx:ip=192.168.178.10      # the ip of the knx ip tunnel
knx:type=TUNNEL            # operation mode
knx:localIp=192.168.178.11 # the ip of openHAB itself

some random knx items:

Dimmer        Light_FF_Child1      "Licht Kind 1 [%d %%]"      {knx="<1/5/0, 1/5/1, 1/5/2+<1/5/3"}
Rollershutter Shutter_FF_Child1    "Rolladen Kind 1 [%s]"      {knx="1/4/0,1/4/1,1/4/2+<1/4/3"}
Number        Heat_FF_Child1_Is    "Temp ist Kind 1 [%.1f °C]" {knx="<9.001:1/7/0"}
Switch        Light_Garden         "Licht Garten [%s]"         {knx="0/4/0+<0/4/1"}
Number        Lux_Yard             "Helligkeit Hof [%.0f Lx]"  {knx="9.004:0/7/0"}
Contact       Gate_Yard            "Tor Hof [%s]"              {knx="<0/7/1"}

openHAB2 ff (in a file knx.things):

Bridge knx:ip:bridge "knx/IP Gateway" [
    ipAddress="192.168.178.10",
    type="TUNNEL",
    localIp="192.168.178.11"
] {
  Thing device dimmer1 "Dimmer REG 1.1.1" [ // a multi channel dimmer pack
    address="1.1.1"
  ] {
    Channels:
    Type dimmer : ch1 "Kind 1" [ switch="<1/5/0", position="1/5/2+<1/5/3" ]
  }
  Thing device rollladen1 "Rollladen REG 1.1.2" [ // a multi channel shutter actuator
    address="1.1.2"
  ] {
    Channels:
    Type rollershutter : ch1 "Kind 1" [ upDown="1/4/0", stopMove="1/4/1", position="1/4/2+<1/4/3" ]
  }
  Thing device rocker1 "Wandtaster 1.1.3" [ // a wall switch with heat control
    address="1.1.3"
  ] {
    Channels:
    Type number : temp "Temperatur Ist Kind1" [ ga="<9.001:1/7/0" ]
  }
  Thing device schalten1 "Schalten REG 1.1.4" [ // a multi channel switch actuator
    address="1.1.4"
  ] {
    Channels:
    Type switch : ch1 "Licht Garten" [ ga="0/4/0+<0/4/1" ]
  }
  Thing device sensor1 "Bewegungssensor Außen 1.1.5" [ // a motion sensor with luminance sensor
    address="1.1.5"
  ] {
    Channels:
    Type number : "Helligkeit Hof" [ ga="9.004:0/7/0" ]
  }
  Thing device binary1 "Binäreingänge REG 1.1.6" [ // a multi channel binary input
    address="1.1.6"
  ] {
    Channels:
    Type contact : ch1 "Hoftor" [ ga="<0/7/1" ]
  }
}

and the corresponding knx.items:

Dimmer        Light_FF_Child1      "Licht Kind 1"    {channel="knx:device:bridge:dimmer1:ch1"}
Rollershutter Shutter_FF_Child1    "Rolladen Kind 1" {channel="knx:device:bridge:rollladen1:ch1"}
Number        Heat_FF_Child1_Is    "Temp ist Kind 1" {channel="knx:device:bridge:rocker1:temp"}
Switch        Light_Garden         "Licht Garten"    {channel="knx:device:bridge:schalten1:ch1"}
Number        Lux_Yard             "Helligkeit Hof"  {channel="knx:device:bridge:sensor1:lux"}
Contact       Gate_Yard            "Tor Hof"         {channel="knx:device:bridge:binary1:ch1"}

openHAB4 knx is UoM aware, that is: openHAB will respect the exact DPT set to the Group Address, so you will get the Unit of Measurement. Just a little adjustment to the number Items:

Number:Temperature Heat_FF_Child1_Is "Temp ist Kind 1" {channel="knx:device:bridge:rocker1:temp", unit="°C", stateDescription=""[pattern="%.1f °C"]}
Number:Illuminance Lux_Yard          "Helligkeit Hof"  {channel="knx:device:bridge:sensor1:lux",  unit="lx", stateDescription=""[pattern="%.1f lx"]}

Now the items will use Units of Measurement and present the values with the correct unit.

As the code above is only an example, I’ve only created one channel per Thing.
In fact, you could create just one Thing for the whole bus (of course you then must not set the address of this virtual device). but the things are meant as a software equivalent for the real hardware devices, so best practice is to use one Thing per device.

1 Like