Command Line YAML configuration has moved error

My old dashboard worked as before. Use these entities:

switch.d_nvr
switch.d_danmain

Both appear on my custom outlet/switch dashboard I made and the on/off calls are working. I have them appear in my dashboard by just adding these two entities above. Hope that helps.!


Just chipping in with what worked for me - and thanks for the tips here, which helped me get this far.

I got this warning after upgrading to 2023.6.0

Command Line YAML configuration has moved. This stops working in version 2023.8.0. Please address before upgrading. Configuring Command Line binary_sensor using YAML has moved. Consult the documentation to move your YAML configuration to integration key and restart Home Assistant to fix this issue.

I use include files in my configuration.yaml - and the culprit was in my binary_sensor.yaml which looked like this:

- platform: command_line
  name: OctoPrint camera status
  device_class: connectivity
  command: >
    response=$(curl -LIk -m 5 http://octopi.local/webcam/ -o /dev/null -w 
    "%{http_code}\n" -s); test "$response" -eq 400 && echo "ON" || echo "OFF"
  scan_interval: 60
  value_template: '{{ value }}'

I removed that entry from the file and added this line to my configuration.yaml:

command_line: !include command_line.yaml

In command_line.yaml I added the following:

- binary_sensor:
    name: OctoPrint camera status
    device_class: connectivity
    command: >
      response=$(curl -LIk -m 5 http://octopi.local/webcam/ -o /dev/null -w 
      "%{http_code}\n" -s); test "$response" -eq 400 && echo "ON" || echo "OFF"
    scan_interval: 60
    value_template: '{{ value }}'

Rebooted and the warning disappeared. Hope that helps someone

2 Likes

Where exactly did you add the entities ?

Hi,

I am trying to fix these sensors but was not able.

I get duplicate entry error when moving the command line sensor from sensor.yaml to command_line.yaml, and not able to move the btc_price template sensor to template.yaml without getting any errors.

I would appreciate any help. Thanks in advance.

#############################
# CoinMarketCap Integration #
#############################
  - platform: command_line
    name: coinmarketcap_curl
    command: 'curl -X GET -H "X-CMC_PRO_API_KEY: my_api_key" -H "Accept: application/json" -d "symbol=BTC,ADA,BNB,LTC,THETA,DOGE,BAKE,DOT&convert=USD" -G "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest"'
    value_template: '{{ value_json.value }}'
    scan_interval: 900 #15 mins refresh (at 300 with 3 coins it will use 288 credits per day out of the allocated 333 credits)
    json_attributes:
    - data
  
  - platform: template
    sensors:
      btc_price:
        unique_id: 'btc_price'
        friendly_name: 'Bitcoin Price'
        unit_of_measurement: 'USD'
        value_template: '{{ ((states.sensor.coinmarketcap_curl.attributes.data.BTC.quote.USD.price) | float) | round(5) }}'

sensor.yaml:

- platform: template
  sensors:
    btc_price:
      ....

command_line.yaml:

- sensor:
    name: ...
    command: ...
    value_template: ...

configuration.yaml:

sensor: !include sensor.yaml
command_line: !include command_line.yaml
3 Likes

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

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

Dear Community,

I had a command line switch, which I moved to command_line integration into a separate command_line yaml:

command_line:
  - switch:
      name: dahua_gate_open
      command_on: "/usr/bin/curl -s --globoff --digest --user X:X 'http://192.168.0.251/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote'"
      unique_id: dahua_gate_open

