How to switch Openhab items with KNX-Switch

Hi, i have some knx actors and wall switches which work very well with the openhab knx binding.

But i also have some other actors (controlled with mqtt-commands), which i want to switch on/off with a knx wall switch.

Can someone explain how i can combine this two worlds?

My first idea was to create a dummy-knx device in the knx-things-file.

Then i can connect this dummy GA (group adress) with the knx-wall-switch inside the ETS.

But how can i controll my MQTT-actor-channel with this? Do i have to use rules for this or can i add the code

channel = "knx:device:bridge:Lights:Light_1_J"

behind my mqtt-item?

This is my current mqtt-item:

Switch Light_relay_01    "Light [%s]"                 { channel="mqtt:topic:MosquittoBroker:dingtian_52670:ch1_on_off" }

Easy :slight_smile: you’ll need

  1. a knx thing for the wall switch
  2. a switch-control channel per switch (please be aware that you’ll need two GA send the state to the wall switch, the first GA is to send the state, the second GA is to receive the command from the wall switch)
  3. link both channels (the wall switch channel and the mqtt actuator channel) to the same Switch Item
Bridge knx:ip:bridge {
    Thing device GiraTSplus1 "TS2plus Flur"  {
        Type switch-control : light "Licht"       [ ga="4/0/2+4/0/3" ]
    }
}

Bridge mqtt:broker:mymqtt [...]{
    Thing topic sonoffB1 "Sonoff Basic" {
        Type switch : ch1 "Schalten" [ stateTopic= "switch/sonoff_b1/stat/POWER", commandTopic="switch/sonoff_b1/cmnd/POWER" ]
    }
}

Item:

Switch lightCorridor "Licht Flur" <light> {channel="knx:device:bridge:GiraTSplus1:light", channel="mqtt:topic:mymqtt:sonoffB1:ch1"}

The knx channel will receive the command via 4/0/3 (and also 4/0/2, but knx will never send on this GA). openHAB will send the state of the mqtt device via 4/0/2 to knx, so the indicator within the push button will show the state of the mqtt device.

I tried it with only one GA and i can switch the light with my knx wall switch. But i haven´t tried a led light to indicate.

So when i use the same GA for switching and status it will work in general but i don´t have the full features like i know in knx-only installations?

In my knx switch i entered the same GA into the switching field and into the status field (Rückmeldung). So this is not the correct way?

Well, it depends… :wink:
The correct setting in knx is, to use unique GA for different functionality.
Given a switch actuator with some CO, 1=switch command, 2=switch state, 3=scene…
and a wall switch with two buttons, each with only one CO.
The first button is used to toggle the actuator, the second button is used to send a central OFF command.
So we need three GA, e.g. 1/0/0 → switch light, 1/0/1 → state of light 2/0/0 → all OFF
You’ll have to configure the actuator as follows:
1 → GA 1/0/0,2/0/0 (so the actuator will receive commands via both GA)
2 → GA 1/0/1 (only the actuator is allowed to send the state)
And the wall switch
1 → GA 1/0/0,1/0/1, (toggle dependent of the current state)
2 → GA 2/0/0 , (send only OFF [0])

So the wall switch 1 will send 1 or 0, depending on its own state.
The actuator will receive the command and will send the new state
The switch will change its state to the real state of the actuator.
The wall switch 2 will send 0 which will result in switching off all linked actuators. The wall switch 1 will receive the new state and change its own state, so it will always send a 1 if the actuator is off.

If you want to use more than one wall switch (“Wechselschaltung”), just copy the configuration from the first wall switch, no additional GA needed.
All wall switches will be notified of changes, regardless if they were issued from another wall switch, from central OFF, or even from a scene command. Keep in mind that these are different GA, and some of them are not simple Bit GA, so you can’t link them to the wall switch, you’ll need the real state of the actuator.
For simple wall switches without any additional actuator link (only send commands to openHAB) you may get away with one GA.
If using an extra CO for the indicator, you will have to configure both COs with the same GA for state.

After a few days of using it like you explained, i have to say, that it is not working as it should.

I can switch the mqtt-relais for my light with openhab-webinterface and with the knx-wall-switch. But i tested it on different times the last few days and often i had to push the knx-switch twice the first time, to switch the light on. After that it works like it should do.

Do i have to add the “<” sign in the knx.things for the second ga (Rückmeldung)?

Now i have it his way like you described:

[ ga="4/0/2+4/0/3" ]

First ga is my switch ga and second ga is my status (Rückmeldung).

Should i connect the status-ga with a led for further investigations?

I flashed the application with ETS to the wall-switch a second time - do i have to put the switch twice for the first time after i did that or will the wall-switch read out the status-ga from openhab? On my knx-only installation, the switch can read out the status without any help - even after flashing it new.

No, the < marks the GA as readable, but knx isn’t the “owner” of the state.

I didn´t get it to work… The status ga lost its state every now and then - i don´t know why.

Now i use the knx switch as a dumb switch to only send a command to openhab and inside openhab i made a rule which does the job… Works 100% now.