pypetkitapi 1.13.0__py3-none-any.whl → 1.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pypetkitapi/__init__.py +1 -1
- pypetkitapi/client.py +27 -1
- pypetkitapi/containers.py +38 -1
- {pypetkitapi-1.13.0.dist-info → pypetkitapi-1.15.0.dist-info}/METADATA +1 -1
- {pypetkitapi-1.13.0.dist-info → pypetkitapi-1.15.0.dist-info}/RECORD +7 -7
- {pypetkitapi-1.13.0.dist-info → pypetkitapi-1.15.0.dist-info}/LICENSE +0 -0
- {pypetkitapi-1.13.0.dist-info → pypetkitapi-1.15.0.dist-info}/WHEEL +0 -0
pypetkitapi/__init__.py
CHANGED
pypetkitapi/client.py
CHANGED
@@ -38,7 +38,14 @@ from pypetkitapi.const import (
|
|
38
38
|
PetkitDomain,
|
39
39
|
PetkitEndpoint,
|
40
40
|
)
|
41
|
-
from pypetkitapi.containers import
|
41
|
+
from pypetkitapi.containers import (
|
42
|
+
AccountData,
|
43
|
+
Device,
|
44
|
+
Pet,
|
45
|
+
PetDetails,
|
46
|
+
RegionInfo,
|
47
|
+
SessionInfo,
|
48
|
+
)
|
42
49
|
from pypetkitapi.exceptions import (
|
43
50
|
PetkitAuthenticationError,
|
44
51
|
PetkitAuthenticationUnregisteredEmailError,
|
@@ -227,6 +234,18 @@ class PetKitClient:
|
|
227
234
|
raise PetkitSessionError("No session ID available")
|
228
235
|
return {"F-Session": self._session.id, "X-Session": self._session.id}
|
229
236
|
|
237
|
+
async def _get_pet_details(self) -> list[PetDetails]:
|
238
|
+
"""Fetch pet details from the PetKit API."""
|
239
|
+
_LOGGER.debug("Fetching user details")
|
240
|
+
response = await self.req.request(
|
241
|
+
method=HTTPMethod.GET,
|
242
|
+
url=PetkitEndpoint.DETAILS,
|
243
|
+
headers=await self.get_session_id(),
|
244
|
+
)
|
245
|
+
user_details = response.get("user", {})
|
246
|
+
dogs = user_details.get("dogs", [])
|
247
|
+
return [PetDetails(**dog) for dog in dogs]
|
248
|
+
|
230
249
|
async def _get_account_data(self) -> None:
|
231
250
|
"""Get the account data from the PetKit service."""
|
232
251
|
_LOGGER.debug("Fetching account data")
|
@@ -253,6 +272,13 @@ class PetKitClient:
|
|
253
272
|
uniqueId=str(pet.sn),
|
254
273
|
)
|
255
274
|
|
275
|
+
# Fetch pet details and update pet information
|
276
|
+
pet_details_list = await self._get_pet_details()
|
277
|
+
for pet_details in pet_details_list:
|
278
|
+
pet_id = pet_details.id
|
279
|
+
if pet_id in self.petkit_entities:
|
280
|
+
self.petkit_entities[pet_id].pet_details = pet_details
|
281
|
+
|
256
282
|
async def get_devices_data(self) -> None:
|
257
283
|
"""Get the devices data from the PetKit servers."""
|
258
284
|
start_time = datetime.now()
|
pypetkitapi/containers.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Dataclasses container for petkit API."""
|
2
2
|
|
3
|
+
from typing import Any
|
4
|
+
|
3
5
|
from pydantic import BaseModel, Field, field_validator
|
4
6
|
|
5
7
|
|
@@ -68,6 +70,40 @@ class Device(BaseModel):
|
|
68
70
|
return value
|
69
71
|
|
70
72
|
|
73
|
+
class PetDetails(BaseModel):
|
74
|
+
"""Dataclass for pet details.
|
75
|
+
Subclass of Pet.
|
76
|
+
"""
|
77
|
+
|
78
|
+
active_degree: int | None = Field(None, alias="activeDegree")
|
79
|
+
avatar: str | None = None
|
80
|
+
birth: str | None = None
|
81
|
+
block_time: int | None = Field(None, alias="blockTime")
|
82
|
+
blocke: int | None = None
|
83
|
+
body_info: dict[str, Any] | None = Field(None, alias="bodyInfo")
|
84
|
+
category: dict[str, Any]
|
85
|
+
created_at: str | None = Field(None, alias="createdAt")
|
86
|
+
device_count: int | None = Field(None, alias="deviceCount")
|
87
|
+
emotion: int | None = None
|
88
|
+
family_id: int | None = Field(None, alias="familyId")
|
89
|
+
female_state: int | None = Field(None, alias="femaleState")
|
90
|
+
gender: int | None = None
|
91
|
+
id: int | None = None
|
92
|
+
is_royal_canin_pet: int | None = Field(None, alias="isRoyalCaninPet")
|
93
|
+
male_state: int | None = Field(None, alias="maleState")
|
94
|
+
name: str | None = None
|
95
|
+
oms_discern_pic: dict[str, Any] | None = Field(None, alias="omsDiscernPic")
|
96
|
+
owner: dict[str, Any] | None = None
|
97
|
+
size: dict[str, Any] | None = None
|
98
|
+
states: list[Any] | None = None
|
99
|
+
type: dict[str, Any] | None = None
|
100
|
+
updated_at: str | None = Field(None, alias="updatedAt")
|
101
|
+
weight: float | None = None
|
102
|
+
weight_control: int | None = Field(None, alias="weightControl")
|
103
|
+
weight_control_tips: dict[str, Any] | None = Field(None, alias="weightControlTips")
|
104
|
+
weight_label: str | None = Field(None, alias="weightLabel")
|
105
|
+
|
106
|
+
|
71
107
|
class Pet(BaseModel):
|
72
108
|
"""Dataclass for pet data.
|
73
109
|
Subclass of AccountData.
|
@@ -81,7 +117,8 @@ class Pet(BaseModel):
|
|
81
117
|
sn: str | None = None # Fictive field copied from id (for HA compatibility)
|
82
118
|
name: str | None = None # Fictive field copied from pet_name (for HA compatibility)
|
83
119
|
firmware: str | None = None # Fictive fixed field (for HA compatibility)
|
84
|
-
device_nfo: Device | None = None
|
120
|
+
device_nfo: Device | None = None
|
121
|
+
pet_details: PetDetails | None = None
|
85
122
|
|
86
123
|
# Litter stats
|
87
124
|
last_litter_usage: int | None = None
|
@@ -1,9 +1,9 @@
|
|
1
|
-
pypetkitapi/__init__.py,sha256=
|
1
|
+
pypetkitapi/__init__.py,sha256=sEgLSfzU-CM7h7-yfbyp_wr7WhyOl7Txz03Vh0VrDOE,2107
|
2
2
|
pypetkitapi/bluetooth.py,sha256=1zEZIrKNTttrZpqBiQ-6V37Uphft5_T8CH9OBfYjwxE,9915
|
3
|
-
pypetkitapi/client.py,sha256=
|
3
|
+
pypetkitapi/client.py,sha256=cn3JIh-3AU5Rzka2rX7FgkSfWeQCG9Vw82-moK_rOPY,30889
|
4
4
|
pypetkitapi/command.py,sha256=sRLgV7bkG_kZAWf7Un_UNHL-OkJMH1GLD_RGgg9z8Mw,7515
|
5
5
|
pypetkitapi/const.py,sha256=aAUPBZC56MwbAiDRsSHRvDI5zTy-lZP8uLk-gHPeT7g,4763
|
6
|
-
pypetkitapi/containers.py,sha256=
|
6
|
+
pypetkitapi/containers.py,sha256=7wYKmaoBpMKrqIVMsoD4Iv2in7Kh5nNxrl4vC4eF2fg,6305
|
7
7
|
pypetkitapi/exceptions.py,sha256=4BXUyYXLfZjNxdnOGJPjyE9ASIl7JmQphjws87jvHtE,1631
|
8
8
|
pypetkitapi/feeder_container.py,sha256=PhidWd5WpsZqtdKZy60PzE67YXgQfApjm8CqvMCHK3U,14743
|
9
9
|
pypetkitapi/litter_container.py,sha256=R79wHFKy6pTsHIPf7bJko1PGFsdI-JCAPK4zPyliBmQ,18559
|
@@ -13,7 +13,7 @@ pypetkitapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
pypetkitapi/schedule_container.py,sha256=ycIHeQHkVILDp7ZBjaVdGI_9rhHrgqeKBfvQAX3JMGE,2071
|
14
14
|
pypetkitapi/utils.py,sha256=z7325kcJQUburnF28HSXrJMvY_gY9007K73Zwxp-4DQ,743
|
15
15
|
pypetkitapi/water_fountain_container.py,sha256=5J0b-fDZYcFLNX2El7fifv8H6JMhBCt-ttxSow1ozRQ,6787
|
16
|
-
pypetkitapi-1.
|
17
|
-
pypetkitapi-1.
|
18
|
-
pypetkitapi-1.
|
19
|
-
pypetkitapi-1.
|
16
|
+
pypetkitapi-1.15.0.dist-info/LICENSE,sha256=u5jNkZEn6YMrtN4Kr5rU3TcBJ5-eAt0qMx4JDsbsnzM,1074
|
17
|
+
pypetkitapi-1.15.0.dist-info/METADATA,sha256=q3okbsikRZd38LsZQKABic_7teS3tVcB5rheUJH3oqI,6944
|
18
|
+
pypetkitapi-1.15.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
19
|
+
pypetkitapi-1.15.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|