Error handling of a disabled entity

I have an automation for Christmas lights that will turn off the tree if it is still on, when it isn’t “Christmas Season”. Since my smart plugs are unplugged after the season, I disable them in HA and I receive this error:

Error evaluating condition in ‘XMAS Lights Still On After Season’: In ‘condition’ (item 2 of 2): In ‘state’: In ‘state’ condition: unknown entity switch.xmas_tree.

What is the best way to handle this so I don’t get the error?

  - alias: XMAS Lights Still On After Season
    trigger:
      - platform: time
        at: '23:00'
    condition:
      - condition: state
        entity_id: binary_sensor.christmas_season
        state: 'off'
      - condition: state
        entity_id:
          - switch.xmas_tree
        state: 'on'
    action:
      - service: switch.turn_off
        entity_id:
          - switch.xmas_tree

Disable the automation.

You can replace this State Condition:

      - condition: state
        entity_id:
          - switch.xmas_tree
        state: 'on'

with this Template Condition:

      - condition: template
        value_template: "{{ states.switch.xmas_tree is iterable and is_state('switch.xmas_tree', 'on') }}"

If switch.xmas_tree doesn’t exist, the first test (is it iterable) will report false and the second test (is it on) will not be executed. The template’s final result will be false, thereby preventing the automation from executing its action (and without reporting an error).

Thanks for the explanation!