EVCC MQTT KNX - How do I use HA as MQTT Broker to connect EVCC to KNX entity?

Goal:
I want to turn a KNX switch on/off based on EVCC charger as heatpump, based on excess energy. KNX switch allows Heatpump for pool to work if target temp != actual temp.

Plan:
EVCC publishes on topic evcc/loadpoints/2/Freigabe_WP_Teich = true which is command_topic of switch.freigabe_waermepumpe_teich_mqtt = true if sufficient excess Energy is available at home.
This change triggers an automation Automation_Freigabe_Waermepumpe_Teich_EIN
Automation turns on switch.freigabe_waermepumpe_teich_knx
Heatpump is allowed to heat and warm water in pool based on PV Energy :1st_place_medal:

Workings:
MQTT Mosquitto Plugin running :white_check_mark:
EVCC connected and pub to MQTT Broker. Confirmed on EVCC and used in HA as badge :white_check_mark:
MQTT Switch exists as HA Entity switch.freigabe_waermepumpe_teich_mqtt :white_check_mark:
KNX Switch integrated as HA Entity switch.freigabe_waermepumpe_teich_knx :white_check_mark:
KNX HA Entity changes/updates bidirectionally correctly send on/received from KNX bus :white_check_mark:
KNX Switch Config:

switch:
  #KNX Switches
  #UG Technik
  - address: "3/7/11"
    name: Freigabe Waermepumpe Teich KNX
    state_address: "3/7/21"

Issues:

  1. EVCC seems not to be able to subscribe to MQTT topic. Changes made to switch are published to broker - visible in MQTT Explorer:

MQTT based switch config - tried via value_template, state_on/off and payload_on/off:

switch:
  - name: "Freigabe Waermepumpe Teich MQTT"
    unique_id: freigabe_waermepumpe_teich_mqtt
    command_topic: "evcc/loadpoints/2/Freigabe_WP_Teich"
    state_topic: "evcc/loadpoints/2/Freigabe_WP_Teich_Status"
    payload_on: "true"
    payload_off: "false"
    #    state_on: "true"
    #    state_off: "false"
    optimistic: false
    qos: 0
    retain: true
#    value_template: "{{ True | typeof }}"
  1. EVCC changes are not published to MQTT Topic in Broker. Log Entries Trace on MQTT from EVCC when making changes:
[mqtt ] TRACE 2025/04/15 12:15:58 send evcc/loadpoints/1/chargePower: '0'
[mqtt ] TRACE 2025/04/15 12:16:05 send evcc/loadpoints/2/batteryBoost: 'false'
[mqtt ] TRACE 2025/04/15 12:16:05 send evcc/loadpoints/2/mode: 'now'
[mqtt ] TRACE 2025/04/15 12:16:05 send evcc/updated: '1744712165'
[mqtt ] TRACE 2025/04/15 12:16:06 send evcc/loadpoints/2/batteryBoost: 'false'
[mqtt ] TRACE 2025/04/15 12:16:06 send evcc/loadpoints/2/mode: 'off'
[mqtt ] TRACE 2025/04/15 12:16:06 send evcc/updated: '1744712166
  1. Automation does not work. Changing state manually on MQTT Switch, does not lead to a state change in KNX switch.
alias: Automation_Freigabe_Waermepumpe_Teich_EIN
description: ""
triggers:
  - trigger: state
    entity_id:
      - switch.freigabe_waermepumpe_teich_mqtt
    from: "false"
    to: "true"
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.freigabe_waermepumpe_teich_knx
mode: single

Setup:
EVCC 203.1 running on RaspiPi5 as service
HA running on RaspiPi4B booting from SSD Drive (Core 2025.4.2; Supervisor 2025.04.0; Operating System 15.1)
MQTT Mosquitto integration running on HA

I have been able to solve it.

  1. Expose KNX Switch as Entity in HA
  2. Publish KNX Switch via HA Automation as MQTT Topic - on change and every minute to not run in “Outdated data” error in EVCC.
alias: KNX Schalter switch.freigabe_wp_teich_knx auf MQTT publishen
description: Publiziert den Status des KNX-Schalters switch.freigabe_wp_teich_knx auf MQTT
triggers:
  - entity_id: switch.freigabe_wp_teich_knx
    trigger: state
  - minutes: /1
    trigger: time_pattern
conditions: []
actions:
  - data:
      topic: home/knx/aussen/freigabewpteichknx/state
      payload: |
        {% if trigger.platform == 'state' %}
          {{ 'true' if trigger.to_state.state == 'on' else 'false' }}
        {% else %}
          {{ 'true' if states('switch.freigabe_wp_teich_knx') == 'on' else 'false' }}
        {% endif %}
      qos: 0
      retain: true
    action: mqtt.publish
mode: single

3.Map MQTT set topic via HA Automation to KNX Switch

alias: KNX Schalter switch.freigabe_wp_teich_knx auf MQTT publishen
description: Publiziert den Status des KNX-Schalters switch.freigabe_wp_teich_knx auf MQTT
triggers:
  - entity_id: switch.freigabe_wp_teich_knx
    trigger: state
conditions: []
actions:
  - data:
      topic: home/knx/aussen/freigabewpteichknx/state
      payload: |
        {{ 'true' if trigger.to_state.state == 'on' else 'false' }}
      qos: 0
      retain: true
    action: mqtt.publish
mode: single
  1. EVCC Config Charger
  - name: Waermepumpe_Teich
    type: custom
    icon: heater
    status: # charger status A..F?
      source: script
      cmd: /bin/sh -c 'echo "B"'
    enabled: # charger enabled state (true/false or 0/1)
      source: mqtt
      topic: home/knx/aussen/freigabewpteichknx/state # hier der Schaltzustand des Schalters. Erwartet wird "true/false" oder "1/0"
      timeout: 60s
    enable: # set charger enabled state (true/false or 0/1)
      source: mqtt
      topic: home/knx/aussen/freigabewpteichknx/set # hier der Schaltbefehl an den Schalter. Hier kommt "true/false"
      timeout: 60s
    power:
      source: const
      value: 0
    maxcurrent: #set charger max current (A)
      source: script
      cmd: /bin/sh -c 'echo ${maxcurrent} > /dev/null'
    features:
    - heating
    - integrateddevice

Note: I assume with EVCC 204.1 an higher, it would be possible to directly interact with the HA entity of the switch