Including .yaml-files in configuration.yaml error

Hi there!

I’d like to include .yaml files into the configuration.yaml for a cleaner configuration.yaml. So I created a new file with the name Switches.yaml (in this file should go all switches for wake_on_lan as there is one already in it), added the line switch: !include Switches.yaml (don’t know if the switch is correct, but it should be), checked the developer tools.

I got the following error: Invalid config for ‘switch’ at configuration.yaml, line 34: required key ‘platform’ not provided. What is wrong and how can I fix it? Is it correct how I would do it?
Thank you guys for the answer and I hope you’re able to help me out here!

Try something like this. It works for me.

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
binary_sensor: !include binary_sensor.yaml
template: !include template.yaml

Do you mean to change the name of the file? Will try that!

Didn’t work unfortunately

Try to create first file and than add it to your configuration.

Actually did it the whole time, tried it again and got the same error. You have any more ideas?

Sorry no, that was my 5 cents.

Alright, thank you very much anyways, at least we tried some stuff. I feel like ha isn’t able to get the switch: !include (I mean the first part, but idk). We’ll see if I’m able to figure it out.

Now I changed the name of the file to switch-config, changed it into the configuration.yaml (the line would be: switch-config: !include switch-config.yaml) and got the following error: Integration error: switch-config - Integration ‘switch-config’ not found. I don’t get it…

Can you post what you have inside your switch.yaml?

Check doc if you haven’t already.

Long term, you’ll want to use packages. So I’d start there.

homeassistant:
  packages: !include_dir_named packages

Yes, it’s a wake_on_lan code:
wake_on_lan:

switch:

  • platform: wake_on_lan
    mac_address: MAC:ADRESS:OF:PC
    name: “PC-Name”
    host: IP-Adress

Format your code properly: How to help us help you - or How to ask a good question

Aside from that, remove the switch: and make it look like this:

- platform: wake_on_lan
  mac_address: MAC:ADRESS:OF:PC
  name: “PC-Name”
  host: IP-Adress

In an included file, the top level domain is already inferred from configuration.yaml.

Allright, will try to format it the next times.

Removed the switch, gonna try and see if it works. Do I have to remove the wake_on_lan: as well?

Nope. You need the - platform still. You just don’t use the top level domain in included files (unless you are using packages).

So

wake_on_lan:
- platform: wake_on_lan
and so on right?

- platform: wake_on_lan
  mac_address: MAC:ADRESS:OF:PC
  name: "PC-Name"
  host: IP-Adress

Just like that.

As an example, this is a bit of my switches.yaml file:

- platform: wake_on_lan
  mac: a8:5e:45:e4:40:63
  name: Bill Desktop
  host: 192.168.1.103

- platform: wake_on_lan
  mac: e4:3e:d7:1b:60:b9
  name: Office Monitor 1
  host: 192.168.107.191

- platform: template
  switches:
    living_room_tv_activity:
      unique_id: living_room_tv
      value_template: "{{ is_state('input_boolean.living_room_tv', 'on') }}"
      friendly_name: "Living Room TV Activity"
      turn_on:
        - service: rest_command.living_room_tv_activity_on
        - service: input_boolean.turn_on
          target:
            entity_id: input_boolean.living_room_tv
      turn_off:
        - service: rest_command.living_room_tv_activity_off
        - service: input_boolean.turn_off
          target:
            entity_id: input_boolean.living_room_tv

Note that the double-quotes around PC-Name are now “smart quotes” from copy-pasting your original incorrectly-formatted code.

Should be like this, at the top of your switch.yaml:

- platform: wake_on_lan
  mac_address: MAC:ADDRESS:OF:PC
  name: "PC-Name"
  host: IP-Address
1 Like

Allright, thank you very much for your help. Seems like I had to put the mac into “”. Don’t ask me why, but it seems like I was able to add the switch to my dashboard and that’s probably done.

1 Like