Invalid config for [switch]: required key not provided

I have keep getting this error and I don’t understand why
I’ve cheked the other post about this error but it still dosen’t work

Error

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

I’m trying to use Wake On Lan from this link, but when I check from setting i get this error.

WOL conf.yaml

Line 44
switch:
**- platfotm: wake_on_lan
****mac_addres: "MAC"
****name: Computer
****host: "192.168.1.x"
****turn_off:
*****service: shell_command.turn_off_pc
****shell_command:
*****turn_off_pc: 'net rpc shutdown -I 192.168.1.37 -U mypc%passw'
the * is for the indentation just here
the link I’ve used: https://www.home-assistant.io/components/switch.wake_on_lan/

What I’m doing wrong? I’m running hass.io on ubuntu 18.04

Your indentation is incorrect. ‘service’ should be indented 2 spaces more than turn_off, the same applies to the text below ‘shell’.

EDIT: also, by using the code block formatting (that you have, thank you!), you don’t need to put the *'s there for us :grinning:

spelling error for platform as well. You have platfotm

2 Likes

I didn’t see platform.
I’ve changed the indentation and correct the spelling.
Now I have this error
[switch.wake_on_lan]: required key not provided @ data['mac_address']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.wake_on_lan/

well we cant see your MAC address… did you use the correct format?

EDIT: you only have 1 ‘s’ in ‘address’

1 Like

Sorry I’m dumb. :frowning:
For the Mac “11-11-11-11-11-11” or I have to use : ?
Edit: if I check i get all ok.
I was missing that 2 letters.

1 Like

Sry that i dig up this thread but im gonna crazy
i get the error from the configuration that already include the switch.yaml with
switch: !include switch.yaml:

Invalid config for [switch]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 86). Please check the docs at Switch - Home Assistant

And my switch (wake on lan ) that is on switch.yaml is:

> switch:
>   - platform: wake_on_lan
>     mac_address: "D0-50-99-29-B9-65"
>     name: Wake Chris
>     host: 192.168.2.3
>     turn_off:
>       service: hassio.addon_stdin
>       data:
>         addon: core_rpc_shutdown
>         input: chris-pc

I cant see nothing wrong could you help me?

If your configuration.yaml has

switch: !include switch.yaml

Then the mistake you are making is having the key switch: in your switch.yaml. Just remove that line completely.

7 Likes

Wow! That was the problem! thank you!

1 Like

@anon43302295 Thank you, on the suggestion of removing the sensor tag in the file I’m attempting to remove. That resolved an issue I was having and couldn’t understand, but that actually clears up the command in my head for theinclude too.

1 Like

I registered just to say thank you!!!
This solved my problem with splitting up my configuration.yaml

1 Like

Now is my turn :frowning:

Invalid config for [media_player]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 15).

media_player:
  - platform: soundtouch
    host: 10.0.0.6
    port: 8090
    name: Soundtouch Living Room

I have just started experimenting with splitting up my configuration.yaml.

I used to copy the whole block of code into a separate file and though I could just include that file and it would work…it didn’t.

e.g. from my configuration.yaml

light:
  - platform: group
    name: Trees
    entities:
      - light.front_tree_1
      - light.front_tree_2
      - light.front_tree_3
      - light.front_tree_4

To include this as a separate file, in the configuration.yaml

light: !include lights.yaml

And in the separate lights.yaml file

#light: (this line is not used, it's declared in the configuration.yaml)
  - platform: group
    name: Trees
    entities:
      - light.front_tree_1
      - light.front_tree_2
      - light.front_tree_3
      - light.front_tree_4

Another example for a custom sensor I created froma Wemos D1

In my configuration.yaml file

binary_sensor: !include binary_sensor.yaml

And a separate file for the sensor

#Beam sensor
#binary_sensor: (this line is not used, it's declared in the configuration.yaml)
  - platform: mqtt
    name: "Beam sensor motion"
    state_topic: "stat/beam_sensor/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    qos: 0
    device_class: motion