mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
fix(api): initialize time attribute to prevent AttributeError
Fixed uninitialized self.time attribute causing AttributeError during config entry creation. Added explicit initialization to None with Optional type annotation and guard in _get_price_info_for_specific_homes(). Impact: Config flow no longer crashes when creating initial config entry. Users can complete setup without errors.
This commit is contained in:
parent
ebd1b8ddbf
commit
7a1675a55a
1 changed files with 5 additions and 1 deletions
|
|
@ -46,7 +46,7 @@ class TibberPricesApiClient:
|
|||
self._session = session
|
||||
self._version = version
|
||||
self._request_semaphore = asyncio.Semaphore(2) # Max 2 concurrent requests
|
||||
self.time: TibberPricesTimeService # Set externally by coordinator (always initialized before use)
|
||||
self.time: TibberPricesTimeService | None = None # Set externally by coordinator (optional during config flow)
|
||||
self._last_request_time = None # Set on first request
|
||||
self._min_request_interval = timedelta(seconds=1) # Min 1 second between requests
|
||||
self._max_retries = 5
|
||||
|
|
@ -148,6 +148,10 @@ class TibberPricesApiClient:
|
|||
|
||||
async def _get_price_info_for_specific_homes(self, home_ids: set[str]) -> dict:
|
||||
"""Get price info for specific homes using GraphQL aliases."""
|
||||
if not self.time:
|
||||
msg = "TimeService not initialized - required for price info processing"
|
||||
raise TibberPricesApiClientError(msg)
|
||||
|
||||
if not home_ids:
|
||||
return {"homes": {}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue