Certification expiry doesn't work on bootup

I had discussion about this in the chat yesterday and my hunch was correct. I am using the duckdns + ld addon in Hassio. I have my cert_expiry component setup


  • platform: cert_expiry
    host: xxxx.duckdns,org

Port 443 is forwarded to 8123 in my routers. I can access Hassio just fine from outside and authenticate with the PW over ssl.

But the sensor doesn’t work on boot-up. However I assume after midnight it checks again or it checks every so often . so eventually it started working and is working right now.

Just letting everyone know. I assume if I reboot it will go back to unknown until it checks again then start working.

Annoying! It only updates every 12 hours, and it tries to update on boot, but before the web server is up, so fails.

I have worked around this using a template sensor, and a SQL query.

- platform: cert_expiry
  host: !secret secret_ha_url
  port: !secret secret_ha_port
  name: SSL certificate expiry

- platform: sql
  db_url: !secret secret_db_url
    - name: ssl_certificate_expiry_last_valid
      query: 'SELECT state FROM states WHERE entity_id = "sensor.ssl_certificate_expiry" and state <> "unknown" order by created desc limit 1'
      column: 'state'

- platform: template
      friendly_name: 'SSL Certificate Expiry'
      unit_of_measurement: 'days'
      value_template: >-
        {% if states.sensor.SSL_certificate_expiry.state != "unknown" %}
          {{ states.sensor.SSL_certificate_expiry.state }}
        {% else %}
          {{ states.sensor.SSL_certificate_expiry_last_valid.state }}
        {% endif %}
1 Like