Platform: command_line. sensor is not applied

sensor:
  - platform: command_line
    name: "MeinTestSensor"
    unique_id: "my_unique_test_sensor_xyz"
    command: "/bin/echo HalloWelt"
    scan_interval: 60

can someone add this to their /homeassistant/configuration.yaml and restart it?

Do you then have a “test” sensor?
If not => am I doing something wrong here?
P.s. The log has no errors in it. (sometimes screwed up to debug)

Or asked differently. This code is a minimal test because my own plan does not work.

I am trying to read a JSON file and pass it into a sensor.

sensor:
  - platform: command_line
    name: solarprognose_raw_json_hourly_NEU
    command: “cat /config/solarprognose.json”
    scan_interval: 60

But is not created either. Maybe there are other possibilities?

Have you read the documentation for the Command Line integration? Your syntax does not match what is described there. The current syntax should be:

command_line:
  - sensor:
      command: "/bin/echo Hello World!"

(Also your second code example looks like it uses a different type of quote, and may in the final sensor require the full path /bin/cat written out.)

1 Like

grafik

I don’t quite follow you.
I read the documentary and I BELIEVE I understood it.
’ I only need it for masking.

I don’t need to mask anything for my commands.

I have uploaded it again as an image. With the 2nd command, the editor made something else out of it. I used “ (key 2)

Edit: /bin/cat added + reboot.
The sensor is still not created

Read the documentation again. Your code does not look like any of the examples in the documentation. You are using an outdated syntax, a command line sensor is no longer defined by a platform: command_line entry but by a top level command_line: header.

sorry… I don’t get it.
These are the lines I have tested. But each one gives an error so I can’t restart at all.
Do you have a working code as an example?

command_line:
  - name: "MeinTestSensor"
    unique_id: "my_unique_test_sensor_xyz"
    command: "/bin/echo Hello World!"
    scan_interval: 60


command_line:
  sensors:
    - name: "MeinTestSensor"
      unique_id: "my_unique_test_sensor_xyz"
      command: "/bin/echo Hello World!"
      scan_interval: 60



command_line:
  mein_test_sensor:
    name: "MeinTestSensor"
    unique_id: "my_unique_test_sensor_xyz"
    command: "/bin/echo Hello World!"
    scan_interval: 60



sensor:
  - platform: command_line
    name: "MeinTestSensor"
    unique_id: "my_unique_test_sensor_xyz"
    command: "/bin/echo Hello World!"
    scan_interval: 60

I really don’t see what is difficult about it. Just use a syntax that is identical to what is used in the documentation examples? None of what you have posted so far do. This does:

command_line:
  - sensor:
      name: "MeinTestSensor"
      unique_id: "my_unique_test_sensor_xyz"
      command: "/bin/echo Hello World!"
      scan_interval: 60

(Does it work? No idea, I don’t have any command_line sensors, and cannot be bothered to restart HASS right now to test. But this is how the documentation says that they should be written.)

THANKS !!! Works