Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/cert_expiry/.translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"error": {
"certificate_fetch_failed": "Can not fetch certificate from this host and port combination",
"connection_timeout": "Timeout whemn connecting to this host",
"connection_timeout": "Timeout when connecting to this host",
"host_port_exists": "This host and port combination is already configured",
"resolve_failed": "This host can not be resolved"
},
Expand All @@ -21,4 +21,4 @@
},
"title": "Certificate Expiry"
}
}
}
14 changes: 3 additions & 11 deletions homeassistant/components/cert_expiry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""The cert_expiry component."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType


Expand All @@ -13,13 +11,7 @@ async def async_setup(hass, config):
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Load the saved entities."""

@callback
def async_start(_):
"""Load the entry after the start event."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "sensor")
)

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, async_start)

hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "sensor")
)
return True
18 changes: 17 additions & 1 deletion homeassistant/components/cert_expiry/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT
from homeassistant.const import (
CONF_NAME,
CONF_HOST,
CONF_PORT,
EVENT_HOMEASSISTANT_START,
)
from homeassistant.core import callback
from homeassistant.helpers.entity import Entity

from .const import DOMAIN, DEFAULT_NAME, DEFAULT_PORT
Expand Down Expand Up @@ -82,6 +88,16 @@ def available(self):
"""Icon to use in the frontend, if any."""
return self._available

async def async_added_to_hass(self):
"""Once the entity is added we should update to get the initial data loaded."""

@callback
Comment thread
cereal2nd marked this conversation as resolved.
Outdated
def do_update(_):
"""Run the update method when the start event was fired."""
self.update()

self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, do_update)

def update(self):
"""Fetch the certificate information."""
try:
Expand Down