Sensor to show expiry date of SSL certificate

Although that does sort of go against the point of docker :slight_smile:

I would have to read it again and I will, but will Acme renew the certificate automatically. Just checked crontab -l after Acme installation and it shows:
56 0 * * * “/home/homeassistant/.acme.sh”/acme.sh --cron --home “/home/homeassistant/.acme.sh” > /dev/null

It sure is much easier than using certbot - especially if auto renewal is included.
Thanks!

check the solution one post above yours solution, just put the ssl check script in the homeassistant config folder.

Thank you.

Ive installed the ssl-cert-check in homeassistant home folder, modified its permissions and modified the sensor to let it run in my configuration and give me “-days”

sersors.yaml:

- platform: command_line
  command: /home/homeassistant/ssl-cert-check -b -c /home/homeassistant/.acme.sh/YOURNAME.duckdns.org/YOURNAME.duckdns.org.cer | awk '{print -$6}'
  name: SSL
  scan_interval: 43200
  unit_of_measurement: days

SSL

ps: its build in: https://www.home-assistant.io/components/sensor.cert_expiry/

1 Like

problem is with the builtin one, if you restart HA at any time it says unavailable. I think it only checks every 12 hours.

SSL Certificate Expiry
2 days ago
Unknown
via SSH work fine :frowning:

For anyone looking for a easier method to keep the SSL cert valid, just run:

apt-get install certbot
systemctl enable certbot.timer
systemctl start certbot.timer

This will use the auto-update system defined by Let’s Encrypt itself.

3 Likes

I’m not experiencing that, if I restart it shows it immediately.

Is it possible to use the build in component with the URL: https://xxx.com:789/?src=connect

I have tried

host: xxx.com
port: 789

Since I switched to Caddy it’s working immediately here as well but with the standard LetsEncrypt addin it was a 12 hour wait to see the sensor expiry.

Same problem! Did you solve the problem?
I think is a user permission problem.
LS -la command show me “ssl-cert-check” file have a root:root permission, i think need change with “homeassistant” user.

To fix the delayed update after a system restart, I use an automation that runs 15 seconds after hass startup and calls the homeassistant.update_entity service for the sensor.ssl_certificate_expiry. This way it updates without the 12 wait.

1 Like

Excellent! Thank you for the suggestion.

So you have something like that ?

- alias: update_entity_on_reboot
  trigger:
    - platform: homeassistant
      event: start
  action:
    - delay: "0:00:30"
    - service: homeassistant.update_entity
      entity_id: sensor.ssl_certificate_expiry
1 Like

Yes, that is correct. Works like a charm.

any idea why i do not see days?

image

any idea? my did not show any info.

image

Hi all. Does anybody know what is the name of variable/attribute for currently left days? I setup following automation to receive Pushbullet message:

  • id: ‘1584111101296’
    alias: SSL Certificate Expire
    description: ‘’
    trigger:
    • below: ‘4’
      entity_id: sensor.ssl_certificate_expiry
      platform: numeric_state
    • below: ‘3’
      entity_id: sensor.ssl_certificate_expiry
      platform: numeric_state
    • below: ‘2’
      entity_id: sensor.ssl_certificate_expiry
      platform: numeric_state
      condition:
    • below: ‘4’
      condition: numeric_state
      entity_id: sensor.ssl_certificate_expiry
    • below: ‘3’
      condition: numeric_state
      entity_id: sensor.ssl_certificate_expiry
    • below: ‘2’
      condition: numeric_state
      entity_id: sensor.ssl_certificate_expiry
      action:
    • data:
      message: Hi! This is automated message by Home Assistant - your SSL certificate
      is expiring by {{ state_attr(‘sensor.ssl_certificate_expiry’, ‘???’) }} days!
      target:
      • device/telephone
      • email/[email protected]
      • channel/my_home
        service: notify.pushbullet_stiw47

What should I put in message body instead of question marks, in order to get number which is stated on lovelace?

Thanks.

states(‘sensor.ssl_certificate_expiry’)

1 Like

Anyone who has come to this thread recently, please note this is quite an old thread and there are much better ways of doing this these days, like using an addon that automatically manages your certs, or use the built-in homeassistant sensor.

I’ve updated the OP with a similar note.