Stuck with config "command_line"

Hello all,

First excuse if my english is not perfect, i’m french and some times (due to grammatical differences) it could not be clear

I try for 3 hours to debug my config.yaml because the error message about “command_line” “Configuring Command Line sensor using YAML has moved.”

So please, i need help

The old one (working fine):

- platform: template
  sensors:
    conso_corrigee:
      friendly_name: "conso corrigee"
      value_template: "{{states('sensor.shellyem_34945470f4ca_channel_2_power')|multiply(1.06)|round(0)}}"
      unit_of_measurement: Wh
      device_class: energy
      icon_template: mdi:gauge
      attribute_templates:
        state_class: total_increasing
    #comptage lumières allumées
    nombre_lumieres_on:
      friendly_name: "lumières allumées"
      value_template: "{{ states.light | selectattr('state', 'eq', 'on') | rejectattr('attributes.friendly_name','search','all')| list | count }}"
    #Solaire beem
    solaire_beem_total:
      friendly_name: "Solaire Beem Total"
      value_template: "{{states('sensor.beem1_ch1_power') | float + states('sensor.beem2_ch1_power') | float}}"
      unit_of_measurement: 'watts'
    #solaire Voltalia
    solaire_voltalia_total:
      friendly_name: "Solaire Voltalia Total"
      value_template: "{{states('sensor.arriere_cuisine_ch1_power') | float + states('sensor.arriere_salon_ch1_power') | float}}"
      unit_of_measurement: 'watts'
    #temperature SPA
    temperature_spa:
      friendly_name: "temperature spa"
      value_template: "{{ state_attr('climate.spa', 'current_temperature') }}"
      unit_of_measurement: '°C'
#System Monitor raspberry Pi
- platform: systemmonitor
  resources:
    - type: disk_free
      arg: /
    - type: disk_use_percent
      arg: /
    - type: memory_free
    - type: memory_use_percent
    - type: swap_use_percent
    - type: processor_use
    - type: last_boot

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

# Tempo
- platform: rest
  name: "Tempo Demain"
  resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
  value_template: '{{ value_json.JourJ1.Tempo }}'
  headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)
- platform: rest
  name: "Tempo Aujourd'hui"
  resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
  value_template: "{{ value_json['JourJ'].Tempo }}"
  headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)

The new one (f#cked up):
error: configuration is not valid: Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 54).

sensor:
  - platform: command_line
    name: "conso corrigee"
    command: "echo '{{ states(''sensor.shellyem_34945470f4ca_channel_2_power'') | float * 1.06 | round(0) }}'"
    unit_of_measurement: Wh
    device_class: energy
    icon_template: mdi:gauge
    scan_interval: 5

  - platform: command_line
    name: "lumières allumées"
    command: "echo '{{ states.light | selectattr(''state'', ''eq'', ''on'') | rejectattr(''attributes.friendly_name'',''search'',''all'') | list | count }}'"
    scan_interval: 5

  - platform: command_line
    name: "Solaire Beem Total"
    command: "echo '{{ states(''sensor.beem1_ch1_power'') | float + states(''sensor.beem2_ch1_power'') | float }}'"
    unit_of_measurement: 'watts'
    scan_interval: 5

  - platform: command_line
    name: "Solaire Voltalia Total"
    command: "echo '{{ states(''sensor.arriere_cuisine_ch1_power'') | float + states(''sensor.arriere_salon_ch1_power'') | float }}'"
    unit_of_measurement: 'watts'
    scan_interval: 5

  - platform: command_line
    name: "temperature spa"
    command: "echo '{{ state_attr(''climate.spa'', ''current_temperature'') }}'"
    unit_of_measurement: '°C'
    scan_interval: 60

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

  - platform: systemmonitor
    resources:
      - type: disk_free
        arg: /
      - type: disk_use_percent
        arg: /
      - type: memory_free
      - type: memory_use_percent
      - type: swap_use_percent
      - type: processor_use
      - type: last_boot

  - platform: rest
    name: "Tempo Demain"
    resource_template: "https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{ now().strftime('%Y-%m-%d') }}&TypeAlerte=TEMPO"
    value_template: "{{ value_json.JourJ1.Tempo }}"
    headers:
      Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
      Content-Type: "application/json"
      User-Agent: "Wget/1.20.3 (linux-gnu)"

  - platform: rest
    name: "Tempo Aujourd'hui"
    resource_template: "https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{ now().strftime('%Y-%m-%d') }}&TypeAlerte=TEMPO"
    value_template: "{{ value_json['JourJ'].Tempo }}"
    headers:
      Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
      Content-Type: "application/json"
      User-Agent: "Wget/1.20.3 (linux-gnu)"

Use this syntax instead (here is an example of part of mine - justr “comand_line” and then below that “sensor”):

command_line:
  - sensor:
# Add-Ins for monitoring weewx published weather data
      name: WEEWX_LAST1_SENT_TO_AWEKAS
      command: "grep 'AWEKAS: Published' /share/weewx.log | tail -1 | cut -c-255"
      scan_interval: 30
      command_timeout: 5
      value_template: >
        {% set data = value | regex_findall('\(([0-9]+)\)') | first | int | as_datetime | as_local %}
        {% set ts = data.year ~ ' ' ~ (value | regex_findall('(.+)kruse-pi weewx') | first).strip() %}
        {% set time = strptime(ts, '%Y %b %d %H:%M:%S', data) | as_local %}
        {% set str = time.strftime('%a %-m/%-d %-I:%M:%S%p') ~ ' (5 min)' %}
        {% set indx = str.find("M (") %}
        {% set oldstr = str[indx-1:indx+1] %}
        {{ str.replace(oldstr,oldstr.lower()) }}
      unique_id: WEEWX_LAST1_SENT_TO_AWEKAS
  - sensor:
      name: WEEWX_LAST1_SENT_TO_WUNDERGROUND-PWS
      command: "grep 'Wunderground-PWS: Published' /share/weewx.log | tail -1 | cut -c-255"
      scan_interval: 30
      command_timeout: 5
      value_template: >
        {% set data = value | regex_findall('\(([0-9]+)\)') | first | int | as_datetime | as_local %}
        {% set ts = data.year ~ ' ' ~ (value | regex_findall('(.+)kruse-pi weewx') | first).strip() %}
        {% set time = strptime(ts, '%Y %b %d %H:%M:%S', data) | as_local %}
        {% set str = time.strftime('%a %-m/%-d %-I:%M:%S%p') ~ ' (5 min)' %}
        {% set indx = str.find("M (") %}
        {% set oldstr = str[indx-1:indx+1] %}
        {{ str.replace(oldstr,oldstr.lower()) }}
      unique_id: WEEWX_LAST1_SENT_TO_WUNDERGROUND-PWS
  - sensor:
(and so on)

Used in this dashboard from my weather station (above sensors were the ones in the red rectangles):

There is French-speaking forum here: https://forum.hacf.fr/
Questions can be asked in French :wink: