IR TV and Template Switch

I have a dumb Samsung TV that I want to control with a Broadlink. I have the TV plugged into a Xiaomi Zigbee Plug to monitor the power consumption for the purposes of keeping the switch in sync. Admittedly this is a little over my head at the moment and I am in struggle town.

This is what I have in my switch.yaml currently:

    TV_switch:
        value_template: "{{ states('sensor.tv_consumption_monitor_switch_powerdraw') | int > 20}}"
        turn_on:
          - service: switch.broadlink_send_packet_10_0_20_62
            data:
              packet: 
                - "JgCMAJSVETkRORE4EhMRFBEUERQRFBE4EjgROREUERQRFBETEhMTEhE5ERQRFBEUERMSExITETkRFBE4EjgRORE5EjcSOBEABgaUlRE5ETkROBITERQRFBEUERQROBI4ETkRFBEUERQTERITEhMROREUERQRFBETEhMSExE5ERQTNhI4EjgRORE4EjgSAA0FAAAAAAAAAAAAAAAA="
        turn_off:
          - service: switch.broadlink_send_packet_10_0_20_62
            data:
              packet: 
                - "JgCMAJSVETkRORE4EhMRFBEUERQRFBE4EjgROREUERQRFBETEhMTEhE5ERQRFBEUERMSExITETkRFBE4EjgRORE5EjcSOBEABgaUlRE5ETkROBITERQRFBEUERQROBI4ETkRFBEUERQTERITEhMROREUERQRFBETEhMSExE5ERQTNhI4EjgRORE4EjgSAA0FAAAAAAAAAAAAAAAA="

Am I on the right path with this?

Looks similar to mine. I’d paste the value template in the template editor and turn the TV on and off manually to see if that value works.
Also, you need to remove the uppercase in the name, is tv_switch:

Thanks! Yeah I think I might have used yours from another thread possibly. Which would explain why it is similar. I was getting another error but worked out I had a space in the wrong spot.

I ended up leaving it just to activate the IR Switch I already had that worked fine. In case anyone comes looking for something similar -

 -  platform: template
    switches:
      tv:
        value_template: "{{ states('sensor.tv_consumption_monitor_switch_powerdraw') | int > 5 }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.tv_power_ir
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.tv_power_ir