8000 Cert-expiry component on domain of the hass instance can't connect yet in startup · Issue #7481 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Cert-expiry component on domain of the hass instance can't connect yet in startup #7481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Maxr1998 opened this issue May 7, 2017 · 7 comments · Fixed by #8920
Closed

Cert-expiry component on domain of the hass instance can't connect yet in startup #7481

Maxr1998 opened this issue May 7, 2017 · 7 comments · Fixed by #8920

Comments

@Maxr1998
Copy link
Maxr1998 commented May 7, 2017

Home Assistant release (hass --version):

  • 0.44

Component/platform:

  • https certificate expiry component

Description of problem:

  • When using this component on the IP of the home assistant instance, the first refresh happens while the server isn't available yet and fails with [homeassistant.components.sensor.cert_expiry] Cannot connect to <domain>. As a result, the UI shows unknown days for the first 12 hours (until another refresh happens).

Expected:

  • Sensor immediately shows the right value for the certificate after hass start.

@fabfurnari

@Maxr1998 Maxr1998 changed the title Cert expiry component on home assistant instance can't connect yet in startup Cert-expiry component on domain of the hass instance can't connect yet in startup May 7, 2017
@arsaboo
Copy link
Contributor
arsaboo commented May 7, 2017

I had the same error. I am using a duckdns.org subdomain. I tried both with and without https://

@cbrherms
Copy link
Contributor
cbrherms commented May 9, 2017

Same issue here. Fails on first run during startup but works fine on second run at 12hr mark

@mukundv
Copy link
mukundv commented May 24, 2017

Can confirm the issue still exists in 0.45.1
hass --version
0.45.1

/home/homeassistant/.homeassistant/home-assistant.log
2017-05-24 20:36:29 ERROR (Thread-9) [homeassistant.components.sensor.cert_expiry] Cannot connect to <domain>.duckdns.org

@cbrherms
Copy link
Contributor

Any way to change how this inits so it fire's off either at the end of startup or a couple of minutes in?

@daenny
Copy link
Contributor
daenny commented Jul 27, 2017

I fixed this for me like this. It's not the nicest way, and the 2 second sleep was trial and error. But this works for me.
I do not know how else I would check, if the web-server finished loading.
To test, you can just copy the cert_expiry.py into <ha_config_dir>/custom_components/sensor/
and replace the setup_platform like this:

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up certificate expiry sensor."""
    server_name = config.get(CONF_HOST)
    server_port = config.get(CONF_PORT)
    sensor_name = config.get(CONF_NAME)

    ssl_entity = SSLCertificate(sensor_name, server_name, server_port)

    def update_on_start(event):
        """If no state yet, wait for server to start and force refresh."""
        if ssl_entity.state is None:
            from time import sleep
            sleep(2.0)
            ssl_entity.schedule_update_ha_state(force_refresh=True)

    hass.bus.listen_once(EVENT_HOMEASSISTANT_START, update_on_start)
    add_devices([ssl_entity], True)

@arsaboo
Copy link
Contributor
arsaboo commented Jul 28, 2017

#8683 should fix the errors. It essentially delays the firing by 2 minutes as @daenny suggested, but uses Throttle, which is more async friendly. Feel free to try it out in custom_components.

@Maxr1998
Copy link
Author

@arsaboo thanks for the fix!

@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants
0