KNX invert status

Hi,
I need to invert a KNX status in HA. I am using a KNX switch and I already tried to solve this with ETS using a logic gate, but it didn’t work. Basically, the light status is 1 and I need to HA shows it to 0.
Any idea to solve this?

Use a template switch or binary sensor


How can I invert the status using the template switch? Thanks

Do you want to invert the switch, or the status of a sensor?

  • I have an output of an knx actuator connected to a NC Relay that is controlling an oven.
    So when the output is on the relay is off and when the output is off the relay is on.
  • I imported this output to homekit using HA as a switch, but the status is inverted.
    That’s the real case scenario.

You should use a binary sensor to report the (inverted) status:

binary_sensor:
  - platform: knx
    name: Entity ID from knx
    state_address: 'x/y/z'
  - platform: template
    sensors:
      oven_inverted_status:
        friendly_name: "Oven"
        value_template: >-
          {{ is_state('binary_sensor.entity_id_from_knx', 'off') }}

And how can I link that with homekit switch ?

Sorry, my bad. You should indeed have a switch instead like this:

switch:
  - platform: knx
    name: Oven relay switch
    state_address: 'x/y/z'

  - platform: template
    switches:
      oven:
        value_template: "{{ is_state('switch.oven_relay_switch', 'off') }}"
        turn_on:
          service: switch.turn_off
          data:
            entity_id: switch.oven_relay_switch
        turn_off:
          service: switch.turn_on
          data:
            entity_id: switch.oven_relay_switch

homekit:

It will automatically appear in your Homekit if there is no filter or anything set…

I will give it a try, thanks mate :sunglasses:

Solved, using @Cadish solution.
Many thanks again

1 Like