Skip to content

Commit

Permalink
look in all initially fetched data for MR entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dreautall committed Dec 30, 2023
1 parent f4ed610 commit 81fd3b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sngraz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.1.7"
__version__ = "0.1.8"

from .sngraz import *
8 changes: 6 additions & 2 deletions src/sngraz/sngraz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 81fd3b8

Please sign in to comment.