pypetkitapi 0.4.0__tar.gz → 0.5.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-0.4.0 → pypetkitapi-0.5.1}/PKG-INFO +1 -1
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/client.py +4 -2
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/command.py +65 -13
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/const.py +9 -1
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/containers.py +15 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/feeder_container.py +14 -1
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/litter_container.py +11 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pyproject.toml +2 -2
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/LICENSE +0 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/README.md +0 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/__init__.py +0 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/exceptions.py +0 -0
- {pypetkitapi-0.4.0 → pypetkitapi-0.5.1}/pypetkitapi/water_fountain_container.py +0 -0
@@ -46,6 +46,7 @@ class PetKitClient:
|
|
46
46
|
_session: SessionInfo | None = None
|
47
47
|
_servers_list: list[RegionInfo] = []
|
48
48
|
account_data: list[AccountData] = []
|
49
|
+
# TODO : Adding pet as entity ?
|
49
50
|
device_list: dict[int, Feeder | Litter | WaterFountain] = {}
|
50
51
|
|
51
52
|
def __init__(
|
@@ -279,7 +280,7 @@ class PetKitClient:
|
|
279
280
|
self,
|
280
281
|
device_id: int,
|
281
282
|
action: StrEnum,
|
282
|
-
setting: dict | None = None,
|
283
|
+
setting: dict | StrEnum | None = None,
|
283
284
|
) -> None:
|
284
285
|
"""Control the device using the PetKit API."""
|
285
286
|
device = self.device_list.get(device_id)
|
@@ -331,7 +332,8 @@ class PetKitClient:
|
|
331
332
|
data=params,
|
332
333
|
headers=headers,
|
333
334
|
)
|
334
|
-
if res
|
335
|
+
if res in (SUCCESS_KEY, RES_KEY):
|
336
|
+
# TODO : Manage to get the response from manul feeding
|
335
337
|
_LOGGER.info("Command executed successfully")
|
336
338
|
else:
|
337
339
|
_LOGGER.error("Command execution failed")
|
@@ -9,6 +9,7 @@ import json
|
|
9
9
|
from pypetkitapi.const import (
|
10
10
|
ALL_DEVICES,
|
11
11
|
D3,
|
12
|
+
D4,
|
12
13
|
D4H,
|
13
14
|
D4S,
|
14
15
|
D4SH,
|
@@ -44,6 +45,7 @@ class FeederCommand(StrEnum):
|
|
44
45
|
class LitterCommand(StrEnum):
|
45
46
|
"""LitterCommand"""
|
46
47
|
|
48
|
+
POWER = "power"
|
47
49
|
CONTROL_DEVICE = "control_device"
|
48
50
|
RESET_DEODORIZER = "reset_deodorizer"
|
49
51
|
|
@@ -54,6 +56,12 @@ class PetCommand(StrEnum):
|
|
54
56
|
UPDATE_SETTING = "update_setting"
|
55
57
|
|
56
58
|
|
59
|
+
class FountainCommand(StrEnum):
|
60
|
+
"""Fountain Command"""
|
61
|
+
|
62
|
+
CONTROL_DEVICE = "control_device"
|
63
|
+
|
64
|
+
|
57
65
|
class LitterBoxCommand(StrEnum):
|
58
66
|
"""LitterBoxCommand"""
|
59
67
|
|
@@ -148,6 +156,43 @@ LB_CMD_TO_VALUE = {
|
|
148
156
|
}
|
149
157
|
|
150
158
|
|
159
|
+
class FountainAction(StrEnum):
|
160
|
+
"""Fountain Action"""
|
161
|
+
|
162
|
+
PAUSE = "Pause"
|
163
|
+
NORMAL_TO_PAUSE = "Normal To Pause"
|
164
|
+
SMART_TO_PAUSE = "Smart To Pause"
|
165
|
+
NORMAL = "Normal"
|
166
|
+
SMART = "Smart"
|
167
|
+
RESET_FILTER = "Reset Filter"
|
168
|
+
DO_NOT_DISTURB = "Do Not Disturb"
|
169
|
+
DO_NOT_DISTURB_OFF = "Do Not Disturb Off"
|
170
|
+
FIRST_BLE_CMND = "First BLE Command"
|
171
|
+
SECOND_BLE_CMND = "Second BLE Command"
|
172
|
+
LIGHT_LOW = "Light Low"
|
173
|
+
LIGHT_MEDIUM = "Light Medium"
|
174
|
+
LIGHT_HIGH = "Light High"
|
175
|
+
LIGHT_ON = "Light On"
|
176
|
+
LIGHT_OFF = "Light Off"
|
177
|
+
|
178
|
+
|
179
|
+
FOUNTAIN_COMMAND_TO_CODE = {
|
180
|
+
FountainAction.DO_NOT_DISTURB: "221",
|
181
|
+
FountainAction.DO_NOT_DISTURB_OFF: "221",
|
182
|
+
FountainAction.LIGHT_ON: "221",
|
183
|
+
FountainAction.LIGHT_OFF: "221",
|
184
|
+
FountainAction.LIGHT_LOW: "221",
|
185
|
+
FountainAction.LIGHT_MEDIUM: "221",
|
186
|
+
FountainAction.LIGHT_HIGH: "221",
|
187
|
+
FountainAction.PAUSE: "220",
|
188
|
+
FountainAction.RESET_FILTER: "222",
|
189
|
+
FountainAction.NORMAL: "220",
|
190
|
+
FountainAction.NORMAL_TO_PAUSE: "220",
|
191
|
+
FountainAction.SMART: "220",
|
192
|
+
FountainAction.SMART_TO_PAUSE: "220",
|
193
|
+
}
|
194
|
+
|
195
|
+
|
151
196
|
@dataclass
|
152
197
|
class CmdData:
|
153
198
|
"""Command Info"""
|
@@ -192,7 +237,7 @@ ACTIONS_MAP = {
|
|
192
237
|
"time": "-1",
|
193
238
|
**setting,
|
194
239
|
},
|
195
|
-
supported_device=
|
240
|
+
supported_device=[FEEDER, FEEDER_MINI, D3, D4, D4H],
|
196
241
|
),
|
197
242
|
FeederCommand.MANUAL_FEED_DUAL: CmdData(
|
198
243
|
endpoint=PetkitEndpoint.MANUAL_FEED_DUAL,
|
@@ -259,7 +304,15 @@ ACTIONS_MAP = {
|
|
259
304
|
},
|
260
305
|
supported_device=[D3],
|
261
306
|
),
|
262
|
-
|
307
|
+
LitterCommand.POWER: CmdData(
|
308
|
+
endpoint=PetkitEndpoint.CONTROL_DEVICE,
|
309
|
+
params=lambda device, setting: {
|
310
|
+
"id": device.id,
|
311
|
+
"kv": json.dumps(setting),
|
312
|
+
"type": "power",
|
313
|
+
},
|
314
|
+
supported_device=[T3, T4, T5, T6],
|
315
|
+
),
|
263
316
|
LitterCommand.CONTROL_DEVICE: CmdData(
|
264
317
|
endpoint=PetkitEndpoint.CONTROL_DEVICE,
|
265
318
|
params=lambda device, command: {
|
@@ -269,22 +322,21 @@ ACTIONS_MAP = {
|
|
269
322
|
},
|
270
323
|
supported_device=[T3, T4, T5, T6],
|
271
324
|
),
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
# ),
|
325
|
+
PetCommand.UPDATE_SETTING: CmdData(
|
326
|
+
endpoint=PetkitEndpoint.CONTROL_DEVICE,
|
327
|
+
params=lambda pet, setting: {
|
328
|
+
"petId": pet,
|
329
|
+
"kv": json.dumps(setting),
|
330
|
+
},
|
331
|
+
supported_device=ALL_DEVICES,
|
332
|
+
),
|
281
333
|
# FountainCommand.CONTROL_DEVICE: CmdData(
|
282
334
|
# endpoint=PetkitEndpoint.CONTROL_DEVICE,
|
283
335
|
# params=lambda device, setting: {
|
284
|
-
# "bleId":
|
336
|
+
# "bleId": device.id,
|
285
337
|
# "cmd": cmnd_code,
|
286
338
|
# "data": ble_data,
|
287
|
-
# "mac":
|
339
|
+
# "mac": device.mac,
|
288
340
|
# "type": water_fountain.ble_relay,
|
289
341
|
# },
|
290
342
|
# supported_device=[CTW3],
|
@@ -95,9 +95,17 @@ class PetkitEndpoint(StrEnum):
|
|
95
95
|
GET_DEVICE_RECORD_RELEASE = "getDeviceRecordRelease"
|
96
96
|
UPDATE_SETTING = "updateSettings"
|
97
97
|
|
98
|
+
# Bluetooth relay
|
99
|
+
BLE_AS_RELAY = "ble/ownSupportBleDevices"
|
100
|
+
BLE_CONNECT = "ble/connect"
|
101
|
+
BLE_POLL = "ble/poll"
|
102
|
+
BLE_CANCEL = "ble/cancel"
|
103
|
+
|
104
|
+
# Fountain & Litter Box
|
105
|
+
CONTROL_DEVICE = "controlDevice"
|
106
|
+
|
98
107
|
# Litter Box
|
99
108
|
DEODORANT_RESET = "deodorantReset"
|
100
|
-
CONTROL_DEVICE = "controlDevice"
|
101
109
|
|
102
110
|
# Feeders
|
103
111
|
REPLENISHED_FOOD = "added"
|
@@ -15,6 +15,21 @@ class RegionInfo(BaseModel):
|
|
15
15
|
name: str
|
16
16
|
|
17
17
|
|
18
|
+
class BleRelay(BaseModel):
|
19
|
+
"""Dataclass for BLE relay devices
|
20
|
+
Fetched from the API endpoint :
|
21
|
+
- ble/ownSupportBleDevices
|
22
|
+
"""
|
23
|
+
|
24
|
+
id: int
|
25
|
+
low_version: int = Field(alias="lowVersion")
|
26
|
+
mac: str
|
27
|
+
name: str
|
28
|
+
pim: int
|
29
|
+
sn: str
|
30
|
+
type_id: int = Field(alias="typeId")
|
31
|
+
|
32
|
+
|
18
33
|
class SessionInfo(BaseModel):
|
19
34
|
"""Dataclass for session data.
|
20
35
|
Fetched from the API endpoint :
|
@@ -154,6 +154,19 @@ class StateFeeder(BaseModel):
|
|
154
154
|
conservation_status: int | None = Field(None, alias="conservationStatus")
|
155
155
|
|
156
156
|
|
157
|
+
class ManualFeed(BaseModel):
|
158
|
+
"""Dataclass for result data."""
|
159
|
+
|
160
|
+
amount1: int | None = None
|
161
|
+
amount2: int | None = None
|
162
|
+
id: str | None = None
|
163
|
+
is_executed: int | None = Field(None, alias="isExecuted")
|
164
|
+
is_need_upload_video: int | None = Field(None, alias="isNeedUploadVideo")
|
165
|
+
src: int | None = None
|
166
|
+
status: int | None = None
|
167
|
+
time: int | None = None
|
168
|
+
|
169
|
+
|
157
170
|
class Feeder(BaseModel):
|
158
171
|
"""Dataclass for feeder data."""
|
159
172
|
|
@@ -184,7 +197,7 @@ class Feeder(BaseModel):
|
|
184
197
|
p2p_type: int | None = Field(None, alias="p2pType")
|
185
198
|
multi_config: bool | None = Field(None, alias="multiConfig")
|
186
199
|
device_type: str | None = Field(None, alias="deviceType")
|
187
|
-
|
200
|
+
manual_feed: ManualFeed | None = None
|
188
201
|
|
189
202
|
@classmethod
|
190
203
|
def get_endpoint(cls, device_type: str) -> str:
|
@@ -130,6 +130,16 @@ class StateLitter(BaseModel):
|
|
130
130
|
wander_time: int | None = Field(None, alias="wanderTime")
|
131
131
|
|
132
132
|
|
133
|
+
class WorkState(BaseModel):
|
134
|
+
"""Dataclass for work state data."""
|
135
|
+
|
136
|
+
safe_warn: int = Field(alias="safeWarn")
|
137
|
+
stop_time: int = Field(alias="stopTime")
|
138
|
+
work_mode: int = Field(alias="workMode")
|
139
|
+
work_process: int = Field(alias="workProcess")
|
140
|
+
work_reason: int = Field(alias="workReason")
|
141
|
+
|
142
|
+
|
133
143
|
class Litter(BaseModel):
|
134
144
|
"""Dataclass for Litter Data.
|
135
145
|
Supported devices = T4, T6
|
@@ -171,6 +181,7 @@ class Litter(BaseModel):
|
|
171
181
|
service_status: int | None = Field(None, alias="serviceStatus")
|
172
182
|
total_time: int | None = Field(None, alias="totalTime")
|
173
183
|
device_type: str | None = Field(None, alias="deviceType")
|
184
|
+
work_state: WorkState | None = Field(None, alias="workState")
|
174
185
|
|
175
186
|
@classmethod
|
176
187
|
def get_endpoint(cls, device_type: str) -> str:
|
@@ -187,7 +187,7 @@ build-backend = "poetry.core.masonry.api"
|
|
187
187
|
|
188
188
|
[tool.poetry]
|
189
189
|
name = "pypetkitapi"
|
190
|
-
version = "0.
|
190
|
+
version = "0.5.1"
|
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.
|
207
|
+
current_version = "0.5.1"
|
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
|
File without changes
|
File without changes
|
File without changes
|