Skip to content

Commit

Permalink
last PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tmenguy committed Aug 17, 2024
1 parent 542f9b9 commit c608134
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/pyatmo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@
ACCESSORY_WIND_TIME_TYPE = "wind_timeutc"
ACCESSORY_GUST_STRENGTH_TYPE = "gust_strength"
ACCESSORY_GUST_ANGLE_TYPE = "gust_angle"

# 2 days of dynamic historical data stored
MAX_HISTORY_TIME_FRAME = 24 * 2 * 3600
8 changes: 4 additions & 4 deletions src/pyatmo/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def update_topology(self, raw_data: RawData) -> None:

async def update(self, raw_data: RawData, do_raise_for_reachability_error=False) -> None:
"""Update home with the latest data."""
num_errors = 0
has_error = False
for module in raw_data.get("errors", []):
num_errors += 1
has_error = True
await self.modules[module["id"]].update({})

data = raw_data["home"]
Expand Down Expand Up @@ -164,8 +164,8 @@ async def update(self, raw_data: RawData, do_raise_for_reachability_error=False)
],
)

if (do_raise_for_reachability_error and
num_errors > 0
if (do_raise_for_reachability_error
and has_error
and has_one_module_reachable is False
and has_an_update is False
):
Expand Down
6 changes: 1 addition & 5 deletions src/pyatmo/modules/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from operator import itemgetter
from typing import TYPE_CHECKING, Any

from pyatmo.const import RawData
from pyatmo.const import RawData, MAX_HISTORY_TIME_FRAME
from pyatmo.modules.device_types import DeviceType

if TYPE_CHECKING:
Expand Down Expand Up @@ -60,10 +60,6 @@ class EntityBase:
name: str | None


# 2 days of dynamic historical data stored
MAX_HISTORY_TIME_FRAME = 24 * 2 * 3600


class NetatmoBase(EntityBase, ABC):
"""Base class for Netatmo entities."""

Expand Down

0 comments on commit c608134

Please sign in to comment.