Sensor.ssl_certificate_expiry fails

HA: 0.104.1 (on Debian Buster)

Add this integration. Got the sensor with the days. But after a reboot I see a error. Remove the integration and add it again it is working again. But every time I reboot the error comes back

2020-01-17 10:50:27 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ssl_certificate_expiry fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/cert_expiry/sensor.py", line 122, in update
    cert = get_cert(self.server_name, self.server_port)
  File "/usr/src/homeassistant/homeassistant/components/cert_expiry/helper.py", line 12, in get_cert
    with socket.create_connection(address, timeout=TIMEOUT) as sock:
  File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I get exactly the same error when HA restarts. In my instance, it is because the cert_expiry integration in HA is trying to query the HA web site (i.e. it is HA integration trying to query its own web site) before the web site is fully up, and it therefore fails.

As annoying as it is, I have just ignored it and moved on to other things.

Someone else did a post somewhere and told when you do a reload of the core then it is working.

After HA is restarted you can do in developer tools service

homeassistant.update_entity

entity_id: sensor.ssl_certificate_expiry

my sensor is called: sensor.ssl_certificate_expiry

I’ve add this in a automation, when HA is done, it will start homekit, and do this action also again to get the expire value correct