Skip to content

Commit 8f249dd

Browse files
authored
Update wallbox_monitor.py
1 parent 1975419 commit 8f249dd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

wallbox_monitor.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# v1.3
3+
# v1.3.1
44
# wallbox-monitoring - by bjoerrrn
55
# github: https://github.com/bjoerrrn/wallbox-monitoring
66
# This script is licensed under GNU GPL version 3.0 or above
@@ -175,6 +175,7 @@ def german_timestamp():
175175
return datetime.now().strftime("%d.%m.%y, %H:%M")
176176

177177
def get_last_state():
178+
data = "" # initialize before try
178179
try:
179180
with open(STATE_FILE, "r") as f:
180181
data = f.read().strip()
@@ -205,10 +206,11 @@ def get_last_state():
205206
"repeat_check": bool(int(repeat_check)), # NEW FLAG
206207
}
207208

208-
except (FileNotFoundError, ValueError, IndexError):
209+
except (FileNotFoundError, ValueError, IndexError) as e:
209210
logger.error("State file corrupted or missing. Resetting to default.")
210-
logger.error(f"State file content: {data}") # Debugging
211-
211+
logger.error(f"Exception: {e}, File content: {data}")
212+
213+
# Always return fallback
212214
return {
213215
"state": "idle",
214216
"start_time": None,

0 commit comments

Comments
 (0)