pypetkitapi 0.2.1__tar.gz → 0.4.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.
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/PKG-INFO +9 -13
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/README.md +8 -12
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/client.py +7 -1
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/command.py +5 -5
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/const.py +4 -3
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/containers.py +1 -1
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/exceptions.py +2 -2
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pyproject.toml +2 -2
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/LICENSE +0 -0
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/__init__.py +0 -0
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/feeder_container.py +0 -0
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/litter_container.py +0 -0
- {pypetkitapi-0.2.1 → pypetkitapi-0.4.0}/pypetkitapi/water_fountain_container.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pypetkitapi
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Python client for PetKit API
|
5
5
|
Home-page: https://github.com/Jezza34000/pypetkit
|
6
6
|
License: MIT
|
@@ -19,10 +19,6 @@ Description-Content-Type: text/markdown
|
|
19
19
|
|
20
20
|
---
|
21
21
|
|
22
|
-
# WIP - UNDER DEVELOPMENT
|
23
|
-
|
24
|
-
---
|
25
|
-
|
26
22
|
[][pypi_]
|
27
23
|
[][python version]
|
28
24
|
|
@@ -72,29 +68,29 @@ logging.basicConfig(level=logging.DEBUG)
|
|
72
68
|
|
73
69
|
async def main():
|
74
70
|
client = PetKitClient(
|
75
|
-
username="username", # Your PetKit account username
|
71
|
+
username="username", # Your PetKit account username or id
|
76
72
|
password="password", # Your PetKit account password
|
77
|
-
region="France", # Your region
|
73
|
+
region="France", # Your region or country code (e.g. FR, US, etc.)
|
78
74
|
timezone="Europe/Paris", # Your timezone
|
79
75
|
)
|
80
76
|
|
81
77
|
# To get the account and devices data attached to the account
|
82
78
|
await client.get_devices_data()
|
79
|
+
|
83
80
|
# Read the account data
|
84
81
|
print(client.account_data)
|
82
|
+
|
85
83
|
# Read the devices data
|
86
84
|
print(client.device_list)
|
87
85
|
|
88
|
-
# client.device_list[0] is the first device in the list in this example it's a Feeder
|
89
|
-
# Get the Feeder from the device list
|
90
|
-
my_feeder = client.device_list[0]
|
91
|
-
|
92
86
|
# Send command to the devices
|
93
87
|
### Example 1 : Turn on the indicator light
|
94
|
-
|
88
|
+
### Device_ID, Command, Payload
|
89
|
+
await client.send_api_request(012346789, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
|
95
90
|
|
96
91
|
### Example 2 : Feed the pet
|
97
|
-
|
92
|
+
### Device_ID, Command, Payload
|
93
|
+
await client.send_api_request(0123467, FeederCommand.MANUAL_FEED, {"amount": 1})
|
98
94
|
|
99
95
|
|
100
96
|
if __name__ == "__main__":
|
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
---
|
4
4
|
|
5
|
-
# WIP - UNDER DEVELOPMENT
|
6
|
-
|
7
|
-
---
|
8
|
-
|
9
5
|
[][pypi_]
|
10
6
|
[][python version]
|
11
7
|
|
@@ -55,29 +51,29 @@ logging.basicConfig(level=logging.DEBUG)
|
|
55
51
|
|
56
52
|
async def main():
|
57
53
|
client = PetKitClient(
|
58
|
-
username="username", # Your PetKit account username
|
54
|
+
username="username", # Your PetKit account username or id
|
59
55
|
password="password", # Your PetKit account password
|
60
|
-
region="France", # Your region
|
56
|
+
region="France", # Your region or country code (e.g. FR, US, etc.)
|
61
57
|
timezone="Europe/Paris", # Your timezone
|
62
58
|
)
|
63
59
|
|
64
60
|
# To get the account and devices data attached to the account
|
65
61
|
await client.get_devices_data()
|
62
|
+
|
66
63
|
# Read the account data
|
67
64
|
print(client.account_data)
|
65
|
+
|
68
66
|
# Read the devices data
|
69
67
|
print(client.device_list)
|
70
68
|
|
71
|
-
# client.device_list[0] is the first device in the list in this example it's a Feeder
|
72
|
-
# Get the Feeder from the device list
|
73
|
-
my_feeder = client.device_list[0]
|
74
|
-
|
75
69
|
# Send command to the devices
|
76
70
|
### Example 1 : Turn on the indicator light
|
77
|
-
|
71
|
+
### Device_ID, Command, Payload
|
72
|
+
await client.send_api_request(012346789, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
|
78
73
|
|
79
74
|
### Example 2 : Feed the pet
|
80
|
-
|
75
|
+
### Device_ID, Command, Payload
|
76
|
+
await client.send_api_request(0123467, FeederCommand.MANUAL_FEED, {"amount": 1})
|
81
77
|
|
82
78
|
|
83
79
|
if __name__ == "__main__":
|
@@ -101,18 +101,24 @@ class PetKitClient:
|
|
101
101
|
await self._get_api_server_list()
|
102
102
|
_LOGGER.debug("Finding region server for region: %s", self.region)
|
103
103
|
|
104
|
+
# TODO : Improve this
|
105
|
+
if self.region == "china":
|
106
|
+
self._base_url = PetkitURL.CHINA_SRV
|
107
|
+
return
|
108
|
+
|
104
109
|
regional_server = next(
|
105
110
|
(
|
106
111
|
server
|
107
112
|
for server in self._servers_list
|
108
113
|
if server.name.lower() == self.region
|
114
|
+
or server.id.lower() == self.region
|
109
115
|
),
|
110
116
|
None,
|
111
117
|
)
|
112
118
|
|
113
119
|
if regional_server:
|
114
120
|
_LOGGER.debug(
|
115
|
-
"
|
121
|
+
"Using server %s for region : %s", regional_server, self.region
|
116
122
|
)
|
117
123
|
self._base_url = regional_server.gateway
|
118
124
|
return
|
@@ -160,10 +160,10 @@ class CmdData:
|
|
160
160
|
def get_endpoint_manual_feed(device):
|
161
161
|
"""Get the endpoint for the device"""
|
162
162
|
if device.device_type == FEEDER_MINI:
|
163
|
-
return PetkitEndpoint.
|
163
|
+
return PetkitEndpoint.MANUAL_FEED_MINI
|
164
164
|
if device.device_type == FEEDER:
|
165
|
-
return PetkitEndpoint.
|
166
|
-
return PetkitEndpoint.
|
165
|
+
return PetkitEndpoint.MANUAL_FEED_FRESH_ELEMENT
|
166
|
+
return PetkitEndpoint.MANUAL_FEED_DUAL
|
167
167
|
|
168
168
|
|
169
169
|
def get_endpoint_reset_desiccant(device):
|
@@ -195,7 +195,7 @@ ACTIONS_MAP = {
|
|
195
195
|
supported_device=DEVICES_FEEDER, # TODO: Check if this is correct
|
196
196
|
),
|
197
197
|
FeederCommand.MANUAL_FEED_DUAL: CmdData(
|
198
|
-
endpoint=PetkitEndpoint.
|
198
|
+
endpoint=PetkitEndpoint.MANUAL_FEED_DUAL,
|
199
199
|
params=lambda device, setting: {
|
200
200
|
"day": datetime.datetime.now().strftime("%Y%m%d"),
|
201
201
|
"deviceId": device.id,
|
@@ -203,7 +203,7 @@ ACTIONS_MAP = {
|
|
203
203
|
"time": "-1",
|
204
204
|
**setting,
|
205
205
|
},
|
206
|
-
supported_device=
|
206
|
+
supported_device=[D4S, D4SH],
|
207
207
|
),
|
208
208
|
FeederCommand.CANCEL_MANUAL_FEED: CmdData(
|
209
209
|
endpoint=lambda device: (
|
@@ -35,6 +35,7 @@ class PetkitURL(StrEnum):
|
|
35
35
|
"""Petkit URL constants"""
|
36
36
|
|
37
37
|
REGION_SRV = "https://passport.petkt.com/v1/regionservers"
|
38
|
+
CHINA_SRV = "https://api.petkit.cn/6/"
|
38
39
|
|
39
40
|
|
40
41
|
class Client(StrEnum):
|
@@ -107,6 +108,6 @@ class PetkitEndpoint(StrEnum):
|
|
107
108
|
FRESH_ELEMENT_DESICCANT_RESET = "feeder/desiccant_reset"
|
108
109
|
CALL_PET = "callPet"
|
109
110
|
CANCEL_FEED = "cancelRealtimeFeed"
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
MANUAL_FEED_MINI = "feedermini/save_dailyfeed"
|
112
|
+
MANUAL_FEED_FRESH_ELEMENT = "feeder/save_dailyfeed"
|
113
|
+
MANUAL_FEED_DUAL = "saveDailyFeed"
|
@@ -22,8 +22,8 @@ class PetkitRegionalServerNotFoundError(PypetkitError):
|
|
22
22
|
"""Initialize the exception."""
|
23
23
|
self.region = region
|
24
24
|
self.message = (
|
25
|
-
f"Region you provided: '{region}' was not found in the server list. "
|
26
|
-
f"Are you sure you provided the correct region?"
|
25
|
+
f"Region you provided: '{region}' was not found in the Petkit's server list. "
|
26
|
+
f"Are you sure you provided the correct region ?"
|
27
27
|
)
|
28
28
|
super().__init__(self.message)
|
29
29
|
|
@@ -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.4.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.
|
207
|
+
current_version = "0.4.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
|
File without changes
|
File without changes
|
File without changes
|