From 338cd910a96af36c46a76066bb534d1dabefc2ff Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Tue, 11 Jun 2024 11:11:36 +0000 Subject: [PATCH] issue with empty transaction #121 #124 --- custom_components/alfen_wallbox/alfen.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom_components/alfen_wallbox/alfen.py b/custom_components/alfen_wallbox/alfen.py index 3d1b1de..7be506c 100644 --- a/custom_components/alfen_wallbox/alfen.py +++ b/custom_components/alfen_wallbox/alfen.py @@ -342,8 +342,14 @@ async def _get_transaction(self): #_LOGGER.debug(response) # split this text into lines with \n lines = str(response).splitlines() + + # if the lines are empty, break the loop + if not lines or not response: + transactionLoop = False + break + for line in lines: - if line is None or response is None: + if line is None: transactionLoop = False break @@ -418,6 +424,10 @@ async def _get_transaction(self): elif 'dto' in line: continue + elif '0_Empty' in line: + # break if the transaction is empty + transactionLoop = False + break else: _LOGGER.debug(f"Unknown line: {line}") continue