Sensor to check SSL expiration doesn't show

I’ve a strange problem with this sensor:

  - platform: command_line
    name: ssl_expiration
    unit_of_measurement: Giorni
    scan_interval: 43200
    command: "sudo ssl-cert-check -b -c /home/homeassistant/dehydrated/certs/ | awk '{ print $NF }'"

Trying to show it in lovelace with this code:

- type: glance
        title: SSL
          - entity: sensor.ssl_expiration
            name: Prossimo rinnovo SSL
            icon: mdi:certificate

but I seen only “Giorni” without the number. If I try to send command using SSH it report it correctly…so i don’t know where is the problem in lovelace or in the sensor…

I assume you are either running Hassbian or a venv installation.

Try putting the full path to the ssl-cert-check command in the configuration. The execution environment may not have that path. Perhaps try adding the path for sudo too.

You should also see the sensor information under Developer Tools -> States


Any reason you are using the command line sensor?

There’s a certificate expiry sensor:

- platform: cert_expiry

Yes i’m using Hassbian.
Sorry i’m not very good with SSH and this SO.
My admin user is “pi” when I access with SSH.
Home assistant is installed with “homeassistant” user.

I’ve installed ssl-cert-check under “pi”.

Also If I try to access SSH with user “homeassistant” I get access denied after entering password :frowning: so I always installed packages using pi user.

tried also with:
command: “sudo /usr/bin/ssl-cert-check -b -c /home/homeassistant/dehydrated/certs/ | awk ‘{ print $NF }’”

with no success.

In Developer Tools -> States I get no value / empty value

path to awk & sudo ? Is sudo even needed?

Try with:

command: “sudo /usr/bin/ssl-cert-check -b -c /home/homeassistant/dehydrated/certs/ | /usr/bin/awk ‘{ print $NF }’”

no success… still empty

Finally I get it working!
Thanks to this guide, i get a solution:

sudo visudo

then add this row:

homeassistant ALL=(ALL) NOPASSWD:ALL

1 Like