Connect HVAC to KNX Switch using expose

I had a KNX system that controlled lights, covers fans and HVAC. The KNX system operated independently for lights and covers with an AMX interface for automations, and a GUI. It also used the KNX Switch with an LCD Temp panel connected to AMX, which connected to a integration to a Mitsubishi HVAC system for on/off and temp control.

I used HA to replace all the AMX UI and interface capabilities and connected the HA to the Mitsubishi HVAC via Coolmaster. All this works perfectly, HVAC can be controlled via HA or Alexa commands. (expect for storing state for the HVAC when there is a power outage)

I want to use the existing KNX switches to turn the HVAC in a room on or off. This is what I’ve done so far.

The Expose switch works, the turn on HVAC automation works with a small bug, the turn off HVAC automation clashes with something and stops the Turn on automation from working.

Expose

    - type: binary
      address: "10/273"
      entity_id: switch.office_hvac
      default: false

Turning this switch in HA turns on the KNX wall switch and vice versa.

This Turn on HVAC automation works. When I push the KNX switch the HVAC unit turns on.

id: '1628431001280'
alias: KNX On Switch Office HVAC v1
description: ''
trigger:
  - platform: state
    entity_id: switch.office_hvac
    id: 'on'
condition: []
action:
  - service: climate.turn_on
    data: {}
    target:
      entity_id: climate.l1_017
mode: single

However, the Turn off Automation, (which is a copy of the turn on automation" with the 2nd part turning off the HVAC) stops the first automation from working again. I can turn on the HVAC from HA, but not from the KNX switch once the off automation is used once.
Trying to figure out what is wrong.

alias: 'KNX Off Switch Office HVAC '
description: ''
trigger:
  - platform: state
    entity_id: switch.office_hvac
    id: 'off'
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: 'off'
    target:
      entity_id: climate.l1_017
mode: single

Both have the exact same trigger and will clash with each other.

trigger:
  - platform: state
    entity_id: switch.office_hvac
    id: 'on'
trigger:
  - platform: state
    entity_id: switch.office_hvac
    id: 'off'

Both of them trigger on a state change. Be it on or off at the same time.

You will need to add the the to: line to decide on which action it should trigger:

trigger:
  - platform: state
    entity_id: switch.office_hvac
    to: 'on'
    id: 'on'
trigger:
  - platform: state
    entity_id: switch.office_hvac
    to: 'off'
    id: 'off'

And the id is only used to see what trigger was used when using multiple triggers.
So this could be just 1 automation using that. But since you are dealing with an simple on off a choose with a default action would be simpler.
Tho many other way available :smiley: I’m sure soemone can post an even cleaner automation.

alias: New Automation
description: ''
trigger:
  - platform: state
    entity_id: switch.office_hvac
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.office_hvac
            state: 'on'
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.l1_017
    default:
      - service: climate.set_hvac_mode
        data:
          hvac_mode: 'off'
        target:
          entity_id: climate.l1_017
mode: single
1 Like

Both options you suggested work :+1:

They allow me to turn the HVAC on/off via the KNX switch.
If however, I turn the HVAC off via the the dashboard in HA, the expose switch is not updated and the LED on the Switch is not updated for on/off. Is there a way to fix that?

Then you would need an automation for that too :smiley:
Use the state of the climate for a trigger and then check if its ‘off’ : turn switch off
And default action turn switch on, off is an easier chack as climate can have multiple options for its on state like heat, cool

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: climate.heating
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: climate.heating
            state: 'off'
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.yourswitch
    default:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.yourswitch

Awesome - this now works perfectly!
Is there a more clever way to have this work on another 15 units - other than just copy/paste and change variables for each individual unit.

If you use a naming scheme it should be doable with checking the entity_id with a condition and then using part of the entity_id for the action.

so the switch entities should be name: switch.hvac_l1017
and the climates likewise: climate.l1_017

That way you can use whatever triggered the automation to set the corresponding climate.
Never done it that way, but should be fun to find out.

You could create a blueprint. But tbh copy&paste 14 times will probably save you some time.

Thanks for the suggestions.

Running into a strange problem.

I created the KNX office switch entity “KNX Office HVAC” last year. When I turn on the switch in HA or vice versa the red LED indicator light on the KNX panel lights up.

I created a new KNX entity switches for other KNX wall panels. The HA entity controls the physical switch and vice versa. But, not red indicator light. Tried this with several panels.

Code is the same for entity and expose.

What might be wrong? Do I need to reset the entire KNX system?

 - name: "KNX Office HVAC"
      address: "10/273"
      state_address: "10/273"
 - name: "KNX Family HVAC"
      address: "10/264"
      state_address: "10/264"

and

  expose:
    - type: binary
      address: "10/273"
      entity_id: switch.office_hvac
      default: false
    - type: binary
      address: "10/264"
      entity_id: switch.knx_family_hvac
      default: false