Skip to content

Commit

Permalink
Added check for invalid total energy readings
Browse files Browse the repository at this point in the history
  • Loading branch information
sockless-coding committed Oct 27, 2021
1 parent 715a83c commit fd96ba6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions custom_components/garo_wallbox/garo.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def _do_update(self):


response_json = await response.json()
self._status = GaroStatus(response_json)
self._status = GaroStatus(response_json, self._status)

async def async_get_info(self):
response = await self._session.request(method='GET', url=self.__get_url('config', True))
Expand Down Expand Up @@ -138,7 +138,7 @@ def __get_url(self, action, add_tick = False):

class GaroStatus:

def __init__(self,response):
def __init__(self,response, prev_status):
self.ocpp_state = response['ocppState']
self.free_charging = response['freeCharging']
self.ocpp_connection_state = response['ocppConnectionState']
Expand All @@ -153,8 +153,12 @@ def __init__(self,response):
if self.current_charging_power > 32000:
self.current_charging_power = 0
self.acc_session_energy = response['accSessionEnergy']
self.latest_reading = response['latestReading']
self.latest_reading_k = max(0,response['latestReading'] /1000)
last_reading = response['latestReading']
if prev_status is not None and last_reading - prev_status.latest_reading > 500000:
last_reading = prev_status.latest_reading

self.latest_reading = last_reading
self.latest_reading_k = max(0,last_reading /1000)
self.current_temperature = response['currentTemperature']
self.pilot_level = response['pilotLevel']
self.session_start_value = response['sessionStartValue']
Expand Down

0 comments on commit fd96ba6

Please sign in to comment.