KNX+Zigbee2MQTT via OH3

Hello,
I have recently extended my KNX based (and OH3-linked) home automation installation with a few zigbee based sensors and actuators (plugs mainly). Thanks to the help of the community (Sonoff Zigbee 3.0 USB Dongle Plus -- consensus on installation and use - #7 by hafniumzinc) I have successfully linked in the zigbee elements with zigbee2mqtt using a sonoff usb plus dongl. I can see the status of the sensors and switch the plugs from the openhab UI.

So far so good.

What I would like to do is to be able to link the knx and zigbee based elements… for example use a knx push button to toggle a zigbee-linked plug.

I have hence created a new KNX group address, and “virtual” thing in openhab, where a channel is connected to that KNX group address. I then link this channel to the item already linked to the zigbee-mqtt thing.
Unfortunately it doesn’t work.

Sending a knx telegram directly in the ETS Group monitor, actually does change the relevant (zigbee based) item:

2022-03-31 17:04:24.404 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'des3' changed from OFF to ON

However, the switching doesn’t take place.

If I change the same item in openhab UI directly, the switching does take place. (i.e. the zigbee plug is correctly linked into openhab)

2022-03-31 16:22:02.447 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'des3' received command ON
2022-03-31 16:22:02.451 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'des3' predicted to become ON
2022-03-31 16:22:02.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'des3' changed from OFF to ON

I have played around with the link profiles for the two links to the same item. (follow, normal), but to no avail.

Stuff coming from outside OH generally results in Item state changes.
Stuff that OH wants to happen is passed as Item commands.
Two different things (small t).

So what you want is for external KNX action to cause an openHAB command, the inverse of the usual arrangement.

Fortunately the KNX binding provides a means to do that with the xxx-control set of Thing types. Associate your external KNX device with one of those, link that to the Item that sends commands to the zigbee gubbins.

I glued e.g. zigbee wall switches under the dining room table as well as my office desktop to be able to control knx lights from the Boss chair :wink:, so the other way around (triggering e.g. knx actors from Zigbee) could work as follows :
Integrate your switch into z2m, create an mqtt item in OH linking the switches action (This is where e.g. my Tuya or IKEA switch is sending the payload) to 1…n channel(s).
In a rule trigger the action to take place on the item linked to one or more knx channels.
Required minor coding (or blockly) but is working fine for me.

Cheers, that works!

Is there a possibility, to include the zigbee thing (e.g. the smart plug), in a group created in KNX?

A group in knx is simply a set of devices listening to the same group address.
So if you want your ZigBee device to become part of the group you need to model a knx thing in OH with a channel linked to this group address and then link the zigbee channel to this knx channel.
This should do the trick.

No, these have nothing to do with each other, it is all going via Items in openHAB. KNX has no idea where its commands go to, Zigbee has no idea where they come from.

As you already know, an Item can be linked to more than one channel (and so on to external devices)
Maybe what you want can be achieved by linking an Item to the KNX xx-control channel and two Zigbee channels.

Got it to work in that direction with this approach. Thanks a lot.
Just a little write up on what I did …

0. Configure the Zigbee Thing + Item in openhab

a. Create a zigbee Thing (+channels) in openhab**


b. Create an openhab Item, representing the zigbee Thing’s function, e.g. switching state.

c. Link the zigbee item to the Thing’s relevant channel

In practice, you would do a. and then c., creating the Item on the fly.
This works for me to create a new zigbee item in open. I have added the zigbee device in zigbee2mqtt as homeassistant enabled devices. That way, they appear in openhab’s Thing Inbox. I have not managed to manually configure these zigbee2mqtt Things in openhab yet. but hey!

Little side questions: After adding the z2m Things, they remain in the Inbox. Is that normal? How to make openhab understand, they have already been taken care of?

1. Created KNX group addresses


In this example 1/0/64 SAL4 is the knx actuator based light, while 1/0/65 SAS5 refers to the zigbee based smart plug. In 1/0/69 SAL9 both are together in a group.

Little side question: is it good practice to define a dummy virtual device in KNX (how?) or do the GAs suffice. It looks actually a bit consufing in ETS, as SAS5 and SAL9 only seem to be linked to the push buttons, and nothing else …

2. Created one openhab Thing for all similar zigbee devices


This is the openhab equivalent of the ‘missing’ virtual KNX device (previous side question). It doesn’t have a KNX device address, but that doesn’t matter, apparently.

3. Created channels for every zigbee device (+groups)


These channels are created as ‘switch-control’ rather than ‘switch’ as per @rossko57’s advice above.

So in above example, there is one channel for the zigbee device (smart plug) referred to in KNX 1/0/65 SAS5, and another referring to the mixed (knx+zigbee) group.


Additional question: This structure works for me, but is this the way to go? Or can one have a single channel, which listen to both group addresses instead?

4. Link the KNX Thing channel(s) to the zigbee Item

With this approach, the direction KNX button/sensor to Zigbee actuator works. The Zigbee actuator can be combined in a mixed KNX+Zigbee actuator group and the KNX sensor can also be a KNX defined scenario.

Thanks for your help!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.