My problem is that I cannot call switch turn on service for this reconfigured switch, because I cannot reference the switch itself (not even in developer call service, not as a device, nor as an entitiy, and I don’t even see in the state list (not by name or unique_id), also not visible under Devices/entites list…

How can I call turn_on service for a command_line defined switch??

Trying to call turn on service in developer tools, command_line switch is not found:

I had the same issue as OP. I thought I’d post my previous YAML and my new YAML, which seems to be working now.

configuration.yaml

switch:
  - platform: command_line
    switches:
      raspberry_pi_shutdown:
        command_on: "ssh -i /config/ssh_keys/pi -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"

      hallway_pi_shutdown:
        command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"

      master_bedroom_pi_shutdown:
        command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"

      hallway_pi_reboot:
        command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"

      master_bedroom_pi_reboot:
        command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"

And now, I’ve changed it to:

command_line:
  - switch:
      name: raspberry_pi_shutdown
      command_on: "ssh -i /config/ssh_keys/pi -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"
      command_off: ""

  - switch:
      name: hallway_pi_shutdown
      command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
      command_off: ""

  - switch:
      name: master_bedroom_pi_shutdown
      command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
      command_off: ""

  - switch:
      name: hallway_pi_reboot
      command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
      command_off: ""

  - switch:
      name: master_bedroom_pi_reboot
      command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
      command_off: ""

I’m pretty sure this works.

2 Likes

I also had the same issue… Here is my code that now works.

Old - Switch.yaml


  - platform: command_line
    switches:
      http_tasmota_switch1:
        command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20On'
        command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20Off'
        command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.51/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
        value_template:   '{{value_json.POWER == "ON" }}'
        friendly_name:    "Http_Tasmota 1"

      http_tasmota_switch2:
        command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20On'
        command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20Off'
        command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.52/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
        value_template:   '{{value_json.POWER == "ON" }}'
        friendly_name:    "Http_Tasmota 2"

      http_tasmota_switch3:
        command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20On'
        command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20Off'
        command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.53/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
        value_template:   '{{value_json.POWER == "ON" }}'
        friendly_name:    "Http_Tasmota 3"

      http_tasmota_combo_switch:
        command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20On'
        command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20Off'
        command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.54/cm?cmnd=Power1' || echo -n {\"POWER\":\"OFF\"}
        value_template:   '{{value_json.POWER1 == "ON" }}'
        friendly_name:    "Http_Combo Switch 1"

      http_tasmota_combo_switch2:
        command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20On'
        command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20Off'
        command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.54/cm?cmnd=Power2' || echo -n {\"POWER\":\"OFF\"}
        value_template:   '{{value_json.POWER2 == "ON" }}'
        friendly_name:    "Http_Combo Switch 2" 

New Command_Line.yaml

- switch:
    # http_tasmota_switch1:
    command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20On'
    command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20Off'
    command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.51/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
    value_template:   '{{value_json.POWER == "ON" }}'
    name: "Http_Tasmota 1"
    unique_id: http_tasmota_switch1

- switch: 
    # http_tasmota_switch2:
    command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20On'
    command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20Off'
    command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.52/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
    value_template:   '{{value_json.POWER == "ON" }}'
    name: "Http_Tasmota 2"
    unique_id: http_tasmota_switch2

- switch:
    # http_tasmota_switch3:
    command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20On'
    command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20Off'
    command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.53/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
    value_template:   '{{value_json.POWER == "ON" }}'
    name: "Http_Tasmota 3"
    unique_id: http_tasmota_switch3

- switch:
    # http_tasmota_combo_switch1:
    command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20On'
    command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20Off'
    command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.54/cm?cmnd=Power1' || echo -n {\"POWER\":\"OFF\"}
    value_template:   '{{value_json.POWER2 == "ON" }}'
    name: "Http_Combo Switch 1" 
    unique_id: http_tasmota_combo_switch 1

- switch:
    # http_tasmota_combo_switch2:
    command_on:       /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20On'
    command_off:      /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20Off'
    command_state:    /usr/bin/curl -s -m 5 -X GET  'http://192.168.0.54/cm?cmnd=Power2' || echo -n {\"POWER\":\"OFF\"}
    value_template:   '{{value_json.POWER2 == "ON" }}'
    name: "Http_Combo Switch 2" 
    unique_id: http_tasmota_combo_switch 2

@scharmach
I always feel a bit stupid reading answers like this. “The solution is in this post”
Why not being specific?

3 Likes

I think you need to get rid of the ‘command_line:’ at the top. It already knows it’s a command_line when you included the command_line yaml file. This is what happened to me. Hope it maybe helps.

1 Like

Hello everyone!
At the moment I have managed to make the rest of the sensors work for me with the new method
The problem comes to me with the systemmonitor integration, since it falls under sensor.
As:

sensor:
   - platform: systemmonitor
     resources:
       -type: disk_use_percent
         arg: /config
       -type: memory_free

Does anyone know how to make it accept it and the warning not come?

I also additionally gave an example that is listed in the breaking changes (2023.6: Network storage, favorite light colors, new integrations dashboard - Home Assistant) and the solution has a link to the relevant documentation.

1 Like

Hm, if I’m not mistaken, that’s not the case unfortunately, at least according to my previous experiences: the file name could be anything, the content matters. I splitted my configuration in to different yamls, and call them with “include dir” in main configuration yaml, but it doesn’t look at the filename, rather the content.

if I don define command_line at the beginning of the file, I get the following error upon yaml config validation in developer tools:

expected a dictionary for dictionary value @ data['packages']['command_line']

But you gave me a good idea, to try out the command_line integration in the main configuration, maybe it works there.

hm, you also do not declare command_line at the beginning of your split configuration in your separate command_line.yaml as @mchome suggested?? And it works? Tried, but didn’t work for me…

hm, @mchome, just a feedback: I moved the whole thing back to main configuration.yaml, and this way it works perfectly. I don’t know what I’m screwing up with split config, in a different yaml:

in main config:

ommand_line:
  - switch:
      name: "Bejárati kapu"
      command_on: "/usr/bin/curl -s --globoff --digest --user gh:2Thousand45 'http://192.168.0.251/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote'"
      command_off: ""
      unique_id: dahua_gate_open

and calling service in developer tools finally finds it:

Hey,
Can you post it here so I can compare it with mine. I am having the exact issue with my sensors and I keep getting an error after I made the proper changes.

Here is my configuration.yaml file:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
command_line: !include command_lines.yaml
sensor: !include sensors.yaml
my:
history:
# Tile
device_tracker:
  - platform: tile
    username: !secret tile_user
    password: !secret tile_pass

and here is my command_lines.yaml file:

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

It took me a while to get the indention right. But once I did, it worked well.

1 Like

I have my command line sensors moved into a new command_line.yaml file and the sensors are working as normal in the new config. I have renamed the original file to name.yaml.disabled so HA won’t be looking for it. After a reboot the sensors are working but the repair warning is still present. Should it go away on its own if everything is good or do I just have to dismiss it?

Cannot check it myself at the moment (so cannot be sure for 100%), but I do recall that this “Repair” popup has a button after pressing which it is considered that you SOLVED the issue (“repaired”) and this repair entry will disappear.

Have you noticed any problems with the command_line sensor scan_interval?
After moving it to the new format it doesn’t seem to work for me. The script is working correctly once (i.e. after HA restart), but never triggered again.
Here is my config:

configuration.yaml

command_line: !include command_line.yaml

command_line.yaml

- sensor:
    name: "Bin collections"
    command: "python3 -u /config/python-scripts/bins_collection.py"
    scan_interval: 10800  # 3h
    command_timeout: 60 # needed as the website may sometimes not load
    json_attributes:
      - error
      - response

Forgot to mention that I use a Docker version of HA