pypetkitapi 1.13.0__tar.gz → 1.15.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypetkitapi
3
- Version: 1.13.0
3
+ Version: 1.15.0
4
4
  Summary: Python client for PetKit API
5
5
  License: MIT
6
6
  Author: Jezza34000
@@ -51,7 +51,7 @@ from .media import DownloadDecryptMedia, MediaCloud, MediaFile, MediaManager
51
51
  from .purifier_container import Purifier
52
52
  from .water_fountain_container import WaterFountain
53
53
 
54
- __version__ = "1.13.0"
54
+ __version__ = "1.15.0"
55
55
 
56
56
  __all__ = [
57
57
  "CTW3",
@@ -38,7 +38,14 @@ from pypetkitapi.const import (
38
38
  PetkitDomain,
39
39
  PetkitEndpoint,
40
40
  )
41
- from pypetkitapi.containers import AccountData, Device, Pet, RegionInfo, SessionInfo
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()
@@ -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 # Device is now optional
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
@@ -186,7 +186,7 @@ build-backend = "poetry.core.masonry.api"
186
186
 
187
187
  [tool.poetry]
188
188
  name = "pypetkitapi"
189
- version = "1.13.0"
189
+ version = "1.15.0"
190
190
  description = "Python client for PetKit API"
191
191
  authors = ["Jezza34000 <info@mail.com>"]
192
192
  readme = "README.md"
@@ -208,7 +208,7 @@ ruff = "^0.8.1"
208
208
  types-aiofiles = "^24.1.0.20240626"
209
209
 
210
210
  [tool.bumpver]
211
- current_version = "1.13.0"
211
+ current_version = "1.15.0"
212
212
  version_pattern = "MAJOR.MINOR.PATCH"
213
213
  commit_message = "bump version {old_version} -> {new_version}"
214
214
  tag_message = "{new_version}"
File without changes
File without changes