I struggled with this earlier today. Ended up moving command_line configuration into the configuration.yaml file from the breakout switches and sensor.yaml files where it was.
Here’s a Before and After example (parameters have been modified):
I recommend to use command_lime: !include command_line.yaml in configuration.yaml and created the referenced file. So you can split them as well (like Switches, sensors, etc)
Nevermind, it was an indent thing… Sigh…
I had to indent the code below -sensor:…
Stupid mistake, but hey… I’m only human
Hi,
I am dealing with an equal challenge here.
I currently (still) use my IOWait sensor using the old format.
sensor:
- platform: command_line
name: CPU IO Wait
command: top -b -n1 | grep ^CPU | awk '{printf("%.0f"), $10}'
scan_interval: 3
unit_of_measurement: '%'
value_template: '{{ value }}'
If my interpretation of the documentation is correct, the new format should be this
command_line:
- sensor:
name: CPU IO Wait
command: top -b -n1 | grep ^CPU | awk '{printf("%.0f"), $10}'
scan_interval: 3
unit_of_measurement: '%'
value_template: '{{ value }}'
When I however do a check config, it returns:
Invalid config for [command_line]: expected a dictionary for dictionary value @ data['command_line'][0]['sensor']. Got None
extra keys not allowed @ data['command_line'][0]['command']. Got 'top -b -n1 | grep ^CPU | awk \'{printf("%.0f"), $10}\''
extra keys not allowed @ data['command_line'][0]['name']. Got 'CPU IO Wait'
extra keys not allowed @ data['command_line'][0]['scan_interval']. Got 3
extra keys not allowed @ data['command_line'][0]['unit_of_measurement']. Got '%'
extra keys not allowed @ data['command_line'][0]['value_template']. Got '{{ value }}'. (See /config/configuration.yaml, line 204).
Does anyone have any idea?
For the record, the old one works like a charm.
I did not realize that I could include a directory structure of YAML files, but I will seriously consider migrating my YAML files to this as my system grows.