Template Rendered Invalid Service - Tasmota 3-Way Light

I have a Tasmota 3-Way lightswitch that has two switches within it - one for the power and one for the power status on it.

I set up as a template to automatically flip its status light when the power switches on it. It worked for a while, but some time ago started getting the error “Template Rendered Invalid Service” when flipped. The odd part is that it works most of the time, but not always. Not clear on what I am doing wrong with it.

    switch:
      basement_lights:
        friendly_name: Basement Lights
        value_template: "{{ states('switch.basement_lights_power_status') }}"
        turn_off:
          service: >
            {% if is_state('switch.basement_lights_power_status', 'on') %}
              switch.toggle
            {% endif %}
          entity_id: 'switch.basement_lights_power_switch'
        turn_on:
          service: >
            {% if is_state('switch.basement_lights_power_status', 'off') %}
              switch.toggle
            {% endif %}
          entity_id: 'switch.basement_lights_power_switch'
        icon_template: mdi:lightbulb

If you turn the switch off when it is already off you will be calling a service but not supplying one. Likewise for on when already on. This will generate an error, you can’t have a null service. You must always provide an else case if using an if template for a service or entity_id so that it receives some valid value.

If you have no else case then you need to think of another approach, like this:

    switch:
      basement_lights:
        friendly_name: Basement Lights
        value_template: "{{ states('switch.basement_lights_power_status') }}"
        turn_off:
          - condition: state
            entity_id: switch.basement_lights_power_status
            state: 'on'
          - service: switch.toggle
            entity_id: switch.basement_lights_power_switch
        turn_on:
          - condition: state
            entity_id: switch.basement_lights_power_status
            state: 'off'
          - service: switch.toggle
            entity_id: switch.basement_lights_power_switch
        icon_template: mdi:lightbulb