rankjie-pypetkitapi 1.3.0.dev1__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.
- rankjie_pypetkitapi-1.3.0.dev1/LICENSE +21 -0
- rankjie_pypetkitapi-1.3.0.dev1/PKG-INFO +209 -0
- rankjie_pypetkitapi-1.3.0.dev1/README.md +178 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/__init__.py +116 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/bluetooth.py +248 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/client.py +1080 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/command.py +279 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/const.py +231 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/containers.py +279 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/exceptions.py +57 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/feeder_container.py +366 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/litter_container.py +555 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/media.py +823 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/purifier_container.py +91 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/py.typed +0 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/schedule_container.py +67 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/utils.py +55 -0
- rankjie_pypetkitapi-1.3.0.dev1/pypetkitapi/water_fountain_container.py +183 -0
- rankjie_pypetkitapi-1.3.0.dev1/pyproject.toml +281 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 - 2025 Jezza34000
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rankjie-pypetkitapi
|
|
3
|
+
Version: 1.3.0.dev1
|
|
4
|
+
Summary: Python client for PetKit API
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: petkit,api,client,pet,iot
|
|
8
|
+
Author: Jezza34000
|
|
9
|
+
Author-email: info@mail.com
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Home Automation
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: aiofiles (>=24.1.0,<25.0.0)
|
|
22
|
+
Requires-Dist: aiohttp (>=3.11.11,<4.0.0)
|
|
23
|
+
Requires-Dist: m3u8 (>=6.0.0,<7.0.0)
|
|
24
|
+
Requires-Dist: pycryptodome (>=3.19.1,<4.0.0)
|
|
25
|
+
Requires-Dist: pydantic (>=2.10.4,<3.0.0)
|
|
26
|
+
Requires-Dist: tenacity (>=9.1.2,<10.0.0)
|
|
27
|
+
Project-URL: Homepage, https://github.com/rankjie/py-petkit-api
|
|
28
|
+
Project-URL: Repository, https://github.com/rankjie/py-petkit-api
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# Petkit API Client
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
[](https://github.com/Jezza34000/py-petkit-api/)
|
|
36
|
+
[][python version] [](https://github.com/Jezza34000/py-petkit-api/actions)
|
|
37
|
+
|
|
38
|
+
[][pypi_] [](https://pepy.tech/projects/pypetkitapi)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api) [](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api) [](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
43
|
+
|
|
44
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
45
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
46
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
47
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
48
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
49
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
50
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
51
|
+
|
|
52
|
+
[][pre-commit]
|
|
53
|
+
[][black]
|
|
54
|
+
[](https://mypy.readthedocs.io/en/stable/)
|
|
55
|
+
[](https://github.com/astral-sh/ruff)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
[pypi_]: https://pypi.org/project/pypetkitapi/
|
|
60
|
+
[python version]: https://pypi.org/project/pypetkitapi
|
|
61
|
+
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
62
|
+
[black]: https://github.com/psf/black
|
|
63
|
+
|
|
64
|
+
### Enjoying this library?
|
|
65
|
+
|
|
66
|
+
[![Sponsor Jezza34000][github-sponsor-shield]][github-sponsor] [![Static Badge][buymeacoffee-shield]][buymeacoffee]
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## âšī¸ Overview
|
|
71
|
+
|
|
72
|
+
PetKit Client is a Python library for interacting with the PetKit API. It allows you to manage your PetKit devices, retrieve account data, and control devices through the API.
|
|
73
|
+
|
|
74
|
+
## đ Features
|
|
75
|
+
|
|
76
|
+
- Login and session management
|
|
77
|
+
- Fetch account and device data
|
|
78
|
+
- Control PetKit devices (Feeder, Litter Box, Water Fountain, Purifiers)
|
|
79
|
+
- Fetch images & videos produced by devices
|
|
80
|
+
> Pictures are available **with or without** Care+ subscription, Videos are only available **with** Care+ subscription
|
|
81
|
+
|
|
82
|
+
## âŦī¸ Installation
|
|
83
|
+
|
|
84
|
+
Install the library using pip:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install rankjie-pypetkitapi
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## đĄ Usage Example:
|
|
91
|
+
|
|
92
|
+
Here is a simple example of how to use the library to interact with the PetKit API \
|
|
93
|
+
This example is not an exhaustive list of all the features available in the library.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import asyncio
|
|
97
|
+
import logging
|
|
98
|
+
import aiohttp
|
|
99
|
+
from pypetkitapi.client import PetKitClient
|
|
100
|
+
from pypetkitapi.command import DeviceCommand, FeederCommand, LBCommand, DeviceAction, LitterCommand
|
|
101
|
+
|
|
102
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
103
|
+
|
|
104
|
+
async def main():
|
|
105
|
+
async with aiohttp.ClientSession() as session:
|
|
106
|
+
client = PetKitClient(
|
|
107
|
+
username="username", # Your PetKit account username or id
|
|
108
|
+
password="password", # Your PetKit account password
|
|
109
|
+
region="FR", # Your region or country code (e.g. FR, US,CN etc.)
|
|
110
|
+
timezone="Europe/Paris", # Your timezone(e.g. "Asia/Shanghai")
|
|
111
|
+
session=session,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
await client.get_devices_data()
|
|
115
|
+
|
|
116
|
+
# Lists all devices and pet from account
|
|
117
|
+
|
|
118
|
+
for key, value in client.petkit_entities.items():
|
|
119
|
+
print(f"{key}: {type(value).__name__} - {value.name}")
|
|
120
|
+
|
|
121
|
+
# Select a device
|
|
122
|
+
device_id = key
|
|
123
|
+
# Read devices or pet information
|
|
124
|
+
print(client.petkit_entities[device_id])
|
|
125
|
+
|
|
126
|
+
# Send command to the devices
|
|
127
|
+
### Example 1 : Turn on the indicator light
|
|
128
|
+
### Device_ID, Command, Payload
|
|
129
|
+
await client.send_api_request(device_id, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
|
|
130
|
+
|
|
131
|
+
### Example 2 : Feed the pet
|
|
132
|
+
### Device_ID, Command, Payload
|
|
133
|
+
# simple hopper :
|
|
134
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount": 1})
|
|
135
|
+
# dual hopper :
|
|
136
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount1": 2})
|
|
137
|
+
# or
|
|
138
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount2": 2})
|
|
139
|
+
|
|
140
|
+
### Example 3 : Start the cleaning process
|
|
141
|
+
### Device_ID, Command, Payload
|
|
142
|
+
await client.send_api_request(device_id, LitterCommand.CONTROL_DEVICE, {DeviceAction.START: LBCommand.CLEANING})
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if __name__ == "__main__":
|
|
146
|
+
asyncio.run(main())
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## đĄ More example usage
|
|
150
|
+
|
|
151
|
+
Check at the usage in the Home Assistant integration : [here](https://github.com/Jezza34000/homeassistant_petkit)
|
|
152
|
+
|
|
153
|
+
## âī¸ Supported Devices
|
|
154
|
+
|
|
155
|
+
| **Category** | **Name** | **Device** |
|
|
156
|
+
| ---------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
157
|
+
| **đ Feeders** | â
Fresh Element | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/feeder.png" width="40"/></a> |
|
|
158
|
+
| | â
Fresh Element Mini Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/feedermini.png" width="40"/></a> |
|
|
159
|
+
| | â
Fresh Element Infinity | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d3.png" width="40"/></a> |
|
|
160
|
+
| | â
Fresh Element Solo | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4.png" width="40"/></a> |
|
|
161
|
+
| | â
Fresh Element Gemini | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4s.png" width="40"/></a> |
|
|
162
|
+
| | â
YumShare Solo | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4h.png" width="40"/></a> |
|
|
163
|
+
| | â
YumShare Dual-hopper | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4sh.png" width="40"/></a> |
|
|
164
|
+
| **đŊ Litters** | â
PuraX | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t3.png" width="40"/></a> |
|
|
165
|
+
| | â
PuraMax | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t4.1.png" width="40"/></a> |
|
|
166
|
+
| | â
PuraMax 2 | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t4.png" width="40"/></a> |
|
|
167
|
+
| | â
Purobot Max Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t5.png" width="40"/></a> |
|
|
168
|
+
| | â
Purobot Ultra | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t6.png" width="40"/></a> |
|
|
169
|
+
| **ⲠFountains** | â
Eversweet Solo 2 | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/5w5.png" width="40"/></a> |
|
|
170
|
+
| | â
Eversweet 3 Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/4w5.png" width="40"/></a> |
|
|
171
|
+
| | â
Eversweet 3 Pro UVC | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/6w5.png" width="40"/></a> |
|
|
172
|
+
| | â
Eversweet 5 Mini | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/2w5.png" width="40"/></a> |
|
|
173
|
+
| | â
Eversweet Max | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/ctw3.png" width="40"/></a> |
|
|
174
|
+
| **đ§´ Purifiers** | â
Air Magicube | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/k2.png" width="40"/></a> |
|
|
175
|
+
| | â
Air Smart Spray | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/k3.png" width="40"/></a> |
|
|
176
|
+
|
|
177
|
+
## đ Help and Support
|
|
178
|
+
|
|
179
|
+
Developers? Want to help? Join us on our Discord channel dedicated to developers and contributors.
|
|
180
|
+
|
|
181
|
+
[![Discord][discord-shield]][discord]
|
|
182
|
+
|
|
183
|
+
## đ¨âđģ Contributing
|
|
184
|
+
|
|
185
|
+
Contributions are welcome!\
|
|
186
|
+
Please open an issue or submit a pull request.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
[homeassistant_petkit]: https://github.com/Jezza34000/py-petkit-api
|
|
195
|
+
[commits-shield]: https://img.shields.io/github/commit-activity/y/Jezza34000/py-petkit-api.svg?style=flat
|
|
196
|
+
[commits]: https://github.com/Jezza34000/py-petkit-api/commits/main
|
|
197
|
+
[discord]: https://discord.gg/Va8DrmtweP
|
|
198
|
+
[discord-shield]: https://img.shields.io/discord/1318098700379361362.svg?style=for-the-badge&label=Discord&logo=discord&color=5865F2
|
|
199
|
+
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge&label=Home%20Assistant%20Community&logo=homeassistant&color=18bcf2
|
|
200
|
+
[forum]: https://community.home-assistant.io/t/petkit-integration/834431
|
|
201
|
+
[license-shield]: https://img.shields.io/github/license/Jezza34000/py-petkit-api.svg??style=flat
|
|
202
|
+
[maintenance-shield]: https://img.shields.io/badge/maintainer-Jezza34000-blue.svg?style=flat
|
|
203
|
+
[releases-shield]: https://img.shields.io/github/release/Jezza34000/py-petkit-api.svg?style=for-the-badge&color=41BDF5
|
|
204
|
+
[releases]: https://github.com/Jezza34000/py-petkit-api/releases
|
|
205
|
+
[github-sponsor-shield]: https://img.shields.io/badge/sponsor-Jezza34000-blue.svg?style=for-the-badge&logo=githubsponsors&color=EA4AAA
|
|
206
|
+
[github-sponsor]: https://github.com/sponsors/Jezza34000
|
|
207
|
+
[buymeacoffee-shield]: https://img.shields.io/badge/Donate-buy_me_a_coffee-yellow.svg?style=for-the-badge&logo=buy-me-a-coffee
|
|
208
|
+
[buymeacoffee]: https://www.buymeacoffee.com/jezza
|
|
209
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Petkit API Client
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
[](https://github.com/Jezza34000/py-petkit-api/)
|
|
6
|
+
[][python version] [](https://github.com/Jezza34000/py-petkit-api/actions)
|
|
7
|
+
|
|
8
|
+
[][pypi_] [](https://pepy.tech/projects/pypetkitapi)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api) [](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api) [](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
13
|
+
|
|
14
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
15
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
16
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
17
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
18
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
19
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
20
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
|
21
|
+
|
|
22
|
+
[][pre-commit]
|
|
23
|
+
[][black]
|
|
24
|
+
[](https://mypy.readthedocs.io/en/stable/)
|
|
25
|
+
[](https://github.com/astral-sh/ruff)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
[pypi_]: https://pypi.org/project/pypetkitapi/
|
|
30
|
+
[python version]: https://pypi.org/project/pypetkitapi
|
|
31
|
+
[pre-commit]: https://github.com/pre-commit/pre-commit
|
|
32
|
+
[black]: https://github.com/psf/black
|
|
33
|
+
|
|
34
|
+
### Enjoying this library?
|
|
35
|
+
|
|
36
|
+
[![Sponsor Jezza34000][github-sponsor-shield]][github-sponsor] [![Static Badge][buymeacoffee-shield]][buymeacoffee]
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## âšī¸ Overview
|
|
41
|
+
|
|
42
|
+
PetKit Client is a Python library for interacting with the PetKit API. It allows you to manage your PetKit devices, retrieve account data, and control devices through the API.
|
|
43
|
+
|
|
44
|
+
## đ Features
|
|
45
|
+
|
|
46
|
+
- Login and session management
|
|
47
|
+
- Fetch account and device data
|
|
48
|
+
- Control PetKit devices (Feeder, Litter Box, Water Fountain, Purifiers)
|
|
49
|
+
- Fetch images & videos produced by devices
|
|
50
|
+
> Pictures are available **with or without** Care+ subscription, Videos are only available **with** Care+ subscription
|
|
51
|
+
|
|
52
|
+
## âŦī¸ Installation
|
|
53
|
+
|
|
54
|
+
Install the library using pip:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install rankjie-pypetkitapi
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## đĄ Usage Example:
|
|
61
|
+
|
|
62
|
+
Here is a simple example of how to use the library to interact with the PetKit API \
|
|
63
|
+
This example is not an exhaustive list of all the features available in the library.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
import logging
|
|
68
|
+
import aiohttp
|
|
69
|
+
from pypetkitapi.client import PetKitClient
|
|
70
|
+
from pypetkitapi.command import DeviceCommand, FeederCommand, LBCommand, DeviceAction, LitterCommand
|
|
71
|
+
|
|
72
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
73
|
+
|
|
74
|
+
async def main():
|
|
75
|
+
async with aiohttp.ClientSession() as session:
|
|
76
|
+
client = PetKitClient(
|
|
77
|
+
username="username", # Your PetKit account username or id
|
|
78
|
+
password="password", # Your PetKit account password
|
|
79
|
+
region="FR", # Your region or country code (e.g. FR, US,CN etc.)
|
|
80
|
+
timezone="Europe/Paris", # Your timezone(e.g. "Asia/Shanghai")
|
|
81
|
+
session=session,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
await client.get_devices_data()
|
|
85
|
+
|
|
86
|
+
# Lists all devices and pet from account
|
|
87
|
+
|
|
88
|
+
for key, value in client.petkit_entities.items():
|
|
89
|
+
print(f"{key}: {type(value).__name__} - {value.name}")
|
|
90
|
+
|
|
91
|
+
# Select a device
|
|
92
|
+
device_id = key
|
|
93
|
+
# Read devices or pet information
|
|
94
|
+
print(client.petkit_entities[device_id])
|
|
95
|
+
|
|
96
|
+
# Send command to the devices
|
|
97
|
+
### Example 1 : Turn on the indicator light
|
|
98
|
+
### Device_ID, Command, Payload
|
|
99
|
+
await client.send_api_request(device_id, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
|
|
100
|
+
|
|
101
|
+
### Example 2 : Feed the pet
|
|
102
|
+
### Device_ID, Command, Payload
|
|
103
|
+
# simple hopper :
|
|
104
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount": 1})
|
|
105
|
+
# dual hopper :
|
|
106
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount1": 2})
|
|
107
|
+
# or
|
|
108
|
+
await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount2": 2})
|
|
109
|
+
|
|
110
|
+
### Example 3 : Start the cleaning process
|
|
111
|
+
### Device_ID, Command, Payload
|
|
112
|
+
await client.send_api_request(device_id, LitterCommand.CONTROL_DEVICE, {DeviceAction.START: LBCommand.CLEANING})
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
asyncio.run(main())
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## đĄ More example usage
|
|
120
|
+
|
|
121
|
+
Check at the usage in the Home Assistant integration : [here](https://github.com/Jezza34000/homeassistant_petkit)
|
|
122
|
+
|
|
123
|
+
## âī¸ Supported Devices
|
|
124
|
+
|
|
125
|
+
| **Category** | **Name** | **Device** |
|
|
126
|
+
| ---------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
127
|
+
| **đ Feeders** | â
Fresh Element | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/feeder.png" width="40"/></a> |
|
|
128
|
+
| | â
Fresh Element Mini Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/feedermini.png" width="40"/></a> |
|
|
129
|
+
| | â
Fresh Element Infinity | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d3.png" width="40"/></a> |
|
|
130
|
+
| | â
Fresh Element Solo | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4.png" width="40"/></a> |
|
|
131
|
+
| | â
Fresh Element Gemini | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4s.png" width="40"/></a> |
|
|
132
|
+
| | â
YumShare Solo | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4h.png" width="40"/></a> |
|
|
133
|
+
| | â
YumShare Dual-hopper | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/d4sh.png" width="40"/></a> |
|
|
134
|
+
| **đŊ Litters** | â
PuraX | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t3.png" width="40"/></a> |
|
|
135
|
+
| | â
PuraMax | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t4.1.png" width="40"/></a> |
|
|
136
|
+
| | â
PuraMax 2 | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t4.png" width="40"/></a> |
|
|
137
|
+
| | â
Purobot Max Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t5.png" width="40"/></a> |
|
|
138
|
+
| | â
Purobot Ultra | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/t6.png" width="40"/></a> |
|
|
139
|
+
| **ⲠFountains** | â
Eversweet Solo 2 | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/5w5.png" width="40"/></a> |
|
|
140
|
+
| | â
Eversweet 3 Pro | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/4w5.png" width="40"/></a> |
|
|
141
|
+
| | â
Eversweet 3 Pro UVC | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/6w5.png" width="40"/></a> |
|
|
142
|
+
| | â
Eversweet 5 Mini | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/2w5.png" width="40"/></a> |
|
|
143
|
+
| | â
Eversweet Max | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/ctw3.png" width="40"/></a> |
|
|
144
|
+
| **đ§´ Purifiers** | â
Air Magicube | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/k2.png" width="40"/></a> |
|
|
145
|
+
| | â
Air Smart Spray | <a href=""><img src="https://raw.githubusercontent.com/Jezza34000/homeassistant_petkit/refs/heads/main/images/devices/k3.png" width="40"/></a> |
|
|
146
|
+
|
|
147
|
+
## đ Help and Support
|
|
148
|
+
|
|
149
|
+
Developers? Want to help? Join us on our Discord channel dedicated to developers and contributors.
|
|
150
|
+
|
|
151
|
+
[![Discord][discord-shield]][discord]
|
|
152
|
+
|
|
153
|
+
## đ¨âđģ Contributing
|
|
154
|
+
|
|
155
|
+
Contributions are welcome!\
|
|
156
|
+
Please open an issue or submit a pull request.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
[homeassistant_petkit]: https://github.com/Jezza34000/py-petkit-api
|
|
165
|
+
[commits-shield]: https://img.shields.io/github/commit-activity/y/Jezza34000/py-petkit-api.svg?style=flat
|
|
166
|
+
[commits]: https://github.com/Jezza34000/py-petkit-api/commits/main
|
|
167
|
+
[discord]: https://discord.gg/Va8DrmtweP
|
|
168
|
+
[discord-shield]: https://img.shields.io/discord/1318098700379361362.svg?style=for-the-badge&label=Discord&logo=discord&color=5865F2
|
|
169
|
+
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge&label=Home%20Assistant%20Community&logo=homeassistant&color=18bcf2
|
|
170
|
+
[forum]: https://community.home-assistant.io/t/petkit-integration/834431
|
|
171
|
+
[license-shield]: https://img.shields.io/github/license/Jezza34000/py-petkit-api.svg??style=flat
|
|
172
|
+
[maintenance-shield]: https://img.shields.io/badge/maintainer-Jezza34000-blue.svg?style=flat
|
|
173
|
+
[releases-shield]: https://img.shields.io/github/release/Jezza34000/py-petkit-api.svg?style=for-the-badge&color=41BDF5
|
|
174
|
+
[releases]: https://github.com/Jezza34000/py-petkit-api/releases
|
|
175
|
+
[github-sponsor-shield]: https://img.shields.io/badge/sponsor-Jezza34000-blue.svg?style=for-the-badge&logo=githubsponsors&color=EA4AAA
|
|
176
|
+
[github-sponsor]: https://github.com/sponsors/Jezza34000
|
|
177
|
+
[buymeacoffee-shield]: https://img.shields.io/badge/Donate-buy_me_a_coffee-yellow.svg?style=for-the-badge&logo=buy-me-a-coffee
|
|
178
|
+
[buymeacoffee]: https://www.buymeacoffee.com/jezza
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Pypetkit: A Python library for interfacing with PetKit"""
|
|
2
|
+
|
|
3
|
+
from .client import PetKitClient
|
|
4
|
+
from .command import (
|
|
5
|
+
DeviceAction,
|
|
6
|
+
DeviceCommand,
|
|
7
|
+
FeederCommand,
|
|
8
|
+
FountainCommand,
|
|
9
|
+
LBCommand,
|
|
10
|
+
LitterCommand,
|
|
11
|
+
PetCommand,
|
|
12
|
+
PurMode,
|
|
13
|
+
)
|
|
14
|
+
from .const import (
|
|
15
|
+
CTW3,
|
|
16
|
+
D3,
|
|
17
|
+
D4,
|
|
18
|
+
D4H,
|
|
19
|
+
D4S,
|
|
20
|
+
D4SH,
|
|
21
|
+
DEVICES_FEEDER,
|
|
22
|
+
DEVICES_LITTER_BOX,
|
|
23
|
+
DEVICES_PURIFIER,
|
|
24
|
+
DEVICES_WATER_FOUNTAIN,
|
|
25
|
+
FEEDER,
|
|
26
|
+
FEEDER_MINI,
|
|
27
|
+
FEEDER_WITH_CAMERA,
|
|
28
|
+
K2,
|
|
29
|
+
K3,
|
|
30
|
+
LITTER_NO_CAMERA,
|
|
31
|
+
LITTER_WITH_CAMERA,
|
|
32
|
+
T3,
|
|
33
|
+
T4,
|
|
34
|
+
T5,
|
|
35
|
+
T6,
|
|
36
|
+
T7,
|
|
37
|
+
W5,
|
|
38
|
+
BluetoothState,
|
|
39
|
+
MediaType,
|
|
40
|
+
RecordType,
|
|
41
|
+
)
|
|
42
|
+
from .containers import IotInfo, LiveFeed, NewIotInfo, Pet
|
|
43
|
+
from .exceptions import (
|
|
44
|
+
PetkitAuthenticationUnregisteredEmailError,
|
|
45
|
+
PetkitRegionalServerNotFoundError,
|
|
46
|
+
PetkitSessionError,
|
|
47
|
+
PetkitSessionExpiredError,
|
|
48
|
+
PetkitTimeoutError,
|
|
49
|
+
PypetkitError,
|
|
50
|
+
)
|
|
51
|
+
from .feeder_container import Feeder, RecordsItems
|
|
52
|
+
from .litter_container import Litter, LitterRecord, WorkState
|
|
53
|
+
from .media import DownloadDecryptMedia, MediaCloud, MediaFile, MediaManager
|
|
54
|
+
from .purifier_container import Purifier
|
|
55
|
+
from .water_fountain_container import WaterFountain
|
|
56
|
+
|
|
57
|
+
__version__ = "1.3.0.dev1"
|
|
58
|
+
|
|
59
|
+
__all__ = [
|
|
60
|
+
"CTW3",
|
|
61
|
+
"D3",
|
|
62
|
+
"D4",
|
|
63
|
+
"D4H",
|
|
64
|
+
"D4S",
|
|
65
|
+
"D4SH",
|
|
66
|
+
"DEVICES_FEEDER",
|
|
67
|
+
"DEVICES_LITTER_BOX",
|
|
68
|
+
"DEVICES_PURIFIER",
|
|
69
|
+
"DEVICES_WATER_FOUNTAIN",
|
|
70
|
+
"FEEDER",
|
|
71
|
+
"FEEDER_MINI",
|
|
72
|
+
"FEEDER_WITH_CAMERA",
|
|
73
|
+
"K2",
|
|
74
|
+
"K3",
|
|
75
|
+
"LITTER_NO_CAMERA",
|
|
76
|
+
"LITTER_WITH_CAMERA",
|
|
77
|
+
"T3",
|
|
78
|
+
"T4",
|
|
79
|
+
"T5",
|
|
80
|
+
"T6",
|
|
81
|
+
"T7",
|
|
82
|
+
"W5",
|
|
83
|
+
"BluetoothState",
|
|
84
|
+
"DeviceAction",
|
|
85
|
+
"DeviceCommand",
|
|
86
|
+
"DownloadDecryptMedia",
|
|
87
|
+
"Feeder",
|
|
88
|
+
"FeederCommand",
|
|
89
|
+
"FountainCommand",
|
|
90
|
+
"IotInfo",
|
|
91
|
+
"LBCommand",
|
|
92
|
+
"Litter",
|
|
93
|
+
"LitterCommand",
|
|
94
|
+
"LitterRecord",
|
|
95
|
+
"LiveFeed",
|
|
96
|
+
"MediaCloud",
|
|
97
|
+
"MediaFile",
|
|
98
|
+
"MediaManager",
|
|
99
|
+
"MediaType",
|
|
100
|
+
"NewIotInfo",
|
|
101
|
+
"Pet",
|
|
102
|
+
"PetCommand",
|
|
103
|
+
"PetKitClient",
|
|
104
|
+
"PetkitAuthenticationUnregisteredEmailError",
|
|
105
|
+
"PetkitRegionalServerNotFoundError",
|
|
106
|
+
"PetkitSessionError",
|
|
107
|
+
"PetkitSessionExpiredError",
|
|
108
|
+
"PetkitTimeoutError",
|
|
109
|
+
"PurMode",
|
|
110
|
+
"Purifier",
|
|
111
|
+
"PypetkitError",
|
|
112
|
+
"RecordType",
|
|
113
|
+
"RecordsItems",
|
|
114
|
+
"WaterFountain",
|
|
115
|
+
"WorkState",
|
|
116
|
+
]
|