Switch vs. Button


I guess there is always an article about this, but i couldn’t find it.
On OH4 I deployed a knx gateway and a switch actor. Everything runs well. But for the stairway I’m using a (in german knx calls it: Treppenlicht), it means the light is switched on for a predefined time by an trigger-impulse.
If I deploy a switch as an item in OH, it always looks like turned on, when you use it, it doesn’t fall back after the light timing is over…

Any tips? - Previous post?

You want to set the expire metadata on the item that is connected to the switch.

A quick search for expire metadata should give you all the information you need.

Please don’t :slight_smile:

Instead, configure the actuator and openHAB the correct way.
Every knx actuator has different Communication Objects (CO, or in german KO - Kommunikationsobjekt), these are bound to Group Addresses (GA).
There is always a command CO and a state CO. You simply have to link both CO to different GA and set the knx channel to use both GA.
Please be aware that a state is always part of a single actuator channel, so if there is more than one channel involved, each channel has its own state, even if these channels are always switched at the same time.
Let’s assume there is a simple relay channel (like your stairways light):

CO | function | GA    | comment
 1 | command  | 1/1/1 | receives command to set relay
 2 | state    | 1/1/2 | sends state of relay

Now in openHAB, you’ll have to set the switch channel like that:

Type switch : ch1 "stairs" [ ga="1/1/1+<1/1/2" ]

This way, openHAB will send a command to 1/1/1, the actuator then will react to the command and will switch the light, after switching the actuator will send the new state to 1/1/2, which will be received by openHAB.
It’s best practice to setup the secondary GA to be read at startup (this is the <), so openHAB will actively ask the knx bus for the current state.
Furthermore, you should set linked Items to metadata autoupdate="false", this way the state of the Item will only be set through the state update.

thanks, that works fine…

Hi Udo,

is there anywhere a documentation of “how to”/“best practice” setup “Things” and “Items” of KNX-Devices?
Especialy by file (*.things / *.items)…


I’m not aware of any.

My two cents:
I’m using one file knx.things with the whole knx bus, each device is listed, even if a device has no channels at all (or no channels, which are exposed to openHAB), e.g. wall switches.
I tend to setup channels for all knx actuator channels, even if the channel is unused at the moment, but this is only my way to do it :slight_smile:

As I’m using VS Code to create my text configuration, I also build my Items directly in VS Code, therefor I have another file knx.items with all knx-only Items. There are some Items which overlap, e.g. ntp current date/time, as these items are to send date and time to knx and therefor share two channels:

DateTime Buszeit "Zeit und Tag" {channel="knx:device:bridge:Virtuell:wochenzeit",channel="ntp:ntp:local:dateTime"}

The corresponding channel is like that:

Type datetime-control : wochenzeit "Zeit und Tag"  [ ga="10.001:15/7/10" ]

and because it’s of type datetime-control, the channel will send all Item status updates to knx immediately :slight_smile: