Skip to content

Commit

Permalink
Merge pull request #3 from bj00rn/chore/dont-spam-logs
Browse files Browse the repository at this point in the history
move firmware version check to integration setup
  • Loading branch information
bj00rn authored Jul 31, 2023
2 parents f574353 + 00a9550 commit eeb4bc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
24 changes: 24 additions & 0 deletions custom_components/saleryd_hrv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
DOMAIN,
PLATFORMS,
STARTUP_MESSAGE,
SUPPORTED_FIRMWARES,
UNSUPPORTED_FIRMWARES,
)
from .coordinator import SalerydLokeDataUpdateCoordinator

Expand All @@ -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:
Expand All @@ -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

Expand Down
16 changes: 1 addition & 15 deletions custom_components/saleryd_hrv/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
4 changes: 2 additions & 2 deletions custom_components/saleryd_hrv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit eeb4bc8

Please sign in to comment.