I’m starting from the ground up with Home Assistant. My current version is out of date and the config is a total mess.
I was thinkign that this time around I’d split my configuration file out and use directories and seperate yaml files to keep things organized.
Now I’m only a few hours into getting things back into HA and I’m taking things slowly, making sure things work properly before moving on the next thing. Right now I’m working on setting up sensors for a weather platform.
Unfortunately I am getting the following error:
Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 14).
The relevant area of my configuration file looks like this:
No indentations, according to the docs there are no indetations or ‘-’ before platform when using !include_dir_named
Also I tried with - platform, no identations, and with indentations
I also tried with trailing ‘/’ after the directory name.
None of my attempts yielded any different results.
" This small example illustrates how the “split” files work. In this case, we start with two (2) device tracker entries (owntracks and nmap). These files follow “style 1” that is to say a fully left aligned leading entry (- platform: owntracks) followed by the parameter entries indented two (2) spaces."
Example:
configuration.yaml
sensor: !include_dir_merge_list sensor/
One of the sensor file:
#Home IP
- platform: rest
resource: https://api.ipify.org?format=json
value_template: '{{ value_json.ip }}'
name: Home IP
I don’t understand exactly what that means. I’m a very visual learner, I love examples.
I assume that dir_merge_list is the most common usage and works something like this?
configuration.yaml
Yaml before !include_fir_merge_list
#contents of file 1
lines
of
yaml
code
#contents of file 2
lines
of
yaml
code
#contents of file 3
lines
of
yaml
code
Yaml after !include_fir_merge_list
“!include_dir_merge_list” will merge/combine all .yaml files in directory.
Example:
if you like to combine all sensors .yaml files, HA will already know it’s a sensors and you don’t have to add to all files
sensor:
just name of the platform and etc…
configuration.yaml
sensor: !include_dir_merge_list sensor/
/config/sensor/ directory will have number of .yaml files
home_ip.yaml
#Home IP
- platform: rest
resource: https://api.ipify.org?format=json
value_template: '{{ value_json.ip }}'
name: Home IP
mta_status.yaml
# MTA service status sensor
- platform: command_line
name: MTA service status
command: "python3 /config/python_scripts/service_status.py"
scan_interval: 600
“!include_dir_named” will map filenames to file content
if you using in configuration.yaml
sensor: !include_dir_named sensors
/config/sensor/ directory will have number of .yaml files
you have to add to each file
sensor:
home_ip.yaml
#Home IP
sensor:
- platform: rest
resource: https://api.ipify.org?format=json
value_template: '{{ value_json.ip }}'
name: Home IP
mta_status.yaml
# MTA service status sensor
sensor:
- platform: command_line
name: MTA service status
command: "python3 /config/python_scripts/service_status.py"
scan_interval: 600
I wish there was a way to see the ‘working’ configuration.yaml file.
In my case if I could have seen the configuration.yaml file that was the result of the !includes I might have been able to catch the mistake earlier, especially when the generated error message is referencing a blank line.