@@ -29,7 +29,6 @@ def __init__(self, config: OpenWBPro) -> None:
2929 self .__session = req .get_http_session ()
3030 self .client_error_context = ErrorTimerContext (
3131 f"openWB/set/chargepoint/{ self .config .id } /get/error_timestamp" , CP_ERROR , hide_exception = True )
32- self .old_chargepoint_state = ChargepointState ()
3332
3433 with SingleComponentUpdateContext (self .fault_state , update_always = False ):
3534 with self .client_error_context :
@@ -58,11 +57,12 @@ def set_current(self, current: float) -> None:
5857 def get_values (self ) -> None :
5958 with SingleComponentUpdateContext (self .fault_state ):
6059 chargepoint_state = self .request_values ()
61- self .store .set (chargepoint_state )
60+ if chargepoint_state is not None :
61+ # bei Fehler, aber Fehlezähler noch nicht abgelaufen, keine Werte mehr publishen.
62+ self .store .set (chargepoint_state )
6263
6364 def request_values (self ) -> ChargepointState :
6465 with self .client_error_context :
65- chargepoint_state = self .old_chargepoint_state
6666 ip_address = self .config .configuration .ip_address
6767 json_rsp = self .__session .get ('http://' + ip_address + '/connect.php' ).json ()
6868
@@ -97,15 +97,17 @@ def request_values(self) -> ChargepointState:
9797 chargepoint_state .rfid_timestamp = json_rsp ["rfid_timestamp" ]
9898
9999 self .validate_values (chargepoint_state )
100- self .old_chargepoint_state = chargepoint_state
101100 self .client_error_context .reset_error_counter ()
101+ return chargepoint_state
102102 if self .client_error_context .error_counter_exceeded ():
103103 chargepoint_state = ChargepointState ()
104104 chargepoint_state .plug_state = False
105105 chargepoint_state .charge_state = False
106- chargepoint_state .imported = self .old_chargepoint_state .imported
107- chargepoint_state .exported = self .old_chargepoint_state .exported
108- return chargepoint_state
106+ chargepoint_state .imported = None # bei None werden keine Werte gepublished
107+ chargepoint_state .exported = None
108+ return chargepoint_state
109+ else :
110+ return None
109111
110112 def validate_values (self , chargepoint_state : ChargepointState ) -> None :
111113 if chargepoint_state .charge_state is False and max (chargepoint_state .currents ) > 1 :
0 commit comments