Configuring window_open_external Popp 701721 thermostat

Please be kind, I’m very much a noob with programming and such so the learning curve is steep (if not vertical :slight_smile: ).

My goal is to use the window_open_external in a Popp 701721 TRV with a Tuya TS0203 door/window sensor. I’ve managed to achieve turning the TRV down/off and on again with the use of a automation based on a blueprint, but it’s probably more elegant to use the window_open_external option.

My thought was to make a template switch in HA, and to use that in the TRV by adding the following to my configuration.yaml.

switch:
  - platform: template
    switches:
      raam_kantoor:
        value_template: "{{ is_state('binary_sensor.raam_kantoor_contact', 'on') }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.trv_kantoor_window_open_external
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.trv_kantoor_window_open_external

The switch (switch.raam_kantoor) itself is working when I open the window, but switch.trv_kantoor_window_open_external is not responding. If I try to add switch.raam_kantoor to the config of the TRV (under devices) I get the following error:
Entity with this ID is already registered.

Probably it has something to do with setting true/false vs on/off?

Am I thinking in the right direction, or should this be done with Zigbee2MQTT? Could anyone give some pointers?

My system:
HA version 2021.12.10 in a docker on a RPI4
Zigbee2MQTT version 1.22.2 in a docker
Coordinator type zStack3x0 (CC2652RB slae.sh)
Coordinator revision 20211217

Figured it out by using the following blueprint which synchronises the on-off states between 2 entities. Sometimes the solution is easier than you think.