diff --git a/custom_components/peaqev/manifest.json b/custom_components/peaqev/manifest.json index 49a3f125..aed11d19 100644 --- a/custom_components/peaqev/manifest.json +++ b/custom_components/peaqev/manifest.json @@ -13,7 +13,9 @@ "tibber", "filter", "integration", - "utility_meter" + "utility_meter", + "shelly", + "template" ], "codeowners": [ "@elden1337" diff --git a/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py b/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py index 47e9da35..8535a306 100644 --- a/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py +++ b/custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py @@ -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 @@ -29,6 +30,7 @@ def __init__( self, hub: HomeAssistantHub, charger_states: dict, charger_type: ChargerType ): self._aux_running_grace_timer = WaitTimer(timeout=300, init_now=True) + self.latest_init_check: float = time.time() super().__init__(hub, charger_states, charger_type) @property @@ -43,7 +45,11 @@ def status_string(self) -> str: def _check_initialized(self) -> bool: if self.model.is_initialized: return True + if time.time() - self.latest_init_check < 10: + return False + self.latest_init_check = time.time() _state = self.hub.state_machine.states.get(self.hub.options.powersensor) + _LOGGER.debug(f'Checking if initialized {self.hub.options.powersensor}. State: {_state.state or None}') if _state is not None: try: float_state = float(_state.state) diff --git a/custom_components/peaqev/peaqservice/hub/observer/iobserver_coordinator.py b/custom_components/peaqev/peaqservice/hub/observer/iobserver_coordinator.py index eea649c3..3b04401b 100644 --- a/custom_components/peaqev/peaqservice/hub/observer/iobserver_coordinator.py +++ b/custom_components/peaqev/peaqservice/hub/observer/iobserver_coordinator.py @@ -58,7 +58,8 @@ def add(self, command: ObserverTypes | str, func): async def async_broadcast(self, command: ObserverTypes | str, argument=None): command = self._check_and_convert_enum_type(command) self.broadcast(command, argument) - await self.async_dispatch() + if len(self.model.broadcast_queue) > 10: + await self.async_dispatch() def broadcast(self, command: ObserverTypes | str, argument=None): command = self._check_and_convert_enum_type(command)