From 5ea46b53ee73a426b341a0c68e7be450716772b7 Mon Sep 17 00:00:00 2001 From: hultenvp <61835400+hultenvp@users.noreply.github.com> Date: Sun, 9 Jul 2023 11:09:15 +0200 Subject: [PATCH] Robustness against offline inverters --- custom_components/solis/soliscloud_api.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/custom_components/solis/soliscloud_api.py b/custom_components/solis/soliscloud_api.py index 3eecd46..d145634 100644 --- a/custom_components/solis/soliscloud_api.py +++ b/custom_components/solis/soliscloud_api.py @@ -29,7 +29,7 @@ _LOGGER = logging.getLogger(__name__) # VERSION -VERSION = '0.4.3' +VERSION = '0.4.4' # API NAME API_NAME = 'SolisCloud' @@ -461,9 +461,13 @@ def _post_process(self) -> None: # just making 0 voltage. So this is too simplistic. # mypy trips over self_data[STRING_COUNT] as it could be of type str, int or float # needs to be fixed at some point in time, but this works. - for i, stringlist in enumerate(STRING_LISTS): - if i > int(self._data[STRING_COUNT]): - self._purge_if_unused(0, *stringlist) + try: + for i, stringlist in enumerate(STRING_LISTS): + if i > int(self._data[STRING_COUNT]): + self._purge_if_unused(0, *stringlist) + except KeyError: + # Ignore offline inverters + pass def _fix_units(self, num_key: str, units_key: str) -> None: """ Convert numeric values according to the units reported by the API. """