pypetkitapi 0.1.2__tar.gz → 0.2.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: 0.1.2
3
+ Version: 0.2.0
4
4
  Summary: Python client for PetKit API
5
5
  Home-page: https://github.com/Jezza34000/pypetkit
6
6
  License: MIT
@@ -1,5 +1,6 @@
1
1
  """Pypetkit Client: A Python library for interfacing with PetKit"""
2
2
 
3
+ import asyncio
3
4
  from datetime import datetime, timedelta
4
5
  from enum import StrEnum
5
6
  import hashlib
@@ -136,6 +137,8 @@ class PetKitClient:
136
137
  # Retrieve the list of servers
137
138
  await self._get_base_url()
138
139
 
140
+ _LOGGER.debug("Logging in to PetKit server")
141
+
139
142
  # Prepare the data to send
140
143
  data = LOGIN_DATA.copy()
141
144
  data["encrypt"] = "1"
@@ -210,6 +213,7 @@ class PetKitClient:
210
213
 
211
214
  async def get_devices_data(self) -> None:
212
215
  """Get the devices data from the PetKit servers."""
216
+ start_time = datetime.now()
213
217
  if not self.account_data:
214
218
  await self._get_account_data()
215
219
 
@@ -219,19 +223,25 @@ class PetKitClient:
219
223
  if account.device_list:
220
224
  device_list.extend(account.device_list)
221
225
 
222
- _LOGGER.info("%s devices found for this account", len(device_list))
226
+ _LOGGER.debug("Fetch %s devices for this account", len(device_list))
227
+
228
+ tasks = []
223
229
  for device in device_list:
224
230
  _LOGGER.debug("Fetching devices data: %s", device)
225
231
  device_type = device.device_type.lower()
226
- # TODO: Fetch device records
227
232
  if device_type in DEVICES_FEEDER:
228
- await self._fetch_device_data(device, Feeder)
233
+ tasks.append(self._fetch_device_data(device, Feeder))
229
234
  elif device_type in DEVICES_LITTER_BOX:
230
- await self._fetch_device_data(device, Litter)
235
+ tasks.append(self._fetch_device_data(device, Litter))
231
236
  elif device_type in DEVICES_WATER_FOUNTAIN:
232
- await self._fetch_device_data(device, WaterFountain)
237
+ tasks.append(self._fetch_device_data(device, WaterFountain))
233
238
  else:
234
239
  _LOGGER.warning("Unknown device type: %s", device_type)
240
+ await asyncio.gather(*tasks)
241
+
242
+ end_time = datetime.now()
243
+ total_time = end_time - start_time
244
+ _LOGGER.debug("Petkit fetch took : %s", total_time)
235
245
 
236
246
  async def _fetch_device_data(
237
247
  self,
@@ -253,7 +263,7 @@ class PetKitClient:
253
263
  )
254
264
  device_data = data_class(**response)
255
265
  device_data.device_type = device.device_type # Add the device_type attribute
256
- _LOGGER.info("Adding device type: %s", device.device_type)
266
+ _LOGGER.debug("Reading device type : %s", device.device_type)
257
267
  self.device_list.append(device_data)
258
268
 
