Skip to content

Commit

Permalink
fix: repair broken updates in HA 2024.2.1
Browse files Browse the repository at this point in the history
Since home-assistant/core@8d3f693 `update_interval` is a property with setter.
We MUST NOT overload it, because `_update_interval_seconds` was introduced and only new setter define it, but `_schedule_refresh` check its value, instead of checking `update_interval`

Fix #99
  • Loading branch information
IATkachenko committed Feb 10, 2024
1 parent af99e75 commit d043615
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions custom_components/yandex_weather/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from functools import cached_property
import json
import logging
import math
Expand Down Expand Up @@ -171,10 +170,11 @@ def __init__(
self.__api_key = api_key
self._lat = latitude
self._lon = longitude
self._updates_per_day = updates_per_day
self._device_id = device_id
self._name = name
self._language = language
# Site tariff have 50 free requests per day, but it may be changed
self.update_interval = timedelta(seconds=math.ceil((24 * 60 * 60) / updates_per_day))

if hass is not None:
super().__init__(
Expand All @@ -186,14 +186,6 @@ def __init__(
)
self.data = {}

@cached_property
def update_interval(self) -> timedelta:
"""How often we may send requests.
Site tariff have 50 free requests per day, but it may be changed
"""
return timedelta(seconds=math.ceil((24 * 60 * 60) / self._updates_per_day))

def process_data(self, dst: dict, src: dict, attributes: list[AttributeMapper]):
"""Convert Yandex API weather state to HA friendly.
Expand Down

0 comments on commit d043615

Please sign in to comment.