From 81fd3b894f5e4e3fc4d66f29b3bb57d8ee703da0 Mon Sep 17 00:00:00 2001 From: dreautall <109872040+dreautall@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:34:40 +0000 Subject: [PATCH] look in all initially fetched data for MR entry ref https://github.com/dreautall/ha-stromnetzgraz/issues/12 --- src/sngraz/__init__.py | 2 +- src/sngraz/sngraz.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sngraz/__init__.py b/src/sngraz/__init__.py index b3a4214..266e67d 100644 --- a/src/sngraz/__init__.py +++ b/src/sngraz/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.1.7" +__version__ = "0.1.8" from .sngraz import * diff --git a/src/sngraz/sngraz.py b/src/sngraz/sngraz.py index be0d9f1..00efbae 100644 --- a/src/sngraz/sngraz.py +++ b/src/sngraz/sngraz.py @@ -416,11 +416,15 @@ async def get_first_reading(self) -> Optional[int]: startTime += dt.timedelta(days=7) endTime = startTime + dt.timedelta(days=7) - if "MR" not in resp[0]: + for res in resp: + if "MR" in res: + break + + if "MR" not in res: _LOGGER.warning("first reading does not contain a meter reading value") return None - self._first_reading = resp[0].get("MR") + self._first_reading = res.get("MR") return self._first_reading @property