diff --git a/custom_components/solarman/coordinator.py b/custom_components/solarman/coordinator.py index 38405d6..3c45ac2 100644 --- a/custom_components/solarman/coordinator.py +++ b/custom_components/solarman/coordinator.py @@ -14,13 +14,21 @@ class InverterCoordinator(DataUpdateCoordinator[dict[str, Any]]): def __init__(self, hass: HomeAssistant, inverter: Inverter): - super().__init__(hass, _LOGGER, name = inverter.config.name, update_interval = TIMINGS_UPDATE_INTERVAL, always_update = False) + super().__init__( + hass, + _LOGGER, + name=inverter.config.name, + update_interval=TIMINGS_UPDATE_INTERVAL, + always_update=False, + ) self.inverter = inverter self._counter = 0 + self._last_successful_data: dict[str, Any] | None = None + self._is_offline_logged = False async def _async_setup(self) -> None: try: - return await self.inverter.load() + await self.inverter.load() except Exception as e: if isinstance(e, TimeoutError): raise @@ -28,11 +36,23 @@ async def _async_setup(self) -> None: async def _async_update_data(self) -> dict[str, Any]: try: - return await self.inverter.get(int(self._counter * self._update_interval_seconds)) + data = await self.inverter.get(int(self._counter * self._update_interval_seconds)) + self._last_successful_data = data + self._is_offline_logged = False + return data except Exception as e: self._counter = 0 + + if not self._is_offline_logged: + _LOGGER.warning("Error retrieving data. Use last known data.") + self._is_offline_logged = True + + if self._last_successful_data is not None: + return self._last_successful_data + if isinstance(e, TimeoutError): raise + raise UpdateFailed(e) from e finally: if self.last_update_success: diff --git a/custom_components/solarman/inverter_definitions/deye_micro.yaml b/custom_components/solarman/inverter_definitions/deye_micro.yaml index 5eeaf82..6d6c807 100644 --- a/custom_components/solarman/inverter_definitions/deye_micro.yaml +++ b/custom_components/solarman/inverter_definitions/deye_micro.yaml @@ -206,10 +206,10 @@ parameters: - key: "default" value: "Error" - - name: "Device Fault" + - name: "Device Fault 1" class: "enum" rule: 3 - registers: [0x0067, 0x0068, 0x0069, 0x006A] + registers: [0x0067] icon: "mdi:message-alert-outline" lookup: - key: 0x0000 @@ -242,11 +242,34 @@ parameters: value: "Arc Fault Reservation" - key: 0x2000 value: "Grid Current Sample Abnormality" - - key: 0x2030000 + - key: "default" + value: "Error" + + - name: "Device Fault 2" + class: "enum" + rule: 3 + registers: [0x0068] + icon: "mdi:message-alert-outline" + lookup: + - key: 0x0000 + value: "OK" + - key: 0x191 value: "Grid phase failure or No Relay Connection" - key: "default" value: "Error" + - name: "Device Debug 1" + class: "enum" + rule: 3 + registers: [0x0069] + icon: "mdi:message-alert-outline" + + - name: "Device Debug 2" + class: "enum" + rule: 3 + registers: [0x006A] + icon: "mdi:message-alert-outline" + - group: PV items: - name: PV Power diff --git a/custom_components/solarman/manifest.json b/custom_components/solarman/manifest.json index 1df8d05..d61efc4 100644 --- a/custom_components/solarman/manifest.json +++ b/custom_components/solarman/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/davidrapan/ha-solarman/issues", "requirements": ["propcache", "aiofiles", "pyyaml", "umodbus"], - "version": "24.12.22" + "version": "25.01.17" }