diff --git a/custom_components/saleryd_hrv/__init__.py b/custom_components/saleryd_hrv/__init__.py index 7270ac4..eda0ead 100644 --- a/custom_components/saleryd_hrv/__init__.py +++ b/custom_components/saleryd_hrv/__init__.py @@ -18,6 +18,8 @@ DOMAIN, PLATFORMS, STARTUP_MESSAGE, + SUPPORTED_FIRMWARES, + UNSUPPORTED_FIRMWARES, ) from .coordinator import SalerydLokeDataUpdateCoordinator @@ -26,6 +28,24 @@ _LOGGER: logging.Logger = logging.getLogger(__package__) +def log_unsupported_firmware(data): + """Write to logs if firmware version is unsupported""" + version = data.get("*SC") + if version: + if version not in SUPPORTED_FIRMWARES: + _LOGGER.warning( + "Your control system version is (%s). This integration has been verified to work with the following versions: %s", + version, + ", ".join(SUPPORTED_FIRMWARES), + ) + if version in UNSUPPORTED_FIRMWARES: + _LOGGER.error( + "Your control system version is (%s). This integration is incompatible with the following versions: %s", + version, + ", ".join(UNSUPPORTED_FIRMWARES), + ) + + async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up this integration using UI.""" if hass.data.get(DOMAIN) is None: @@ -50,7 +70,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): update_interval=SCAN_INTERVAL, ) + await asyncio.sleep( + SCAN_INTERVAL.seconds + ) # sleep to ensure coordinator collects all data await coordinator.async_config_entry_first_refresh() + log_unsupported_firmware(coordinator.data) hass.data[DOMAIN][entry.entry_id] = coordinator diff --git a/custom_components/saleryd_hrv/coordinator.py b/custom_components/saleryd_hrv/coordinator.py index e20a23a..44641fe 100644 --- a/custom_components/saleryd_hrv/coordinator.py +++ b/custom_components/saleryd_hrv/coordinator.py @@ -6,7 +6,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pysaleryd.client import Client -from .const import CLIENT_STATE, DOMAIN, SUPPORTED_FIRMWARES, UNSUPPORTED_FIRMWARES +from .const import CLIENT_STATE, DOMAIN _LOGGER: logging.Logger = logging.getLogger(__package__) @@ -23,19 +23,5 @@ def __init__(self, hass: HomeAssistant, client: Client, update_interval) -> None async def _async_update_data(self): """Fetch the latest data from the source.""" data = self.client.data - version = data.get("*SC") - if version: - if version not in SUPPORTED_FIRMWARES: - _LOGGER.warning( - "Your control system version is (%s). This integration has been verified to work with the following versions: %s", - version, - ", ".join(SUPPORTED_FIRMWARES), - ) - if version in UNSUPPORTED_FIRMWARES: - _LOGGER.error( - "Your control system version is (%s). This integration is incompatible with the following versions: %s", - version, - ", ".join(UNSUPPORTED_FIRMWARES), - ) data[CLIENT_STATE] = self.client.state return data diff --git a/custom_components/saleryd_hrv/manifest.json b/custom_components/saleryd_hrv/manifest.json index 484641e..97b2fce 100644 --- a/custom_components/saleryd_hrv/manifest.json +++ b/custom_components/saleryd_hrv/manifest.json @@ -8,9 +8,9 @@ "documentation": "https://github.com/bj00rn/ha-saleryd-ftx", "integration_type": "device", "iot_class": "local_push", - "issue_tracker": "https://github.com/bj00rn/ha-saleryd-ftx", + "issue_tracker": "https://github.com/bj00rn/ha-saleryd-ftx/issues", "requirements": [ "pysaleryd>=3.0.6" ], - "version": "2.2.0" + "version": "2.2.1" }