How i can to do this swich template in nodered

Hi, i have this switch template and i need help to do a flow.

script:               

  tv_cozinha_on:
    sequence:
    - service: broadlink.send
      data:
        host:  192.168.1.87
        packet:
        - 'JgBYAAABJZQRExESEhISEhISEhISNhISEhISEhISEhIRExETETcSEhISEjYSEhI3EhIRExESEhISNxISETcSEhI3ETcSNxI2EgAGDgABJkoSAAxCAAElShIADQU='  

  tv_cozinha_off:
    sequence:
    - service: broadlink.send
      data:
        host: 192.168.1.87
        packet:
        - 'JgBYAAABJZQRExESEhISEhISEhISNhISEhISEhISEhIRExETETcSEhISEjYSEhI3EhIRExESEhISNxISETcSEhI3ETcSNxI2EgAGDgABJkoSAAxCAAElShIADQU='  


 
  
switch:

  - platform: template
    switches:
      tv_cozinha:
        friendly_name: "Tv Cozinha"
        value_template: '{% if states.sensor.ldrtvcozinha.state|int > 400 %}on{% else %} off {% endif %}'
        turn_on:
          service: script.tv_cozinha_on
          entity_id: script.tv_cozinha_on
        turn_off:
          service: script.tv_cozinha_off
          entity_id: script.tv_cozinha_off
        icon_template: mdi:television

Like this?

[{"id":"f819e10d.562f1","type":"api-current-state","z":"5d0b3ac1.1ad2e4","name":"Tv Cozinha","server":"fc6553e6.c5975","version":1,"outputs":2,"halt_if":"400","halt_if_type":"num","halt_if_compare":"gt","override_topic":false,"entity_id":"sensor.ldrtvcozinha","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":270,"y":160,"wires":[["f19aa0a9.1eb9"],["f80c301a.6ba01"]]},{"id":"f19aa0a9.1eb9","type":"api-call-service","z":"5d0b3ac1.1ad2e4","name":"tv_cozinha_on","server":"fc6553e6.c5975","version":1,"debugenabled":false,"service_domain":"broadlink","service":"send","entityId":"","data":"{\"host\":\"192.168.1.87\",\"packet\":\"JgBYAAABJZQRExESEhISEhISEhISNhISEhISEhISEhIRExETETcSEhISEjYSEhI3EhIRExESEhISNxISETcSEhI3ETcSNxI2EgAGDgABJkoSAAxCAAElShIADQU=\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":480,"y":140,"wires":[[]]},{"id":"f80c301a.6ba01","type":"api-call-service","z":"5d0b3ac1.1ad2e4","name":"tv_cozinha_off","server":"fc6553e6.c5975","version":1,"debugenabled":false,"service_domain":"broadlink","service":"send","entityId":"","data":"{\"host\":\"192.168.1.87\",\"packet\":\"JgBYAAABJZQRExESEhISEhISEhISNhISEhISEhISEhIRExETETcSEhISEjYSEhI3EhIRExESEhISNxISETcSEhI3ETcSNxI2EgAGDgABJkoSAAxCAAElShIADQU=\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":480,"y":180,"wires":[[]]}]

Hi thank you for help… but and this

switch:

  - platform: template
    switches:
      tv_cozinha:
        friendly_name: "Tv Cozinha"
        value_template: '{% if states.sensor.ldrtvcozinha.state|int > 400 %}on{% else %} off {% endif %}'
        turn_on:
          service: script.tv_cozinha_on
          entity_id: script.tv_cozinha_on
        turn_off:
          service: script.tv_cozinha_off
          entity_id: script.tv_cozinha_off
        icon_template: mdi:television

If i deleted that, my switch is gone. What i can do?

If you need the switch, you have to keep the whole code (switch and script).