diff --git a/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py b/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py index 4833c291..49b89fba 100644 --- a/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py +++ b/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py @@ -1,7 +1,6 @@ from __future__ import annotations import logging -import time from typing import TYPE_CHECKING, Tuple from peaqevcore.common.models.observer_types import ObserverTypes @@ -11,7 +10,7 @@ if TYPE_CHECKING: from custom_components.peaqev.peaqservice.hub.hub import HomeAssistantHub - +from peaqevcore.common.wait_timer import WaitTimer from peaqevcore.models.chargecontroller_states import ChargeControllerStates from custom_components.peaqev.peaqservice.chargecontroller.chargecontroller_helpers import \ @@ -29,7 +28,6 @@ def __init__( self, hub: HomeAssistantHub, charger_states: dict, charger_type: ChargerType ): self._aux_running_grace_timer = WaitTimer(timeout=300, init_now=True) - self._init_time = time.time() super().__init__(hub, charger_states, charger_type) @property @@ -106,7 +104,7 @@ async def async_get_status_connected( async def _aux_check_running_charger_mismatch(self, status_type: ChargeControllerStates) -> None: if self._aux_running_grace_timer.is_timeout(): - _LOGGER.warning(f"Charger seems to be running without Peaqev controlling it. Attempting aux stop. If you wish to charge without Peaqev you need to disable it on the switch. {self._aux_running_grace_timer.value}, {self._aux_running_grace_timer.timeout}, {self._init_time}") + _LOGGER.warning(f"Charger seems to be running without Peaqev controlling it. Attempting aux stop. If you wish to charge without Peaqev you need to disable it on the switch.") await self.hub.observer.async_broadcast(ObserverTypes.KillswitchDead) self._aux_running_grace_timer.reset() elif status_type in [ diff --git a/custom_components/peaqev/peaqservice/chargecontroller/charger/charger.py b/custom_components/peaqev/peaqservice/chargecontroller/charger/charger.py index 66a53d04..cb143adc 100644 --- a/custom_components/peaqev/peaqservice/chargecontroller/charger/charger.py +++ b/custom_components/peaqev/peaqservice/chargecontroller/charger/charger.py @@ -29,7 +29,7 @@ def __init__(self, controller): self.model = ChargerModel() self.helpers = ChargerHelpers(self) self.controller.hub.observer.add(ObserverTypes.PowerCanaryDead, self.async_pause_charger) - self.controller.hub.observer.add(ObserverTypes.KillswitchDead, self.async_pause_charger) + self.controller.hub.observer.add(ObserverTypes.KillswitchDead, self.async_terminate_charger) self.controller.hub.observer.add(ObserverTypes.CarConnected, self.async_reset_session) self.controller.hub.observer.add(ObserverTypes.ProcessCharger, self.async_charge) diff --git a/custom_components/peaqev/peaqservice/chargecontroller/ichargecontroller.py b/custom_components/peaqev/peaqservice/chargecontroller/ichargecontroller.py index bbd77d8d..1fc1ab71 100644 --- a/custom_components/peaqev/peaqservice/chargecontroller/ichargecontroller.py +++ b/custom_components/peaqev/peaqservice/chargecontroller/ichargecontroller.py @@ -122,6 +122,10 @@ async def async_set_status(self) -> None: except Exception as e: _LOGGER.debug(f"Error in async_set_status2: {e}") + @abstractmethod + async def _aux_check_running_charger_mismatch(self, status_type: ChargeControllerStates) -> None: + pass + async def async_set_status_type(self, status_type: ChargeControllerStates) -> None: try: if isinstance(status_type, ChargeControllerStates): @@ -132,6 +136,7 @@ async def async_set_status_type(self, status_type: ChargeControllerStates) -> No self.model.status_type = status_type if self.model.charger_type is not ChargerType.NoCharger: #todo: strategy should handle this await self.hub.observer.async_broadcast(ObserverTypes.ProcessCharger) + await self._aux_check_running_charger_mismatch(status_type) except Exception as e: _LOGGER.debug(f"Error in async_set_status_type: {e}")