Structure of configuration.yaml file

I have been reading the official pages on the forums and addons, but still I am not feeling all confident when tinkering around in the configuration. Any of you superusers that can spare a moment or two to explain me the structure of he file buildup?
For example when it comes to sensors. As I build my file, more and more sensors will be added to the file, do I just list them like this:
sensor:
- platform: yr
- platform: ring
- platform: plex
- platform: qbittorrent
qbittorrent:
url: !secret qbtlink
username: !secret qbn
password: !secret qbp
- platform: systemmonitor
resources:
- type: memory_free
- type: memory_use_percent
- type: disk_use_percent
arg: /home
- type: processor_use
- type: last_boot
- type: ipv4_address
arg: eth0
- type: network_in
arg: eth0
- type: network_out
arg: eth0

or can i have segments in it? … for example

    # Ring sensor
    sensor: 
         - ring

    # Ring Component
    ring:
      username: !secret rusn
      password: !secret rpsw

and then add another sensor in another segment like

# Qbittorrent
sensor:
  - platform: qbittorrent  
    qbittorrent:
    url: !secret qbtlink 
    username: !secret qbn
    password: !secret qbp

Sorry for stupid questions… trying to learn :slight_smile:

I like the packages approach.
Every different thing got his own file or folder. Downside, not possible to reload automations scripts and so on.
But do as you please

Did you look at these parts of the documentation?


I personally prefer to keep my config pieces in individual files in separate folders like this one for the input_boolean for example:
image

I was thinking about using packages until I figured out that making changes in the automation part of a package still requires an HA restart rather than just reloading the automations from the UI when I have the automations in my automations sub-folder.

you can’t have multiple sensor: sections… all sensors must be listed one after the other.

1 Like

And you need to start posting your code in the correct format for the forum. It makes it possible to see formatting errors.

Related question:

So at the moment I have a pretty simple file split with things like:

automation: !include automation.yaml
sensor: !include sensor.yaml
switch: !include switch.yaml
etc...

If I want to split my huge automation.yaml file up into areas based on this schema: config/domain/area.yaml (e.g. config/automation/lounge.yaml, config/automation/kitchen.yaml etc…) am I correct in assuming that I have to use

automation: !include_dir_merge_list automation/

What about if my directory structure was based on this schema: config/area/domain.yaml (e.g. config/kitchen/automations.yaml, config/lounge/automations.yaml, ) how would I include those files?

I’m not sure which schema I’ll go with yet. Any advantage to either of the above?

Yes on the first question. That’s sort of the way I have mine set up.

I’m not sure how you would do the second. It doesn’t seem to match any of the config examples.

The advantage of the first solution is that it will work :grin:

Just as you wrote the reference to the automation locations you can then easily either add a single file for each area or even a sub-folders for each area with an individual file for each one of the automations.

The second approach would require the ability to reference to multiple files or folders with the !include from the configuration.yaml, which is not possible as far as I understand it.

Thanks folks. First solution it is then.