Package Error - Invalid config for [switch]: required key not provided @ data['platform']

trying to move my xbox one hassio addon and related components into a package but i get an error. It works if i leave the template switch in the seperate switches.yaml

Invalid config for [switch]: required key not provided @ data['platform']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch/

Any help would be appreciated!

Thanks

switch:
  - platform: template
    switches:
      xboxone:
        value_template: "{{ is_state('sensor.eeeeeediot', 'Online') }}"
        turn_on:
          service: rest_command.xbox
          data:
            power: "poweron"
        turn_off:
          service: rest_command.xbox
          data:
            power: "poweroff"
        friendly_name: "Xbox One"

rest_command:
  xbox:
    url: 'http://192.168.0.xx:5557/device/xxxxxxxxxxxxxxxxxx/{{power}}'

sensor:
# Xbox Live sensor. tells current state of xbox
  - platform: xbox_live
    scan_interval: 90
    api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xuid:
      - xxxxxxxxxxxxxxxxxxx

# Xbox template sensor . Tells current state of xbox
  - platform: template 
    sensors: 
      xboxone_status: 
        friendly_name: "Eeeeeediot"
        value_template: >
          {% if is_state('sensor.eeeeeediot', 'Offline') %}
            Offline
          {% elif is_state('sensor.eeeeeediot', 'Online') %}
            {{ states.sensor.eeeeeediot.attributes["XboxOne Full"] }}
          {% else %}
            Home
          {% endif %}

#xbox switch in switch.yaml - wouldnt copy over and validate correctly

I can’t figure out why it fails, but have you thought of restful switch instead?
It would simplify your setup quite a bit

@lolouk44 Yeah it’s a strange one. I tried the restfull switch a while back but couldn’t get it to work so settled for above.

How would you do it?