Since I upgraded last I have the following message regarding a change to how command line switch entities are done, however I cant seem to find documentation of the new way to define them. They still work, presumably in future they won’t .This is the error:
Command Line YAML configuration has moved
This stops working in version 2023.8.0. Please address before upgrading.
Configuring Command Line `switch` using YAML has moved.
Consult the documentation to move your YAML configuration to integration key and restart Home Assistant to fix this issue.
I tried moving the switches to a separate switches.yaml, but this does not help. Here is an example of my config that triggers the new error:
Thanks for that, the warning error has disappeared now. Only problem is, one switch seems to work on its own, but If I add any more of them, only the last switch in the configuration shows up in homeassistant, is there a separator I’m missing, I’ve tried both of the below and I get the same behaviour:
I had added the -switch: separator for multiple entities, but not done a full restart, only a reload. Below works perfectly now for multiple switches.
I read the documentation and made the changes based on how I read it. But, it did not work for me. Below is the YAML code I ended up with. I had to comment out the CPU Temp code to get it to say a restart would be OK. Can anyone help me get the right YAML code?
The system cannot restart because the configuration is not valid: Invalid config for [switch]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 11).
I’m getting the same.
From how I read it, the documentation is written if the sensor/switch/cover is in the configuration.yaml, but it doesn’t have an example of the formatting if it’s called in it’s own file.
- platform: command_line
sensor:
name: CPU Temp
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "..C"
value_template: "{{ value | multiply(0.001) | round(2) }}"
error reported via Developer Tools validaton:
Invalid config for [sensor.command_line]:
[sensor] is an invalid option for [sensor.command_line].
Check: sensor.command_line->sensor. (See ?, line ?)
Addendum
Moving it to configuration.yaml in the following format fixed it for now.
Would still like to move it back to sensors.yaml at some point to keep it all in order.
command_line:
- sensor:
name: CPU Temp
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "..C"
value_template: "{{ value | multiply(0.001) | round(2) }}"
I tried the YAML above and get the following error:
Configuration invalid!
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 'cat /sys/class/thermal/thermal_zone0/temp'
extra keys not allowed @ data['command_line'][0]['name']. Got 'CPU Temp'
extra keys not allowed @ data['command_line'][0]['unit_of_measurement']. Got '°C'
extra keys not allowed @ data['command_line'][0]['value_template']. Got '{{ value | multiply(0.001) | round(2) }}'. (See /config/configuration.yaml, line 36).
Can I put all sensors under the command_line? Even if they do not have command lines?
I solved my issue. When I copied the YAML to the new structure I had the indentation wrong. Even worse I kept typing it that way. I just fixed the indentation and it works.
Configuration invalid!
Invalid config for [command_line]: [http_tasmota_switch1] is an invalid option for [command_line]. Check: command_line->command_line->0->switch->http_tasmota_switch1.
Already done. The issue now is with http_tasmota_switch1 as it is a invalid option for command_line. This all worked perfectly before in switch.yaml.
Invalid config for [command_line]: [http_tasmota_switch1] is an invalid option for [command_line]. Check: command_line->command_line->0->switch->http_tasmota_switch1.```