Configuring Command Line sensor using YAML has moved. Consult the documentation to move your YAML configuration to integration key and restart Home Assistant to fix this issue

Also

is it mandatory to put into configuration.yaml the following… or not?

command_line: !include command_line.yaml

Hi,

I am unable to get this working. I am only able to get the CPU temperature sensor working with command_line, for the rest, it error’s out.

Please help. My sensor’s part from configuration.yaml are below:

-sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: disk_use
      - type: disk_free
      - type: memory_use_percent
      - type: memory_use
      - type: memory_free
      - type: swap_use_percent
      - type: swap_use
      - type: swap_free
      - type: load_1m
      - type: load_5m
      - type: load_15m
      - type: network_in
        arg: eth0
      - type: network_out
        arg: eth0
      - type: throughput_network_in
        arg: eth0
      - type: throughput_network_out
        arg: eth0
      - type: packets_in
        arg: eth0
      - type: packets_out
        arg: eth0
      - type: ipv4_address
        arg: eth0
      - type: ipv6_address
        arg: eth0
      - type: processor_use
      - type: processor_temperature
      - type: last_boot

  - platform: template
    sensors:
      A1_phone_home:
        value_template: >-
          {% if states('sensor.A1_device_wifi_connection') == "wifi_home-5G" %}
            home
          {% elif states('sensor.A1_device_wifi_connection') == "wifi_home" %}
            home
          {% else %}
            not_home
          {% endif %}
        friendly_name: "A1_phone_wifi"

      G1_phone_home:
        value_template: >-
          {% if states('sensor.G1_phone_wifi_connection') == "wifi_home-5G" %}
            home
          {% elif states('sensor.G1_phone_wifi_connection') == "wifi_home" %}
            home
          {% else %}
            not_home
          {% endif %}
        friendly_name: "G1_phone_wifi"

  - platform: command_line
    name: CPU Temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: "{{ value | multiply(0.001) | round(1) }}"
    scan_interval: 10

Thank you

That is not a command line sensor. Leave it where it is,

Not. It is only required if you want to split your config into different files.

Thank you for the reply. I get an error when i put that in configuration.yaml.

i followed System Monitor - Home Assistant link and it has been declared as a sensor.

If i keep it as is, it gives me the below error.

Invalid config for [command_line]: required key not provided @ data[‘command_line’][1][‘sensor’][‘command’]. Got None. (See /config/configuration.yaml, line 49).
Integration error: -sensor - Integration ‘-sensor’ not found.

It works!!

had to add
command_line: !include command_line.yaml
into configuration.yaml

and use this code into command_line.yaml

- sensor:
     name: "CPU Temp"
     command: "cat /sys/class/thermal/thermal_zone0/temp"
     unit_of_measurement: "°C"
     value_template: '{{ value | multiply(0.001) | round(2) }}'```
5 Likes

Worked for me thanks !

Thanks for your help!

Hello,
Any ideas how to make this work with command_line?

switch:
  - platform: rpi_gpio
    ports:
      23: Tehnoruum
    invert_logic: true

That is not a command line switch. Leave it as is.

Jag fick meddelandet ‘Command Line YAML configuration has moved’.
In configuration.yaml, I had:

- platform: command_line
    name: Raspberry CPU Temperature
    command: cat /sys/class/thermal/thermal_zone0/temp
    unit_of_measurement: "°C"
    value_template: "{{ value | multiply(0.001) | round(2) }}"

I changed it to:

- command_line:      (here I see Missing Property "platform".
    - sensor:
        name: Raspberry CPU Temperature
        command: cat /sys/class/thermal/thermal_zone0/temp
        unit_of_measurement: "°C"
        value_template: "{{ value | multiply(0.001) | round(2) }}"

And when using Developer tools Check Configuration, I see:

Configuration invalid!

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 27).

Can someone please help me out and tell me what I am doing wrong?

Should be

command_line:

And the command line integration should be in your configuration.yaml file. Not the sensors.yaml file.

Thanks for responding. I now have:

command_line:
  - sensor:
      name: Raspberry CPU Temperature
      command: cat /sys/class/thermal/thermal_zone0/temp
      unit_of_measurement: "°C"
      value_template: "{{ value | multiply(0.001) | round(2) }}"

And I see:
Configuration invalid!

Invalid config for [command_line]: [platform] is an invalid option for [command_line]. Check: command_line->command_line->1->platform. (See /config/configuration.yaml, line 52).

Notes:
Everything is in configuration.yaml. I do not have a sensors.yaml file.
To clarify, I am also including a screenshot of this section of configuration.yaml, just in case:
image

Thanks again.

Remove all of the text under your circled text that starts - platform: systemmonitor... and ends before input_select:...

That is not a command line sensor and belongs under sensor: in your configuration.yaml file.

Also in future please do not post images of text. Post the text correctly formatted for the forum.

1 Like

Thank you. Sorted.
Noted and acknowledged re. images.

1 Like

The notification says Command Line YAML configuration has moved, but it doesn’t say from-where or where-to. Many users probably still have their sensor section in their configuration.yaml file, hence the Command Line YAML configuration hasn’t moved anywhere - it has just changed. I think therefore the headline is misleading. It would also be nice if the DOCs would mention that the old syntax for command_line has been (will be) depreciated;

2 Likes

The configuration has moved. From the sensor integration to its own integration. That does not depend on you having a split config or not.

Yeah, I guess you are right. I can see that now, but it wasn’t immediately obvious to me what was meant by that headline.
Thanks for enlightening me.

This works for me too.

Hi,
Unfortunately I have to adjust all my template sensors to the command_line.
I’ve split up my configuration.yaml and now added :

Integrations:
Command_line.yaml

command_line: !include_dir_merge_list ../entities/command_line

In the folder ‘Entities\command_line’
I have several files like this : (uset to be located in my ‘sensor’ subfolder)

  - platform: template
    sensors:
      energy_import_totaal_dagelijks_kwh:
        friendly_name: 'kWh vandaag piek + dal'
        value_template: "{{ (states('sensor.energy_import_t1_dagelijks_kwh')|float + states('sensor.energy_import_t2_dagelijks_kwh')|float)|round(2) }}"
        unit_of_measurement: "kWh"

  - platform: template
    sensors:
      energy_import_totaal_wekelijks_kwh:
        friendly_name: 'kWh wekelijks piek + dal'
        value_template: "{{ (states('sensor.energy_import_t1_wekelijks_kwh')|float + states('sensor.energy_import_t2_wekelijks_kwh')|float)|round(2) }}"
        unit_of_measurement: "kWh"

  - platform: template
    sensors:
      energy_import_totaal_maandelijks_kwh:
        friendly_name: 'kWh maandelijks piek + dal'
        value_template: "{{ (states('sensor.energy_import_t1_maandelijks_kwh')|float + states('sensor.energy_import_t2_maandelijks_kwh')|float)|round(2) }}"
        unit_of_measurement: "kWh"

etc....


Can someone help me and tell me how to ‘convert’ these sensors templates to command_line ?
Thanks in advance.
Jeffrey