Command_line to curl

Hi,
I am trying to get my 1-wire sensor on a ESP8266, that is showing the temperature on a html page.
In mrtg I used this one to graph the temperatur:
curl -s http://nodemcu1|grep -i Duschwasser|cut -c 17-18

So I did the same in the configuration.yaml:

sensor:

  • platform: command_line
    command: ‘curl -s http://nodemcu1 | grep -i Duschwasser | cut -c 17-18’
    name: Duschwasser Temperatur
    unit_of_measurement: “…C”

I used single quote, but it is not working.

I do not see the sensor in Devtools-Status and not anywhere else.

Not sure how to proceed.

Any idea?

Thanks!
Regards,
Miro

  1. Format your code according to rules - place a code into triple backquotes.
  2. This is an old syntax for command_line sensors, check Docs for a proper one.

When posting code to this forum, please be sure to format it properly.

This is the legacy configuration style. It may not be the source of your problem, but I suggest you update to the current standard which would look like this:

command_line:
  - sensor:
      name: Duschwasser Temperatur
      command: 'curl -s http://nodemcu1 | grep -i Duschwasser | cut -c 17-18'
      unit_of_measurement: "…C"

Did you restart HA after adding this to configuration.yaml? When adding a new platform you must restart – a quick reload will not load the new section.

You should check the log files for any errors or issues.

1 Like

Thanks for your help!

I have modified the sensor with your suggstion and it is still not working. But 1 step further…

Looking at the log, I can see :

ValueError: Sensor sensor.duschwasser_temperatur has device class ‘None’, state class ‘None’ unit ‘…C’ and suggested precision ‘None’ thus indicating it has a numeric value; however, it has the non-numeric value: ‘’ (<class ‘str’>)

  • home-assistant.log 50/50 100%

I am running home-assistant in a docker instance and the curl command works from the command line.

What is still wrong here?

Thanks a lot so far!

Best regards,
Miro

Comment “unit_of_measurement” and see what comes there…
Log says the value is not numerical.

Thanks!

Now it is showing the number.
image

Very strange, if I type the ° in the console it gives back the three dots. “…C”
Is this maybe a formating error or something.

Cheers,
Miro

Probably sometimes a value is not numerical - using with UoM causes an error.
You may process a value in template, check docs for command_line.

ok checking docs, thanks to all for Support!