How to update Switch color

I have set up an alarm system based on Homematic stuff. Motion sensors, window and door sensors etc. I can read and display the status in Lovelace like this:

(this is german, so Unscharf = unarmed, Hüllschutz = hull protect, Vollschutz = complete protection)

sensor:
  - platform: template
    sensors:
      alarm_status:
        friendly_name: "Status Alarm"
        value_template: >-
          {%- if state_attr('homematic.ccu3', 'Status_Alarm_Aktiv_Var') == 0 -%}
           Unscharf
          {%- elif state_attr('homematic.ccu3', 'Status_Alarm_Aktiv_Var') == 1 -%}
           Huellschutz
          {%- elif state_attr('homematic.ccu3', 'Status_Alarm_Aktiv_Var') == 2 -%}
           Vollschutz
          {%- else -%}
           Fehler
          {%- endif -%}

Screenshot 2022-05-14 212039

As you see, I control the alarm system status by using switches in Lovelace:

switch:
  - platform: template
    switches:
       alarm_unscharf_switch:
         friendly_name: 'Alarm Unscharf'
         turn_on:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "0"
         turn_off:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "0"
       alarm_huellschutz_switch:
         friendly_name: 'Alarm Hüllschutz'
         turn_on:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "1"
         turn_off:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "0"
       alarm_vollschutz_switch:
         friendly_name: 'Alarm Vollschutz'
         turn_on:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "2"
         turn_off:
           service: homematic.set_variable_value
           data:
             entity_id: homematic.ccu3
             name: Set_Status_Alarm_Var
             value: "0"

As you also see in the screenshot, the Homematic status can change to “unarmed”, but the color of the switch still indicates to be active (on).

Question: how to toggle the switch back based on a sensor status?