pypetkitapi 1.9.0__py3-none-any.whl → 1.9.2__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 CHANGED
@@ -40,7 +40,7 @@ from .medias import MediaHandler, MediasFiles
40
40
  from .purifier_container import Purifier
41
41
  from .water_fountain_container import WaterFountain
42
42
 
43
- __version__ = "1.9.0"
43
+ __version__ = "1.9.2"
44
44
 
45
45
  __all__ = [
46
46
  "CTW3",
pypetkitapi/client.py CHANGED
@@ -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 == T4:
261
+ if device_type in [T3, T4]:
260
262
  record_tasks.append(self._fetch_device_data(device, LitterStats))
261
- if device_type == T6:
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 == T4:
356
+ if device_type in [T3, T4]:
355
357
  self.petkit_entities[device.device_id].device_stats = device_data
356
- if device_type == T6:
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 stats_data.device_nfo.device_type == T4 and stats_data.device_records:
390
- await self._process_t4(pet, stats_data.device_records)
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 == T6
397
+ stats_data.device_nfo.device_type in [T5, T6]
393
398
  and stats_data.device_pet_graph_out
394
399
  ):
395
- await self._process_t6(pet, stats_data.device_pet_graph_out)
400
+ await self._process_t5_t6(pet, stats_data)
396
401
 
397
- async def _process_t4(self, pet, device_records):
398
- """Process T4 device records."""
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 = "Pura Max"
417
+ pet.last_device_used = device_records.device_nfo.device_name
413
418
 
414
- async def _process_t6(self, pet, pet_graphs):
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 = "Purobot Ultra"
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
@@ -5,7 +5,15 @@ from typing import Any, ClassVar
5
5
 
6
6
  from pydantic import BaseModel, Field
7
7
 
8
- from pypetkitapi.const import D3, D4, D4S, DEVICE_DATA, DEVICE_RECORDS, PetkitEndpoint
8
+ from pypetkitapi.const import (
9
+ D3,
10
+ D4,
11
+ D4S,
12
+ DEVICE_DATA,
13
+ DEVICE_RECORDS,
14
+ FEEDER_MINI,
15
+ PetkitEndpoint,
16
+ )
9
17
  from pypetkitapi.containers import CloudProduct, Device, FirmwareDetail, Wifi
10
18
 
11
19
 
@@ -276,8 +284,10 @@ class FeederRecord(BaseModel):
276
284
  return PetkitEndpoint.DAILY_FEED_AND_EAT
277
285
  if device_type == D4:
278
286
  return PetkitEndpoint.FEED_STATISTIC
279
- if device_type == D4S:
287
+ if device_type in D4S:
280
288
  return PetkitEndpoint.DAILY_FEED
289
+ if device_type in FEEDER_MINI:
290
+ return PetkitEndpoint.DAILY_FEED.lower() # Workaround for Feeder Mini
281
291
  return PetkitEndpoint.GET_DEVICE_RECORD
282
292
 
283
293
  @classmethod
@@ -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 == T4:
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 == T4:
258
- if request_date is None:
259
- request_date = datetime.now().strftime("%Y%m%d")
260
- return {"date": int(request_date), "deviceId": device.device_id}
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()),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypetkitapi
3
- Version: 1.9.0
3
+ Version: 1.9.2
4
4
  Summary: Python client for PetKit API
5
5
  Home-page: https://github.com/Jezza34000/pypetkit
6
6
  License: MIT
@@ -1,16 +1,16 @@
1
- pypetkitapi/__init__.py,sha256=FSbNIvn4PuEEWbVnJ2rQEQkyOZgCYiXVAgrWqokbnVg,1562
2
- pypetkitapi/client.py,sha256=J7d8lgrCyR1fJPEB9zUTu_z7HVDp_ALgD_qihu9KAYo,27630
1
+ pypetkitapi/__init__.py,sha256=gwZUf8yep0CbngCc6uTqzZdmmTIaNTdIX5qE0YU6CrU,1562
2
+ pypetkitapi/client.py,sha256=o8dBNxdupWwf7AIt6GB4Jc4SLExc0Zv1E-eX2Qjt5FY,27807
3
3
  pypetkitapi/command.py,sha256=G7AEtUcaK-lcRliNf4oUxPkvDO_GNBkJ-ZUcOo7DGHM,7697
4
4
  pypetkitapi/const.py,sha256=pkTJ0l-8mQix9aoJNC2UYfyUdG7ie826xnv7EkOZtPw,4208
5
5
  pypetkitapi/containers.py,sha256=oJR22ZruMr-0IRgiucdnj_nutOH59MKvmaFTwLJNiJI,4635
6
6
  pypetkitapi/exceptions.py,sha256=fuTLT6Iw2_kA7eOyNJPf59vQkgfByhAnTThY4lC0Rt0,1283
7
- pypetkitapi/feeder_container.py,sha256=q9lsUvBMxVt-vs8gE3Gg7jVyiIz_eh-3Vq-vMhDIzGA,14472
8
- pypetkitapi/litter_container.py,sha256=kVbPddHV7wjaeBbRIsigHn_-G42qLZyFUXJg5U5PcQ0,19061
7
+ pypetkitapi/feeder_container.py,sha256=vfgxPOwbAFd3OFDMXH8md_lk1RLVlEDCFMjbREB4eS4,14640
8
+ pypetkitapi/litter_container.py,sha256=qKP3XFUkbzLREZPXEMDvpR1sqo6BI560O6eJYdkrX7w,19110
9
9
  pypetkitapi/medias.py,sha256=IuWkC7usw0Hbx173X8TGv24jOp4nqv6bIUosZBpXMGg,6945
10
10
  pypetkitapi/purifier_container.py,sha256=ssyIxhNben5XJ4KlQTXTrtULg2ji6DqHqjzOq08d1-I,2491
11
11
  pypetkitapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  pypetkitapi/water_fountain_container.py,sha256=5J0b-fDZYcFLNX2El7fifv8H6JMhBCt-ttxSow1ozRQ,6787
13
- pypetkitapi-1.9.0.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
14
- pypetkitapi-1.9.0.dist-info/METADATA,sha256=ga5bwlaFeRelb8zt8nUMGpSt6X8Uh3mvnbbJwjYteEU,5167
15
- pypetkitapi-1.9.0.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
16
- pypetkitapi-1.9.0.dist-info/RECORD,,
13
+ pypetkitapi-1.9.2.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
14
+ pypetkitapi-1.9.2.dist-info/METADATA,sha256=RUqDHszBUmhesyoV2WfQX-RWQrGZdGSpm-IFBwwMDnE,5167
15
+ pypetkitapi-1.9.2.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
16
+ pypetkitapi-1.9.2.dist-info/RECORD,,