Command Line YAML configuration has moved error

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

I just confirmed that the scan_interval on my newly-configured command_line sensors is working as expected. That said, I don’t see anything wrong with your YAML. Maybe someone with sharper eyes than I will chime in.

Thx @CaptTom for checking.
I have figured that out. As my sensor didn’t have any state assigned, the default value assigned by HA was ‘unknow’. I think there were some changes around that as it was working fine in version 2023.5. In 2023.6.1 I had to set the state different than ‘uknown’ and scan_interval works fine.
So the correct code would be like that:
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
    command_timeout: 60
    value_template: '{{ value_json.response }}' # HAD TO ADD THIS TO WORK
    json_attributes:
      - error
      - response

I’m struggling with this and can’t understand what is the error. I have whis in my configuration.yaml.

# NAS WoL
wake_on_lan:

switch:
  - platform: wake_on_lan
    mac: secret_mac
    name: "NAS"
    host: 192.168.2.10
    broadcast_address: 255.255.255.255
    turn_off:
      service: switch.turn_off
      entity_id: switch.server_off

  - platform: command_line
    switches:
      server_off:
        command_on: switch.home_server
        command_off: "ssh -i /config/unraid/.ssh/id_rsa -o [email protected] 'echo -n mem > /sys/power/state'"

I had tried to add command_line, to add spaces as showed, tried to move this lines to a switch.yaml… nothing works. I got always errors

I don’t use command_line for switches, but from the documentation it looks like this would be the format:


command_line:
  - switch:
      name: string (Required)
      command_on string (Required)
      ommand_off string (Required)
      command_state string (Optional)
      command_timeout integer (Optional, default: 15)
      name string Required
      icon template (Optional)
      unique_id string (Optional)
      value_template string (Optional)
      scan_interval integer (Optional, default: 30)

The command_line: would start in the first column, the rest indented as shown.

=( I don’t have the knowledge to translate my old lines to the new format, it seems always wrong. I will try again in futuro or totaly discard the switch

Thank you for that explanation. That error box left a lot to be desired tbh. Bad grammar, no link to documentation, etc.

Presumably it would be something like this:

command_line:
  - switch:
      name: server_off
      command_on: switch.home_server
      command_off: "ssh -i /config/unraid/.ssh/id_rsa -o [email protected] 'echo -n mem > /sys/power/state'"
      unique_id: cmd_server_off

Note that I added a unique_id. That will help when you bring up this entity in the UI.

(Again, I haven’t done this myself, so I’m open to corrections)

Thank you so much.
I was able to update my command line switch, and everything is working correctly

1 Like

Thank you, it’s working !

This should be command_line. Missing underscore.

I have moved some of my entries over, but I’m lost with the following where I use a combination of WoL and media_player to turn my TV on and off. I cannot for the life of me see what I need to change here!

switch:
  - platform: wake_on_lan
    mac: XX:XX:XX:XX:XX:XX
    name: "Bedroom TV Power"
    turn_off:
      service: media_player.turn_off
      target:
        entity_id: media_player.lg_webos_tv_oled65c9pla

Can anyone advise how I should now format this is my new command_line.yaml?

TIA

that’s not a command line switch…

that’s a wake_on_lan switch.

Ahhh… I see now (I think). That makes sense.

Thank you very much

I am super confused about this change. How would you rewrite a sensor like the below where there is no “Command” per se.

/config/sensor.yaml

==========

platform: template
sensors:
 sunrise:
        friendly_name: "Sunrise"
        unit_of_measurement: ""
        value_template: >
          {{ as_timestamp(state_attr("sun.sun", "next_rising"))
             |timestamp_custom("%H:%M") }}
 sunset:
        friendly_name: "Sunset"
        unit_of_measurement: ""
        value_template: >
          {{ as_timestamp(state_attr("sun.sun", "next_setting"))
             |timestamp_custom("%H:%M") }}