Skip to content

Commit

Permalink
misc startup failures fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Jun 13, 2024
1 parent aa24acf commit e878109
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion custom_components/peaqev/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"tibber",
"filter",
"integration",
"utility_meter"
"utility_meter",
"shelly",
"template"
],
"codeowners": [
"@elden1337"
Expand Down
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 Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e878109

Please sign in to comment.