Skip to content

Commit

Permalink
Remove action calls (don't seem to be working anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
lp55 committed Feb 4, 2025
1 parent 64cf64e commit ec7be86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
29 changes: 16 additions & 13 deletions surepy2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from math import ceil
from typing import Any
from uuid import uuid1
import asyncio

import aiohttp

Expand Down Expand Up @@ -406,18 +407,20 @@ async def get_entities(
else:
from_datetime, to_datetime = None

if raw_activities := await self.get_report(
entity.get("household_id", 0),
entity.get("id", 0),
aggregate=True,
from_datetime=from_datetime,
to_datetime=to_datetime,
):
surepy_entities[entity_id] = Pet(
data=entity, activities=raw_activities.get("data", {})
if response := (
await self.get_report(
entity.get("household_id", 0),
entity.get("id", 0),
aggregate=True,
from_datetime=from_datetime,
to_datetime=to_datetime,
)
):
raw_activities = response.get("data", {})
surepy_entities[entity_id] = Pet(data=entity, activities=raw_activities)
else:
surepy_entities[entity_id] = Pet(data=entity)
asyncio.sleep(3)

else:
surepy_entities[entity_id] = Pet(data=entity)
Expand All @@ -432,10 +435,10 @@ async def get_entities(
self.entities[entity_id] = surepy_entities[entity_id]

# fetch additional data about movement, feeding & drinking
for household_id in household_ids:
await self.get_actions(household_id=household_id)
for household_id in felaqua_household_ids:
await self.get_latest_anonymous_drinks(household_id=household_id)
# for household_id in household_ids:
# await self.get_actions(household_id=household_id)
# for household_id in felaqua_household_ids:
# await self.get_latest_anonymous_drinks(household_id=household_id)

# stupid idea, fix this
_ = [
Expand Down
5 changes: 2 additions & 3 deletions surepy2/entities/pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def __init__(self, data: dict[str, Any], activities: dict[str, Any] = {}):
self.pet_id: int = int(data["id"])

self._type: EntityType = EntityType.PET
self._data: dict[str, Any] = data
self._activities: dict[str, Any] = activities
self._data: dict[str, Any] = data | activities

self._name = str(name) if (name := self._data.get("name")) else "Unnamed"

Expand Down Expand Up @@ -145,7 +144,7 @@ def last_drink(self) -> datetime | None:

@property
def drinking_activity(self) -> list[DrinkingActivity] | None:
if datapoints := self._activities.get("drinking", {}).get("datapoints", {}):
if datapoints := self._data.get("drinking", {}).get("datapoints", {}):
return [
DrinkingActivity(
start=datetime.fromisoformat(data.get("from")),
Expand Down

0 comments on commit ec7be86

Please sign in to comment.