Proper usage of Advanced splitting_configuration - getting Invalid configs error Fix

core-2021.1.5
supervisor-2021.01.7
Home Assistant OS 5.10

IDEs
HassIO > core_configurator
Notepad++ > Lang:YAML
(using double space vs tab)

Hey guys, trying to organize my main config yaml file by following splitting_configuration/#example-include_dir_list but running into an error when I check with Server Controls > CHECK CONFIGURATION. I’ve read some search results but only pointed to formatting fixes, using 'on' vs On

I get a Green check with this:

/config/configuration.yaml

input_number: !include house_heater.yaml

/config/house_heater.yaml

hh_day_mf_wake:
  min: 60
  max: 80
  step: 2

But when I try to use !include_dir_list I get an error.

Invalid config for [input_number]: expected dictionary for dictionary value @ data['input_number']. Got [OrderedDict([('hh_day_mf_wake', OrderedDict([('min', 60), ('max', 80), ('step', 2)]))])]. (See ?, line ?).

/config/configuration.yaml

input_number: !include_dir_list input_numbers/

/config/input_numbers/house_heater.yaml

hh_day_mf_wake:
  min: 60
  max: 80
  step: 2

The example I’m using is for automation: !include_dir_list automation/presence/ so not sure if that’s just the limit of how it was coded and can’t be used for input_numbers?

On another note, this is my first post and had to dig a little extra to find the [code][/code] tags to make it look pretty(er). Would be nice if it was in the WYSIWYG editor like the preformatted and block buttons.

Input numbers are configured as a dictionary, not a list. Use:

!include_dir_named (for one file)

or

!include_dir_merge_named (for many files in a directory).

This is a list:

something:
  - something_else: blah
  - something_else: blah
  - something_else: blah

This is a dictionary:

something:
  sometning_else: blah
  sometning_else: blah
  sometning_else: blah

Have a look at how the config for automations differ from input_numbers.

1 Like

Ah big thanks! Changing it to input_number: !include_dir_merge_named input_numbers/ worked.

So when I was reading the descriptions of the different !includes, I over looked the β€œas a” part.

  • !include_dir_list will return the content of a directory as a list with each file content being an entry in the list. The list entries are ordered based on the alphanumeric ordering of the names of the files.
  • !include_dir_named will return the content of a directory as a dictionary which maps filename => content of file.
  • !include_dir_merge_list will return the content of a directory as a list by merging all files (which should contain a list) into 1 big list.
  • !include_dir_merge_named will return the content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.

Also for clarification if you don’t mind me asking, after I looked around and tried a few things, pretty much if starts with a - it’s going to be a list, like sensor and binary_sensor and input_*, none starting - are going to be a dictionary?

I put all my config under CONFIG:packages/…

so in my configuration.yaml I have:

packages: !include_dir_merge_named packages

then in my CONFIG: my dir folder tree looks like this:

.
β”œβ”€β”€ http.yaml
β”œβ”€β”€ hvac
β”‚   β”œβ”€β”€ controller
β”‚   β”‚   β”œβ”€β”€ bath.yaml
β”‚   β”‚   β”œβ”€β”€ heating.yaml
β”‚   β”‚   β”œβ”€β”€ shower.yaml
β”‚   β”‚   └── water.yaml
β”‚   β”œβ”€β”€ programmer
β”‚   β”‚   └── house.yaml
β”‚   β”œβ”€β”€ sensors
β”‚   β”‚   β”œβ”€β”€ automations.yaml
β”‚   β”‚   └── xiaomi_LYWSD03MMC.yaml
β”‚   β”œβ”€β”€ switch
β”‚   β”‚   └── danfoss.yaml
β”‚   β”œβ”€β”€ thermostats
β”‚   β”‚   └── house.yaml
β”‚   └── trvs
β”œβ”€β”€ lighting
β”‚   β”œβ”€β”€ tablelamp_dad.yaml
β”‚   └── tablelamp_lounge.yaml
β”œβ”€β”€ logger.yaml
β”œβ”€β”€ media
β”œβ”€β”€ metrics
β”‚   └── heating.yaml
β”œβ”€β”€ mqtt.yaml
β”œβ”€β”€ notifications.yaml
β”œβ”€β”€ plugs
β”‚   β”œβ”€β”€ energenie_1.yaml
β”‚   └── energenie_2.yaml
β”œβ”€β”€ recorder.yaml
β”œβ”€β”€ security
β”‚   └── cameras.yaml
β”œβ”€β”€ system
β”‚   └── sysmon.yaml
└── zwave.yaml

13 directories, 22 files

Each .yaml file must have , as its first line , the subpath below packages.
For example, http.yaml first line is:

http:

The first line in the danfoss.yaml file that is down in the structure tree , is this:

hvac_switch_danfoss:

Note how each directory is separated with the underscore β€˜_’

If you do that, then one just needs to create folders and files under packages and it will all work - or should do if your config syntax in those files is correct.

Correct.

Not so correct. We just established that input_numbers were a dictionary because they did not start with a -.