259
269
  async def send_api_request(
@@ -141,6 +141,7 @@ class StateFeeder(BaseModel):
141
141
  door: int | None = None
142
142
  feed_state: FeedState | None = Field(None, alias="feedState")
143
143
  feeding: int | None = None
144
+ error_msg: str | None = Field(None, alias="errorMsg")
144
145
  ota: int | None = None
145
146
  overall: int | None = None
146
147
  pim: int | None = None
@@ -163,10 +164,10 @@ class Feeder(BaseModel):
163
164
  bt_mac: str | None = Field(None, alias="btMac")
164
165
  cloud_product: CloudProduct | None = Field(None, alias="cloudProduct")
165
166
  created_at: str | None = Field(None, alias="createdAt")
166
- firmware: str | None = None
167
- firmware_details: list[FirmwareDetail] | None = Field(None, alias="firmwareDetails")
168
- hardware: int | None = None
169
- id: int | None = None
167
+ firmware: float
168
+ firmware_details: list[FirmwareDetail] = Field(alias="firmwareDetails")
169
+ hardware: int
170
+ id: int
170
171
  locale: str | None = None
171
172
  mac: str | None = None
172
173
  model_code: int | None = Field(None, alias="modelCode")
@@ -177,7 +178,7 @@ class Feeder(BaseModel):
177
178
  settings: SettingsFeeder | None = None
178
179
  share_open: int | None = Field(None, alias="shareOpen")
179
180
  signup_at: str | None = Field(None, alias="signupAt")
180
- sn: str | None = None
181
+ sn: str
181
182
  state: StateFeeder | None = None
182
183
  timezone: float | None = None
183
184
  p2p_type: int | None = Field(None, alias="p2pType")
@@ -91,6 +91,7 @@ class StateLitter(BaseModel):
91
91
  box_full: bool | None = Field(None, alias="boxFull")
92
92
  box_state: int | None = Field(None, alias="boxState")
93
93
  deodorant_left_days: int | None = Field(None, alias="deodorantLeftDays")
94
+ error_msg: str | None = Field(None, alias="errorMsg")
94
95
  frequent_restroom: int | None = Field(None, alias="frequentRestroom")
95
96
  liquid_empty: bool | None = Field(None, alias="liquidEmpty")
96
97
  liquid_lack: bool | None = Field(None, alias="liquidLack")
@@ -140,10 +141,10 @@ class Litter(BaseModel):
140
141
  auto_upgrade: int | None = Field(None, alias="autoUpgrade")
141
142
  bt_mac: str | None = Field(None, alias="btMac")
142
143
  created_at: str | None = Field(None, alias="createdAt")
143
- firmware: str | None = None
144
- firmware_details: list[FirmwareDetail] | None = Field(None, alias="firmwareDetails")
145
- hardware: int | None = None
146
- id: int | None = None
144
+ firmware: float
145
+ firmware_details: list[FirmwareDetail] = Field(alias="firmwareDetails")
146
+ hardware: int
147
+ id: int
147
148
  is_pet_out_tips: int | None = Field(None, alias="isPetOutTips")
148
149
  locale: str | None = None
149
150
  mac: str | None = None
@@ -156,7 +157,7 @@ class Litter(BaseModel):
156
157
  settings: SettingsLitter | None = None
157
158
  share_open: int | None = Field(None, alias="shareOpen")
158
159
  signup_at: str | None = Field(None, alias="signupAt")
159
- sn: str | None = None
160
+ sn: str
160
161
  state: StateLitter | None = None
161
162
  timezone: float | None = None
162
163
  cloud_product: CloudProduct | None = Field(None, alias="cloudProduct") # For T5/T6
@@ -100,9 +100,9 @@ class WaterFountain(BaseModel):
100
100
  filter_expected_days: int | None = Field(None, alias="filterExpectedDays")
101
101
  filter_percent: int | None = Field(None, alias="filterPercent")
102
102
  filter_warning: int | None = Field(None, alias="filterWarning")
103
- firmware: int | None = None
104
- hardware: int | None = None
105
- id: int | None = None
103
+ firmware: float
104
+ hardware: int
105
+ id: int
106
106
  is_night_no_disturbing: int | None = Field(None, alias="isNightNoDisturbing")
107
107
  lack_warning: int | None = Field(None, alias="lackWarning")
108
108
  locale: str | None = None
@@ -110,14 +110,14 @@ class WaterFountain(BaseModel):
110
110
  mac: str | None = None
111
111
  mode: int | None = None
112
112
  module_status: int | None = Field(None, alias="moduleStatus")
113
- name: str | None = None
113
+ name: str
114
114
  record_automatic_add_water: int | None = Field(
115
115
  None, alias="recordAutomaticAddWater"
116
116
  )
117
117
  schedule: Schedule | None = None
118
118
  secret: str | None = None
119
119
  settings: SettingsFountain | None = None
120
- sn: str | None = None
120
+ sn: str
121
121
  status: Status | None = None
122
122
  sync_time: str | None = Field(None, alias="syncTime")
123
123
  timezone: float | None = None
@@ -187,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
187
187
 
188
188
  [tool.poetry]
189
189
  name = "pypetkitapi"
190
- version = "0.1.2"
190
+ version = "0.2.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 = "0.1.2"
207
+ current_version = "0.2.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