Skip to content

Commit

Permalink
#317 typo
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Dec 12, 2023
1 parent 2a82e98 commit 524bfac
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import time
from typing import TYPE_CHECKING, Tuple

from peaqevcore.common.models.observer_types import ObserverTypes
Expand All @@ -27,6 +28,8 @@ class ChargeController(IChargeController):
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
Expand Down Expand Up @@ -101,6 +104,21 @@ async def async_get_status_connected(
)
return ChargeControllerStates.Error, True

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}")
await self.hub.observer.async_broadcast(ObserverTypes.KillswitchDead)
self._aux_running_grace_timer.reset()
elif status_type in [
ChargeControllerStates.Idle,
ChargeControllerStates.Done,
ChargeControllerStates.Error,
ChargeControllerStates.Connected
] and self.hub.sensors.carpowersensor.value > 0:
return
self._aux_running_grace_timer.update()


async def _should_start_charging(self) -> bool:
return all([
any([
Expand Down

0 comments on commit 524bfac

Please sign in to comment.