pypetkitapi 0.1.0__py3-none-any.whl
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/__init__.py +1 -0
- pypetkitapi/client.py +355 -0
- pypetkitapi/command.py +292 -0
- pypetkitapi/const.py +112 -0
- pypetkitapi/containers.py +116 -0
- pypetkitapi/exceptions.py +15 -0
- pypetkitapi/feeder_container.py +247 -0
- pypetkitapi/litter_container.py +177 -0
- pypetkitapi/water_fountain_container.py +135 -0
- pypetkitapi-0.1.0.dist-info/LICENSE +21 -0
- pypetkitapi-0.1.0.dist-info/METADATA +111 -0
- pypetkitapi-0.1.0.dist-info/RECORD +13 -0
- pypetkitapi-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
"""Dataclasses for Water Fountain."""
|
2
|
+
|
3
|
+
from collections.abc import Callable
|
4
|
+
from typing import Any, ClassVar
|
5
|
+
|
6
|
+
from pydantic import BaseModel, Field
|
7
|
+
|
8
|
+
from pypetkitapi.const import PetkitEndpoint
|
9
|
+
|
10
|
+
|
11
|
+
class Electricity(BaseModel):
|
12
|
+
"""Dataclass for electricity details.
|
13
|
+
-> WaterFountainData subclass.
|
14
|
+
"""
|
15
|
+
|
16
|
+
battery_percent: int | None = Field(None, alias="batteryPercent")
|
17
|
+
battery_voltage: int | None = Field(None, alias="batteryVoltage")
|
18
|
+
supply_voltage: int | None = Field(None, alias="supplyVoltage")
|
19
|
+
|
20
|
+
|
21
|
+
class Type(BaseModel):
|
22
|
+
"""Dataclass for type details.
|
23
|
+
-> WaterFountainData subclass.
|
24
|
+
"""
|
25
|
+
|
26
|
+
enable: int | None = None
|
27
|
+
id: str | None = None
|
28
|
+
img: str | None = None
|
29
|
+
is_custom: int | None = Field(None, alias="isCustom")
|
30
|
+
name: str | None = None
|
31
|
+
priority: int | None = None
|
32
|
+
with_device_type: str | None = Field(None, alias="withDeviceType")
|
33
|
+
with_pet: int | None = Field(None, alias="withPet")
|
34
|
+
|
35
|
+
|
36
|
+
class Schedule(BaseModel):
|
37
|
+
"""Dataclass for schedule details.
|
38
|
+
-> WaterFountainData subclass.
|
39
|
+
"""
|
40
|
+
|
41
|
+
alarm_before: int | None = Field(None, alias="alarmBefore")
|
42
|
+
created_at: str | None = Field(None, alias="createdAt")
|
43
|
+
device_id: str | None = Field(None, alias="deviceId")
|
44
|
+
device_type: str | None = Field(None, alias="deviceType")
|
45
|
+
id: str | None = None
|
46
|
+
name: str | None = None
|
47
|
+
repeat: str | None = None
|
48
|
+
status: int | None = None
|
49
|
+
time: str | None = None
|
50
|
+
type: Type | None = None
|
51
|
+
user_custom_id: int | None = Field(None, alias="userCustomId")
|
52
|
+
|
53
|
+
|
54
|
+
class SettingsFountain(BaseModel):
|
55
|
+
"""Dataclass for settings.
|
56
|
+
-> WaterFountainData subclass.
|
57
|
+
"""
|
58
|
+
|
59
|
+
battery_sleep_time: int | None = Field(None, alias="batterySleepTime")
|
60
|
+
battery_working_time: int | None = Field(None, alias="batteryWorkingTime")
|
61
|
+
distribution_diagram: int | None = Field(None, alias="distributionDiagram")
|
62
|
+
disturb_config: int | None = Field(None, alias="disturbConfig")
|
63
|
+
disturb_multi_time: list[dict[str, Any]] | None = Field(
|
64
|
+
None, alias="disturbMultiTime"
|
65
|
+
)
|
66
|
+
lamp_ring_brightness: int | None = Field(None, alias="lampRingBrightness")
|
67
|
+
lamp_ring_switch: int | None = Field(None, alias="lampRingSwitch")
|
68
|
+
light_config: int | None = Field(None, alias="lightConfig")
|
69
|
+
light_multi_time: list[dict[str, Any]] | None = Field(None, alias="lightMultiTime")
|
70
|
+
no_disturbing_switch: int | None = Field(None, alias="noDisturbingSwitch")
|
71
|
+
smart_sleep_time: int | None = Field(None, alias="smartSleepTime")
|
72
|
+
smart_working_time: int | None = Field(None, alias="smartWorkingTime")
|
73
|
+
|
74
|
+
|
75
|
+
class Status(BaseModel):
|
76
|
+
"""Dataclass for status details.
|
77
|
+
-> WaterFountainData subclass.
|
78
|
+
"""
|
79
|
+
|
80
|
+
detect_status: int | None = Field(None, alias="detectStatus")
|
81
|
+
electric_status: int | None = Field(None, alias="electricStatus")
|
82
|
+
power_status: int | None = Field(None, alias="powerStatus")
|
83
|
+
run_status: int | None = Field(None, alias="runStatus")
|
84
|
+
suspend_status: int | None = Field(None, alias="suspendStatus")
|
85
|
+
|
86
|
+
|
87
|
+
class WaterFountain(BaseModel):
|
88
|
+
"""Dataclass for Water Fountain Data.
|
89
|
+
Supported devices = CTW3
|
90
|
+
"""
|
91
|
+
|
92
|
+
url_endpoint: ClassVar[PetkitEndpoint] = PetkitEndpoint.DEVICE_DATA
|
93
|
+
query_param: ClassVar[Callable] = lambda device_id: {"id": device_id}
|
94
|
+
|
95
|
+
breakdown_warning: int | None = Field(None, alias="breakdownWarning")
|
96
|
+
created_at: str | None = Field(None, alias="createdAt")
|
97
|
+
electricity: Electricity | None = None
|
98
|
+
expected_clean_water: int | None = Field(None, alias="expectedCleanWater")
|
99
|
+
expected_use_electricity: float | None = Field(None, alias="expectedUseElectricity")
|
100
|
+
filter_expected_days: int | None = Field(None, alias="filterExpectedDays")
|
101
|
+
filter_percent: int | None = Field(None, alias="filterPercent")
|
102
|
+
filter_warning: int | None = Field(None, alias="filterWarning")
|
103
|
+
firmware: int | None = None
|
104
|
+
hardware: int | None = None
|
105
|
+
id: int | None = None
|
106
|
+
is_night_no_disturbing: int | None = Field(None, alias="isNightNoDisturbing")
|
107
|
+
lack_warning: int | None = Field(None, alias="lackWarning")
|
108
|
+
locale: str | None = None
|
109
|
+
low_battery: int | None = Field(None, alias="lowBattery")
|
110
|
+
mac: str | None = None
|
111
|
+
mode: int | None = None
|
112
|
+
module_status: int | None = Field(None, alias="moduleStatus")
|
113
|
+
name: str | None = None
|
114
|
+
record_automatic_add_water: int | None = Field(
|
115
|
+
None, alias="recordAutomaticAddWater"
|
116
|
+
)
|
117
|
+
schedule: Schedule | None = None
|
118
|
+
secret: str | None = None
|
119
|
+
settings: SettingsFountain | None = None
|
120
|
+
sn: str | None = None
|
121
|
+
status: Status | None = None
|
122
|
+
sync_time: str | None = Field(None, alias="syncTime")
|
123
|
+
timezone: float | None = None
|
124
|
+
today_clean_water: int | None = Field(None, alias="todayCleanWater")
|
125
|
+
today_pump_run_time: int | None = Field(None, alias="todayPumpRunTime")
|
126
|
+
today_use_electricity: float | None = Field(None, alias="todayUseElectricity")
|
127
|
+
update_at: str | None = Field(None, alias="updateAt")
|
128
|
+
user_id: str | None = Field(None, alias="userId")
|
129
|
+
water_pump_run_time: int | None = Field(None, alias="waterPumpRunTime")
|
130
|
+
device_type: str | None = Field(None, alias="deviceType")
|
131
|
+
|
132
|
+
@classmethod
|
133
|
+
def get_endpoint(cls, device_type: str) -> str:
|
134
|
+
"""Get the endpoint URL for the given device type."""
|
135
|
+
return cls.url_endpoint.value
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 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,111 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: pypetkitapi
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Python client for PetKit API
|
5
|
+
Home-page: https://github.com/Jezza34000/pypetkit
|
6
|
+
License: MIT
|
7
|
+
Author: Jezza34000
|
8
|
+
Author-email: info@mail.com
|
9
|
+
Requires-Python: >=3.11
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
15
|
+
Requires-Dist: aiohttp (>=3.11.0,<4.0.0)
|
16
|
+
Description-Content-Type: text/markdown
|
17
|
+
|
18
|
+
# Petkit API Client
|
19
|
+
|
20
|
+
---
|
21
|
+
|
22
|
+
# WIP - UNDER DEVELOPMENT
|
23
|
+
|
24
|
+
---
|
25
|
+
|
26
|
+
[][pypi_]
|
27
|
+
[][python version]
|
28
|
+
|
29
|
+
[][pre-commit]
|
30
|
+
[][black]
|
31
|
+
[](https://mypy.readthedocs.io/en/stable/)
|
32
|
+
[](https://github.com/astral-sh/ruff)
|
33
|
+
[](https://github.com/Jezza34000/py-petkit-api/actions)
|
34
|
+
|
35
|
+
---
|
36
|
+
|
37
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
38
|
+
[](https://sonarcloud.io/summary/new_code?id=Jezza34000_py-petkit-api)
|
39
|
+
|
40
|
+
[pypi_]: https://pypi.org/project/pypetkitapi/
|
41
|
+
[python version]: https://pypi.org/project/pypetkitapi
|
42
|
+
[pre-commit]: https://github.com/pre-commit/pre-commit
|
43
|
+
[black]: https://github.com/psf/black
|
44
|
+
|
45
|
+
## Overview
|
46
|
+
|
47
|
+
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.
|
48
|
+
|
49
|
+
## Features
|
50
|
+
|
51
|
+
Login and session management
|
52
|
+
Fetch account and device data
|
53
|
+
Control PetKit devices (Feeder, Litter Box, Water Fountain)
|
54
|
+
|
55
|
+
## Installation
|
56
|
+
|
57
|
+
Install the library using pip:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
pip install pypetkitapi
|
61
|
+
```
|
62
|
+
|
63
|
+
## Usage Example:
|
64
|
+
|
65
|
+
```python
|
66
|
+
import asyncio
|
67
|
+
import logging
|
68
|
+
from pypetkitapi.client import PetKitClient
|
69
|
+
|
70
|
+
logging.basicConfig(level=logging.DEBUG)
|
71
|
+
|
72
|
+
|
73
|
+
async def main():
|
74
|
+
client = PetKitClient(
|
75
|
+
username="username", # Your PetKit account username
|
76
|
+
password="password", # Your PetKit account password
|
77
|
+
region="France", # Your region
|
78
|
+
timezone="Europe/Paris", # Your timezone
|
79
|
+
)
|
80
|
+
|
81
|
+
# To get the account and devices data attached to the account
|
82
|
+
await client.get_devices_data()
|
83
|
+
# Read the account data
|
84
|
+
print(client.account_data)
|
85
|
+
# Read the devices data
|
86
|
+
print(client.device_list)
|
87
|
+
|
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
|
+
# Send command to the devices
|
93
|
+
### Example 1 : Turn on the indicator light
|
94
|
+
await client.send_api_request(my_feeder, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
|
95
|
+
|
96
|
+
### Example 2 : Feed the pet
|
97
|
+
await client.send_api_request(my_feeder, FeederCommand.MANUAL_FEED, {"amount": 1})
|
98
|
+
|
99
|
+
|
100
|
+
if __name__ == "__main__":
|
101
|
+
asyncio.run(main())
|
102
|
+
```
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
107
|
+
|
108
|
+
## License
|
109
|
+
|
110
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
111
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
pypetkitapi/__init__.py,sha256=eVpyGMD3tkYtiHUkdKEeNSZhQlZ4woI2Y5oVoV7CwXM,61
|
2
|
+
pypetkitapi/client.py,sha256=bqZv773AzwEKzwWN9xEQw0paR8FGVWKBrVFfdX4y4vE,12716
|
3
|
+
pypetkitapi/command.py,sha256=ibJ0zenONy-FBvUvyIA_IvUnYEUezLpPxhC_9XZ6SwM,9282
|
4
|
+
pypetkitapi/const.py,sha256=8V4t-_5TXiZpIz8l_7F28DFt4693O5vNJ8N9TDWvWG8,2818
|
5
|
+
pypetkitapi/containers.py,sha256=GQqZKaDgemQM4UDnugWYDP7N01anpJwO4VjQy2Gla3E,3109
|
6
|
+
pypetkitapi/exceptions.py,sha256=gjHswRYXSCTMy8_pu-Rzbt3gz2tdHDtP3j03lwuGirk,328
|
7
|
+
pypetkitapi/feeder_container.py,sha256=5dCgXAHafl2kMk4jM4JGPgE0f48JBs0UkA1TvLPTfXU,10994
|
8
|
+
pypetkitapi/litter_container.py,sha256=tKYd7iaj88TtR0W-wJ6U8PmsUzCcWg4ZisblOTKjKSg,8957
|
9
|
+
pypetkitapi/water_fountain_container.py,sha256=g_J1nYuNTlDg-ltvo2FZRTxKWLgW9E0GVzbFKO6jpA8,5346
|
10
|
+
pypetkitapi-0.1.0.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
|
11
|
+
pypetkitapi-0.1.0.dist-info/METADATA,sha256=jtiGGKyqYetPzdRoO70PiZFtYjSwzKDW3BJkuXF9eIE,3700
|
12
|
+
pypetkitapi-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
13
|
+
pypetkitapi-0.1.0.dist-info/RECORD,,
|