MAP: Invert Channel to Item works, but not Item to Channel: missing a bidirectional map?

Hi, I have been working on some configuration involveing KNX.

I have an entity on the bus, that can be disabled, by a switch:
it is on, when the “switch” is off,
it is off, when the “switch” if on.

I tried to pass that to an item in OpenHAB such that switch is on, the device is off.
I have either a rule-base route, which would involve having two items in OpenHAB, one for the internal switch, and one for the inverted item on the bus.

Alternatively, I tried to use a MAP (and TRANSFORM:js) to invert the state of the item.

Here I noticed, that this is not bi-directional.
The state coming from the device is properly inverted, but any state coming from the item is not.

Is this the desired behavior, or is there something wrong with my config, or with OpenHAB?

I would apprechate any insights from the community.
For the time being, I can work arond with having multiple items, but that seems rather clumsy.

Sincerely, TLA

Updated title to more closely resemble text

If that’s the simplest way to preserve sanity, go for it. Items do not cost anything.

State coming from where, to where?
Are you meaning commands to the Item, that get passed by the binding to the mystery device? Some bindings allow you to manipulate these in your config.

Basically it is a KNX switch.
However, my interperation of the logic is inverted:
switch-state on → device is off
switch-state off → device is on

I would like to mirror the “interpretation” on the OpenHAB item.

Applying a map, does correctly invert group address write originating from the bus

  • from on to off, and
  • off to on
    in regards to the OpenHAB item.

However, switching the item in OpenHAB to on, results in an “on” group message, and switching the item off, results in an “off” message.

I would like to apply the map to inbound and outbound operations (or if I am not mistaken on the OpenHAB nomenclature to commands, and updates).


Yes, the command to the Item is passed as-is to the binding, for forwarding the device.
And that’s what you want, isn’t it - to set your device ‘inactive’ you have to send a command ON via KNX?
Some bindings provide a means to massage commands before processing - KNX does not.

It’s going to be easiest to have an Item representing the real KNX state, and a ‘virtual’ Item representing your logic condition (perhaps with autoupdate disabled)
A rule can listen for commands to your logical Item, and re-issue the inverted version to the KNX Item (with any conditions, if you wish).
You could update your logical Item state from a rule too (if you linked it to the KNX channel with the inverting map for updates, you’d get the unwanted side effect of passing ‘wrong’ commands as well)…

The standard transformation profile is, as you observe, one-way only affecting state updates. I thought someone had made an add-on switch invert profile that worked on commands too, but cannot find it now.

OK, so the MAP only operates in one direction: from the thing to the item.

I read it somewhere that it might be a good thing to have like an invert transformation, that works in-bound and out-bound.

For the time being, I will just create 12 rules to invert the state of the 12 devices.

Thanks for the feedback.

You should look into ways to do that with one rule, principles -

Look at invert profile ie. in smarthomej: Basic Profiles

1 Like