pypetkitapi 1.16.5__tar.gz → 1.16.7__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.16.5
3
+ Version: 1.16.7
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.16.5"
54
+ __version__ = "1.16.7"
55
55
 
56
56
  __all__ = [
57
57
  "CTW3",
@@ -185,7 +185,7 @@ class BluetoothManager:
185
185
  :return: The BLE command code and the encoded BLE data.
186
186
  """
187
187
  cmd_code = fountain_command[0]
188
- modified_command = fountain_command[:2] + [counter] + fountain_command[2:]
188
+ modified_command = [*fountain_command[:2], counter, *fountain_command[2:]]
189
189
  ble_data = [*BLE_START_TRAME, *modified_command, *BLE_END_TRAME]
190
190
  encoded_data = await self._encode_ble_data(ble_data)
191
191
  return cmd_code, encoded_data
@@ -832,7 +832,9 @@ class PrepReq:
832
832
 
833
833
  match error_code:
834
834
  case 5:
835
- raise PetkitSessionExpiredError(f"Session expired: {error_msg}")
835
+ raise PetkitSessionExpiredError(
836
+ f"Session expired: {error_msg}. WARNING : Make sure you're not using your main PetKit app account. Use a separate one for Home Assistant. Refer to the documentation for more details."
837
+ )
836
838
  case 122:
837
839
  raise PetkitAuthenticationError(
838
840
  f"Authentication failed: {error_msg}"
@@ -55,13 +55,20 @@ class Device(BaseModel):
55
55
 
56
56
  created_at: int = Field(alias="createdAt")
57
57
  device_id: int = Field(alias="deviceId")
58
- device_name: str = Field(alias="deviceName")
58
+ device_name: str | None = Field("unnamed_device", alias="deviceName")
59
59
  device_type: str = Field(alias="deviceType")
60
60
  group_id: int = Field(alias="groupId")
61
61
  type: int
62
62
  type_code: int = Field(0, alias="typeCode")
63
63
  unique_id: str = Field(alias="uniqueId")
64
64
 
65
+ @field_validator("device_name", mode="before")
66
+ def set_default_name(cls, value): # noqa: N805
67
+ """Set default device_name if None or empty to avoid issues."""
68
+ if value is None or not isinstance(value, str) or not value.strip():
69
+ return "unnamed_device"
70
+ return value.lower()
71
+
65
72
  @field_validator("device_name", "device_type", "unique_id", mode="before")
66
73
  def convert_to_lower(cls, value): # noqa: N805
67
74
  """Convert device_name, device_type and unique_id to lowercase."""
@@ -59,7 +59,7 @@ class Purifier(BaseModel):
59
59
  name: str | None = None
60
60
  refreshing: int | None = None
61
61
  relate_t4: int | None = Field(None, alias="relateT4")
62
- relation: dict[str, str]
62
+ relation: dict[str, str] | list | None = None
63
63
  secret: str | None = None
64
64
  settings: Settings | None = None
65
65
  share_open: int | None = Field(None, alias="shareOpen")
@@ -116,6 +116,7 @@ ignore = [
116
116
  "E501", # line too long
117
117
 
118
118
  "PLC1901", # {existing} can be simplified to {replacement} as an empty string is falsey; too many false positives
119
+ "PLC0415", # import should be at the top-level of a file
119
120
  "PLR0911", # Too many return statements ({returns} > {max_returns})
120
121
  "PLR0912", # Too many branches ({branches} > {max_branches})
121
122
  "PLR0913", # Too many arguments to function call ({c_args} > {max_args})
@@ -186,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
186
187
 
187
188
  [tool.poetry]
188
189
  name = "pypetkitapi"
189
- version = "1.16.5"
190
+ version = "1.16.7"
190
191
  description = "Python client for PetKit API"
191
192
  authors = ["Jezza34000 <info@mail.com>"]
192
193
  readme = "README.md"
@@ -208,7 +209,7 @@ ruff = "^0.8.1"
208
209
  types-aiofiles = "^24.1.0.20240626"
209
210
 
210
211
  [tool.bumpver]
211
- current_version = "1.16.5"
212
+ current_version = "1.16.7"
212
213
  version_pattern = "MAJOR.MINOR.PATCH"
213
214
  commit_message = "bump version {old_version} -> {new_version}"
214
215
  tag_message = "{new_version}"
File without changes
File without changes