Struggling with a Template Switch for Harmony

So I am getting the follow error: "Invalid config for [switch]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 30). "

switch:
- platform: template
  switches:
    MB_Roku:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Roku-MB') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206484'
      turn_off:
         service: remote.turn_on
         data:
           entity_id: remote.master_bedroom
           activity: 'PowerOff'
        
    MB_Chromecast:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Cast-MB') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206532'
      turn_off:
         service: remote.turn_on
         data:
           entity_id: remote.master_bedroom
           activity: 'PowerOff'
           
    MB_Bedtime:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Bedtime-MBR') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206568'
      turn_off:
         service: remote.turn_on
         data:
          entity_id: remote.master_bedroom
          activity: 'PowerOff'

Apologies if I messed up the code block. This is my first post. Any help would be appreciated.

remove all the capital letters on each switch name. I.e. MB_Chromecast should be mb_chromecast.

Also, you can be lazy and provide the name of the activity instead of the activity #. Choice is yours.

Thanks for the help

switch:
- platform: template
  switches:
    mb_roku:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Roku-MB') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206484'
      turn_off:
         service: remote.turn_on
         data:
           entity_id: remote.master_bedroom
           activity: 'PowerOff'
        
    mb_chromecast:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Cast-MB') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206532'
      turn_off:
         service: remote.turn_on
         data:
           entity_id: remote.master_bedroom
           activity: 'PowerOff'
           
    mb_bedtime:
      value_template: "{{ is_state_attr('remote.master_bedroom', 'current_activity', 'Bedtime-MBR') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.master_bedroom
          activity: '37206568'
      turn_off:
         service: remote.turn_on
         data:
          entity_id: remote.master_bedroom
          activity: 'PowerOff'

New Error: "Invalid config for [switch]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 29). "

Thanks for the help!

Any other ideas?

Do you have more than 1 switch section?

This is the entire file: switch.yaml

Ok, remove switch from switch.yaml. It’s already called out in configuration.yaml.

Edit: To clarify I’m referring to the word switch: at the top of switch.yaml.

1 Like

That did the trick! I can’t tell you how much I appreciate your help. Not just this interaction, but your previous posts helping others with similar issues. I am a newb at HASS making the conversion over from Openhab and the jump from JSON/XML to YAML has been tougher than expected. Every little bit of help makes a huge difference.

THANK YOU!

A

1 Like