File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 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
177177def 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 ,
You can’t perform that action at this time.
0 commit comments