Message malformed: Entity entity_id is neither a valid entity ID nor a valid UUID for dictionary value

After a power failure, my switches do not restore the state. I have them in decoupled mode and control smart bulbs.
I came up with the following logic.
I catch the events of the transition of monitored switches to off, or the launch of hass
I turn on the switches and raise the recovery mode flag for a minute.
If the lamp turns on at this time, I immediately turn it off.
When trying to save the automation, I get the error
Message malformed: Entity entity_id is neither a valid entity ID nor a valid UUID for dictionary value @ data['action'][0]['choose'][1]['conditions'][0 ]['conditions'][0]['entity_id']

blueprint:
  name: Power_recovery
  description: Turn on decoupled switch after power lost
  domain: automation
  input:
    target_switch:
      name: Switch
      description: This is decoupled switches  to recover
      selector:
        target:
          entity:
            domain: switch
    target_light:
      name: light
      description: ligh_ on decoupled
      selector:
        target:
          entity:
            domain: light    
    emergency_flag:
      name: Input_bolean
      description: recovering
      selector:
        target:
          entity:
            domain: input_boolean
variables:
  switch: !input "target_switch"               

trigger:
  - platform: state
    entity_id: !input target_switch
    to: "off"
    id: power_lost 
  - platform: state
    entity_id: !input target_light
    to: "on"
    id: light
  - platform: homeassistant
    event: start
    id: hass
    
action:
  - choose:
      - conditions:
           - condition: and  
             conditions:             
                 - "{{ expand(switch.entity_id) | selectattr('state', '==', 'off') | list | count > 0 }}"  
                 - condition: or      
                   conditions:           
                       - condition: trigger
                         id:  power_lost 
                       - condition: trigger
                         id:  hass                        
        sequence:
          - service: swith.turn_on
            target: !input target_switch
          - service: input_boolean.turn_on
            target: !input  emergency_flag     
          - delay: "00:01:00"        
          - service: input_boolean.turn_off
            target: !input  emergency_flag     

      - conditions:
           - condition: and  
             conditions:  
                 - condition: state
                   entity_id: !input emergency_flag
                   state: "on"
                 - condition: trigger
                   id:  light
        sequence:
          - service: light.turn_off
            target: !input target_light    

    default: []            

See Getting a couple errors I don't understand on automation blueprint creation - #4 by CentralCommand