From d7cc309b833e15059a2d9e02fc6afdf0ab43ae42 Mon Sep 17 00:00:00 2001 From: Michel Belleau Date: Mon, 13 Dec 2021 13:47:48 -0500 Subject: [PATCH] Upon SuspendEVSE or SuspendedEV events, energy flow is assumed to be 0 in both directions (import and export) (#235) --- custom_components/ocpp/api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index 1e5aa482..a9f5b124 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -966,6 +966,12 @@ def on_status_notification(self, connector_id, error_code, status, **kwargs): self._metrics[Measurand.power_active_import.value].value = 0 if Measurand.power_reactive_import.value in self._metrics: self._metrics[Measurand.power_reactive_import.value].value = 0 + if Measurand.current_export.value in self._metrics: + self._metrics[Measurand.current_export.value].value = 0 + if Measurand.power_active_export.value in self._metrics: + self._metrics[Measurand.power_active_export.value].value = 0 + if Measurand.power_reactive_export.value in self._metrics: + self._metrics[Measurand.power_reactive_export.value].value = 0 self._metrics[cstat.error_code.value].value = error_code self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.StatusNotificationPayload() @@ -1020,6 +1026,12 @@ def on_stop_transaction(self, meter_stop, timestamp, transaction_id, **kwargs): self._metrics[Measurand.power_active_import.value].value = 0 if Measurand.power_reactive_import.value in self._metrics: self._metrics[Measurand.power_reactive_import.value].value = 0 + if Measurand.current_export.value in self._metrics: + self._metrics[Measurand.current_export.value].value = 0 + if Measurand.power_active_export.value in self._metrics: + self._metrics[Measurand.power_active_export.value].value = 0 + if Measurand.power_reactive_export.value in self._metrics: + self._metrics[Measurand.power_reactive_export.value].value = 0 self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.StopTransactionPayload( id_tag_info={om.status.value: AuthorizationStatus.accepted.value}