pypetkitapi 1.9.0__tar.gz → 1.9.1__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.
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/PKG-INFO +1 -1
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/__init__.py +1 -1
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/client.py +22 -17
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/litter_container.py +6 -5
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pyproject.toml +2 -2
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/LICENSE +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/README.md +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/command.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/const.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/containers.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/exceptions.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/feeder_container.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/medias.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/purifier_container.py +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/py.typed +0 -0
- {pypetkitapi-1.9.0 → pypetkitapi-1.9.1}/pypetkitapi/water_fountain_container.py +0 -0
@@ -28,7 +28,9 @@ from pypetkitapi.const import (
|
|
28
28
|
LOGIN_DATA,
|
29
29
|
PET,
|
30
30
|
RES_KEY,
|
31
|
+
T3,
|
31
32
|
T4,
|
33
|
+
T5,
|
32
34
|
T6,
|
33
35
|
Header,
|
34
36
|
PetkitDomain,
|
@@ -256,9 +258,9 @@ class PetKitClient:
|
|
256
258
|
)
|
257
259
|
record_tasks.append(self._fetch_device_data(device, LitterRecord))
|
258
260
|
|
259
|
-
if device_type
|
261
|
+
if device_type in [T3, T4]:
|
260
262
|
record_tasks.append(self._fetch_device_data(device, LitterStats))
|
261
|
-
if device_type
|
263
|
+
if device_type in [T5, T6]:
|
262
264
|
record_tasks.append(self._fetch_device_data(device, PetOutGraph))
|
263
265
|
|
264
266
|
elif device_type in DEVICES_WATER_FOUNTAIN:
|
@@ -351,9 +353,9 @@ class PetKitClient:
|
|
351
353
|
self.petkit_entities[device.device_id].device_records = device_data
|
352
354
|
_LOGGER.debug("Device records fetched OK for %s", device_type)
|
353
355
|
elif data_class.data_type == DEVICE_STATS:
|
354
|
-
if device_type
|
356
|
+
if device_type in [T3, T4]:
|
355
357
|
self.petkit_entities[device.device_id].device_stats = device_data
|
356
|
-
if device_type
|
358
|
+
if device_type in [T5, T6]:
|
357
359
|
self.petkit_entities[device.device_id].device_pet_graph_out = (
|
358
360
|
device_data
|
359
361
|
)
|
@@ -386,17 +388,20 @@ class PetKitClient:
|
|
386
388
|
|
387
389
|
pets_list = await self.get_pets_list()
|
388
390
|
for pet in pets_list:
|
389
|
-
if
|
390
|
-
|
391
|
+
if (
|
392
|
+
stats_data.device_nfo.device_type in [T3, T4]
|
393
|
+
and stats_data.device_records
|
394
|
+
):
|
395
|
+
await self._process_t3_t4(pet, stats_data)
|
391
396
|
elif (
|
392
|
-
stats_data.device_nfo.device_type
|
397
|
+
stats_data.device_nfo.device_type in [T5, T6]
|
393
398
|
and stats_data.device_pet_graph_out
|
394
399
|
):
|
395
|
-
await self.
|
400
|
+
await self._process_t5_t6(pet, stats_data)
|
396
401
|
|
397
|
-
async def
|
398
|
-
"""Process T4
|
399
|
-
for stat in device_records:
|
402
|
+
async def _process_t3_t4(self, pet, device_records):
|
403
|
+
"""Process T3/T4 devices records."""
|
404
|
+
for stat in device_records.device_records:
|
400
405
|
if stat.pet_id == pet.pet_id and (
|
401
406
|
pet.last_litter_usage is None
|
402
407
|
or self.get_safe_value(stat.timestamp) > pet.last_litter_usage
|
@@ -409,11 +414,11 @@ class PetKitClient:
|
|
409
414
|
stat.content.time_in if stat.content else None,
|
410
415
|
stat.content.time_out if stat.content else None,
|
411
416
|
)
|
412
|
-
pet.last_device_used =
|
417
|
+
pet.last_device_used = device_records.device_nfo.device_name
|
413
418
|
|
414
|
-
async def
|
415
|
-
"""Process T6 pet graphs."""
|
416
|
-
for graph in pet_graphs:
|
419
|
+
async def _process_t5_t6(self, pet, pet_graphs):
|
420
|
+
"""Process T5/T6 pet graphs."""
|
421
|
+
for graph in pet_graphs.device_pet_graph_out:
|
417
422
|
if graph.pet_id == pet.pet_id and (
|
418
423
|
pet.last_litter_usage is None
|
419
424
|
or self.get_safe_value(graph.time) > pet.last_litter_usage
|
@@ -423,7 +428,7 @@ class PetKitClient:
|
|
423
428
|
graph.content.pet_weight if graph.content else None
|
424
429
|
)
|
425
430
|
pet.last_duration_usage = self.get_safe_value(graph.toilet_time)
|
426
|
-
pet.last_device_used =
|
431
|
+
pet.last_device_used = pet_graphs.device_nfo.device_name
|
427
432
|
|
428
433
|
async def _get_fountain_instance(self, fountain_id: int) -> WaterFountain:
|
429
434
|
# Retrieve the water fountain object
|
@@ -748,7 +753,7 @@ class PrepReq:
|
|
748
753
|
)
|
749
754
|
case _:
|
750
755
|
raise PypetkitError(
|
751
|
-
f"Request failed code : {error_code} details : {error_msg}"
|
756
|
+
f"Request failed code : {error_code}, details : {error_msg} url : {url}"
|
752
757
|
)
|
753
758
|
|
754
759
|
# Check for success in the response
|
@@ -9,6 +9,7 @@ from pypetkitapi.const import (
|
|
9
9
|
DEVICE_DATA,
|
10
10
|
DEVICE_RECORDS,
|
11
11
|
DEVICE_STATS,
|
12
|
+
T3,
|
12
13
|
T4,
|
13
14
|
T5,
|
14
15
|
T6,
|
@@ -239,7 +240,7 @@ class LitterRecord(BaseModel):
|
|
239
240
|
@classmethod
|
240
241
|
def get_endpoint(cls, device_type: str) -> str:
|
241
242
|
"""Get the endpoint URL for the given device type."""
|
242
|
-
if device_type
|
243
|
+
if device_type in [T3, T4]:
|
243
244
|
return PetkitEndpoint.GET_DEVICE_RECORD
|
244
245
|
if device_type in [T5, T6]:
|
245
246
|
return PetkitEndpoint.GET_DEVICE_RECORD_RELEASE
|
@@ -254,10 +255,10 @@ class LitterRecord(BaseModel):
|
|
254
255
|
) -> dict:
|
255
256
|
"""Generate query parameters including request_date."""
|
256
257
|
device_type = device.device_type
|
257
|
-
if device_type
|
258
|
-
|
259
|
-
|
260
|
-
return {
|
258
|
+
if device_type in [T3, T4]:
|
259
|
+
request_date = request_date or datetime.now().strftime("%Y%m%d")
|
260
|
+
key = "day" if device_type == T3 else "date"
|
261
|
+
return {key: int(request_date), "deviceId": device.device_id}
|
261
262
|
if device_type in [T5, T6]:
|
262
263
|
return {
|
263
264
|
"timestamp": int(datetime.now().timestamp()),
|
@@ -187,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
|
|
187
187
|
|
188
188
|
[tool.poetry]
|
189
189
|
name = "pypetkitapi"
|
190
|
-
version = "1.9.
|
190
|
+
version = "1.9.1"
|
191
191
|
description = "Python client for PetKit API"
|
192
192
|
authors = ["Jezza34000 <info@mail.com>"]
|
193
193
|
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.9.
|
211
|
+
current_version = "1.9.1"
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|