pypetkitapi 1.0.0__tar.gz → 1.1.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.1
2
2
  Name: pypetkitapi
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Python client for PetKit API
5
5
  Home-page: https://github.com/Jezza34000/pypetkit
6
6
  License: MIT
@@ -19,6 +19,7 @@ from pypetkitapi.const import (
19
19
  DEVICES_WATER_FOUNTAIN,
20
20
  ERR_KEY,
21
21
  LOGIN_DATA,
22
+ PET_DATA,
22
23
  RES_KEY,
23
24
  SUCCESS_KEY,
24
25
  Header,
@@ -48,10 +49,11 @@ class PetKitClient:
48
49
  _session: SessionInfo | None = None
49
50
  _servers_list: list[RegionInfo] = []
50
51
  account_data: list[AccountData] = []
51
- petkit_entities: dict[int, Feeder | Litter | WaterFountain | Pet] = {}
52
- petkit_entities_records: dict[
53
- int, FeederRecord | LitterRecord | WaterFountainRecord
54
- ] = {}
52
+ petkit_entities: dict[
53
+ str,
54
+ dict[int, Feeder | Litter | WaterFountain | Pet]
55
+ | dict[int, FeederRecord | LitterRecord | WaterFountainRecord],
56
+ ]
55
57
 
56
58
  def __init__(
57
59
  self,
@@ -67,6 +69,7 @@ class PetKitClient:
67
69
  self.region = region.lower()
68
70
  self.timezone = timezone
69
71
  self._session = None
72
+ self.petkit_entities = {DEVICE_RECORDS: {}, DEVICE_DATA: {}, PET_DATA: {}}
70
73
  self.aiohttp_session = session or aiohttp.ClientSession()
71
74
  self.req = PrepReq(
72
75
  base_url=PetkitDomain.PASSPORT_PETKIT, session=self.aiohttp_session
@@ -169,7 +172,6 @@ class PetKitClient:
169
172
  elif half_max_age < token_age <= max_age:
170
173
  _LOGGER.debug("Token still OK, but refreshing session")
171
174
  await self.refresh_session()
172
- return
173
175
 
174
176
  async def get_session_id(self) -> dict:
175
177
  """Return the session ID."""
@@ -192,7 +194,7 @@ class PetKitClient:
192
194
  for account in self.account_data:
193
195
  if account.pet_list:
194
196
  for pet in account.pet_list:
195
- self.petkit_entities[pet.pet_id] = pet
197
+ self.petkit_entities[PET_DATA][pet.pet_id] = pet
196
198
 
197
199
  async def get_devices_data(self) -> None:
198
200
  """Get the devices data from the PetKit servers."""
@@ -300,12 +302,7 @@ class PetKitClient:
300
302
 
301
303
  _LOGGER.debug("Reading device type : %s (id=%s)", device_type, device_id)
302
304
 
303
- if data_class.data_type == DEVICE_DATA:
304
- self.petkit_entities[device_id] = device_data
305
- elif data_class.data_type == DEVICE_RECORDS:
306
- self.petkit_entities_records[device_id] = device_data
307
- else:
308
- _LOGGER.error("Unknown data type: %s", data_class.data_type)
305
+ self.petkit_entities[data_class.data_type][device_id] = device_data
309
306
 
310
307
  async def send_api_request(
311
308
  self,
@@ -314,7 +311,8 @@ class PetKitClient:
314
311
  setting: dict | None = None,
315
312
  ) -> None:
316
313
  """Control the device using the PetKit API."""
317
- device = self.petkit_entities.get(device_id)
314
+ device_dict = self.petkit_entities.get(DEVICE_DATA, {})
315
+ device = device_dict.get(device_id)
318
316
  if not device:
319
317
  raise PypetkitError(f"Device with ID {device_id} not found.")
320
318
 
@@ -11,6 +11,7 @@ SUCCESS_KEY = "success"
11
11
 
12
12
  DEVICE_RECORDS = "deviceRecords"
13
13
  DEVICE_DATA = "deviceData"
14
+ PET_DATA = "petData"
14
15
 
15
16
  # PetKit Models
16
17
  FEEDER = "feeder"
@@ -187,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
187
187
 
188
188
  [tool.poetry]
189
189
  name = "pypetkitapi"
190
- version = "1.0.0"
190
+ version = "1.1.0"
191
191
  description = "Python client for PetKit API"
192
192
  authors = ["Jezza34000 <info@mail.com>"]
193
193
  readme = "README.md"
@@ -204,7 +204,7 @@ black = "^24.10.0"
204
204
  ruff = "^0.8.1"
205
205
 
206
206
  [tool.bumpver]
207
- current_version = "1.0.0"
207
+ current_version = "1.1.0"
208
208
  version_pattern = "MAJOR.MINOR.PATCH"
209
209
  commit_message = "bump version {old_version} -> {new_version}"
210
210
  tag_message = "{new_version}"
File without changes
File without changes