petsseries 0.0.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.
- petsseries-0.0.1/PKG-INFO +219 -0
- petsseries-0.0.1/README.md +203 -0
- petsseries-0.0.1/petsseries.egg-info/PKG-INFO +219 -0
- petsseries-0.0.1/petsseries.egg-info/SOURCES.txt +9 -0
- petsseries-0.0.1/petsseries.egg-info/dependency_links.txt +1 -0
- petsseries-0.0.1/petsseries.egg-info/requires.txt +4 -0
- petsseries-0.0.1/petsseries.egg-info/top_level.txt +1 -0
- petsseries-0.0.1/pyproject.toml +3 -0
- petsseries-0.0.1/setup.cfg +7 -0
- petsseries-0.0.1/setup.py +23 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: petsseries
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Unofficial Python client for interacting with the Philips Pets Series API
|
|
5
|
+
Home-page: https://github.com/abovecolin/petsseries
|
|
6
|
+
Author: AboveColin
|
|
7
|
+
Author-email: colin@cdevries.dev
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: aiohttp
|
|
13
|
+
Requires-Dist: aiofiles
|
|
14
|
+
Requires-Dist: certifi
|
|
15
|
+
Requires-Dist: PyJWT
|
|
16
|
+
|
|
17
|
+
# Unofficial PetsSeries API Client
|
|
18
|
+
|
|
19
|
+
_Disclaimer: This is an unofficial Python client for the PetsSeries API. It is not affiliated with, endorsed by, or in any way connected to the official PetsSeries, Versuni or Philips companies._
|
|
20
|
+
|
|
21
|
+
## Introduction
|
|
22
|
+
The Unofficial PetsSeries API Client is a Python library designed to interact with the PetsSeries backend services. It provides asynchronous methods to manage user information, homes, devices, meals, events, and device settings. This client handles authentication, token refreshing, and provides a convenient interface for integrating PetsSeries functionalities into your Python applications.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
- **Authentication Management:** Handles access and refresh tokens, including automatic refreshing when expired.
|
|
26
|
+
- **Comprehensive API Coverage:** Methods to interact with user info, homes, devices, meals, events, and device settings.
|
|
27
|
+
- **Event Parsing:** Automatically parses different event types into structured Python objects.
|
|
28
|
+
- **Easy Integration:** Simple initialization and usage patterns for quick integration into projects.
|
|
29
|
+
|
|
30
|
+
## Features to be Added
|
|
31
|
+
- **Schedule Management:** Methods to manage schedules
|
|
32
|
+
- **Camera Feed Access:** Methods to access camera feeds
|
|
33
|
+
- **Food Dispenser Control:** Methods to control food dispensers
|
|
34
|
+
|
|
35
|
+
(feel free to PR if you manage to implement any of these features)
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
Ensure you have Python 3.10 or higher installed. You can install the package using pip:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install -r requirements.txt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Authentication
|
|
45
|
+
This client uses OAuth2 tokens (access_token and refresh_token) to authenticate with the PetsSeries API. Follow the steps below to obtain and set up your tokens.
|
|
46
|
+
|
|
47
|
+
### Obtaining Tokens
|
|
48
|
+
1. Login via Web Interface:
|
|
49
|
+
|
|
50
|
+
- Navigate to [PetsSeries Appliance Login](https://www.home.id/find-appliance).
|
|
51
|
+
- Select a PetsSeries product (Starts with PAW) and log in with your credentials.
|
|
52
|
+
|
|
53
|
+
2. Retrieve Tokens:
|
|
54
|
+
|
|
55
|
+
- After logging in, you will be redirected to a "Thanks for your purchase" screen.
|
|
56
|
+
- Open your browser's developer tools (usually by pressing F12 or Ctrl+Shift+I).
|
|
57
|
+
- Go to the Application tab and inspect the cookies.
|
|
58
|
+
- Locate and copy the cc-access-token and cc-refresh-token from the cookies.
|
|
59
|
+
|
|
60
|
+
3. Provide Tokens to the Client:
|
|
61
|
+
|
|
62
|
+
- You can provide the access_token and refresh_token when initializing the client. These tokens will be saved to tokens.json for future use.
|
|
63
|
+
|
|
64
|
+
### Example Initialization with Tokens
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
from petsseries import PetsSeriesClient
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
client = PetsSeriesClient(
|
|
71
|
+
access_token="your_access_token_here",
|
|
72
|
+
refresh_token="your_refresh_token_here"
|
|
73
|
+
)
|
|
74
|
+
await client.initialize()
|
|
75
|
+
# Your code here
|
|
76
|
+
|
|
77
|
+
asyncio.run(main())
|
|
78
|
+
```
|
|
79
|
+
After the first run, the tokens will be saved automatically, and you won't need to provide them again unless they are invalidated.
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
### Initialization
|
|
83
|
+
Initialize the PetsSeriesClient with optional access_token and refresh_token. If tokens are not provided, ensure that tokens.json exists with valid tokens.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import asyncio
|
|
87
|
+
from petsseries import PetsSeriesClient
|
|
88
|
+
|
|
89
|
+
async def initialize_client():
|
|
90
|
+
async with PetsSeriesClient() as client:
|
|
91
|
+
await client.initialize()
|
|
92
|
+
# Use the client for API calls
|
|
93
|
+
|
|
94
|
+
asyncio.run(initialize_client())
|
|
95
|
+
```
|
|
96
|
+
### Fetching Data
|
|
97
|
+
The client provides various methods to fetch data from the PetsSeries API.
|
|
98
|
+
|
|
99
|
+
#### Get User Info
|
|
100
|
+
```python
|
|
101
|
+
user = await client.get_user_info()
|
|
102
|
+
print(user.name, user.email)
|
|
103
|
+
```
|
|
104
|
+
#### Get Homes
|
|
105
|
+
```python
|
|
106
|
+
homes = await client.get_homes()
|
|
107
|
+
for home in homes:
|
|
108
|
+
print(home.name)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Get Devices
|
|
112
|
+
```python
|
|
113
|
+
for home in homes:
|
|
114
|
+
devices = await client.get_devices(home)
|
|
115
|
+
for device in devices:
|
|
116
|
+
print(device.name, device.id)
|
|
117
|
+
```
|
|
118
|
+
### Get Events
|
|
119
|
+
```python
|
|
120
|
+
from datetime import datetime
|
|
121
|
+
from pytz import timezone
|
|
122
|
+
|
|
123
|
+
from_date = datetime(2024, 9, 27, tzinfo=timezone("Europe/Amsterdam"))
|
|
124
|
+
to_date = datetime(2024, 9, 28, tzinfo=timezone("Europe/Amsterdam"))
|
|
125
|
+
|
|
126
|
+
events = await client.get_events(home, from_date, to_date)
|
|
127
|
+
for event in events:
|
|
128
|
+
print(event)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Managing Devices
|
|
132
|
+
You can manage device settings such as powering devices on/off and toggling motion notifications.
|
|
133
|
+
|
|
134
|
+
#### Device Power
|
|
135
|
+
```python
|
|
136
|
+
result = await client.power_on_device(home, device_id)
|
|
137
|
+
if result:
|
|
138
|
+
print("Device powered on successfully.")
|
|
139
|
+
|
|
140
|
+
result = await client.power_off_device(home, device_id)
|
|
141
|
+
if result:
|
|
142
|
+
print("Device powered off successfully.")
|
|
143
|
+
|
|
144
|
+
result = await client.toggle_device_power(home, device_id)
|
|
145
|
+
if result:
|
|
146
|
+
print("Device power toggled successfully.")
|
|
147
|
+
```
|
|
148
|
+
#### Motion Notifications
|
|
149
|
+
```python
|
|
150
|
+
result = await client.enable_motion_notifications(home, device_id)
|
|
151
|
+
if result:
|
|
152
|
+
print("Motion notifications enabled successfully.")
|
|
153
|
+
|
|
154
|
+
result = await client.disable_motion_notifications(home, device_id)
|
|
155
|
+
if result:
|
|
156
|
+
print("Motion notifications disabled successfully.")
|
|
157
|
+
|
|
158
|
+
result = await client.toggle_motion_notifications(home, device_id)
|
|
159
|
+
if result:
|
|
160
|
+
print("Motion notifications toggled successfully.")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Example
|
|
164
|
+
Here's a complete example demonstrating how to initialize the client, fetch user info, homes, devices, and manage device settings.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
import asyncio
|
|
168
|
+
from petsseries import PetsSeriesClient
|
|
169
|
+
|
|
170
|
+
async def main():
|
|
171
|
+
async with PetsSeriesClient(
|
|
172
|
+
access_token="your_access_token_here",
|
|
173
|
+
refresh_token="your_refresh_token_here"
|
|
174
|
+
) as client:
|
|
175
|
+
await client.initialize()
|
|
176
|
+
|
|
177
|
+
# Fetch user info
|
|
178
|
+
user = await client.get_user_info()
|
|
179
|
+
print(f"User: {user.name} ({user.email})")
|
|
180
|
+
|
|
181
|
+
# Fetch homes
|
|
182
|
+
homes = await client.get_homes()
|
|
183
|
+
for home in homes:
|
|
184
|
+
print(f"Home: {home.name}")
|
|
185
|
+
|
|
186
|
+
# Fetch devices in home
|
|
187
|
+
devices = await client.get_devices(home)
|
|
188
|
+
for device in devices:
|
|
189
|
+
print(f"Device: {device.name} (ID: {device.id})")
|
|
190
|
+
|
|
191
|
+
# Power off device
|
|
192
|
+
success = await client.power_off_device(home, device.id)
|
|
193
|
+
if success:
|
|
194
|
+
print(f"{device.name} powered off.")
|
|
195
|
+
|
|
196
|
+
# Toggle motion notifications
|
|
197
|
+
success = await client.toggle_motion_notifications(home, device.id)
|
|
198
|
+
if success:
|
|
199
|
+
print(f"Motion notifications toggled for {device.name}.")
|
|
200
|
+
|
|
201
|
+
from_date = dt.datetime(2021, 9, 27, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
202
|
+
to_date = dt.datetime(2100, 9, 28, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
203
|
+
print(from_date, to_date)
|
|
204
|
+
|
|
205
|
+
events = await client.get_events(home, from_date, to_date)
|
|
206
|
+
# Possible eventTypes are: ["motion_detected", "meal_dispensed", "meal_upcoming", "food_level_low"]
|
|
207
|
+
for event in events:
|
|
208
|
+
if event.type == "meal_dispensed":
|
|
209
|
+
logger.info(f"Event: {event}")
|
|
210
|
+
|
|
211
|
+
if __name__ == "__main__":
|
|
212
|
+
asyncio.run(main())
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Contributing
|
|
216
|
+
Contributions are more than welcome!
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
__Disclaimer:__ This project is not affiliated with PetsSeries or Versuni. It is developed independently and is intended for personal use. Use it responsibly and respect the terms of service of the official PetsSeries API.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Unofficial PetsSeries API Client
|
|
2
|
+
|
|
3
|
+
_Disclaimer: This is an unofficial Python client for the PetsSeries API. It is not affiliated with, endorsed by, or in any way connected to the official PetsSeries, Versuni or Philips companies._
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
The Unofficial PetsSeries API Client is a Python library designed to interact with the PetsSeries backend services. It provides asynchronous methods to manage user information, homes, devices, meals, events, and device settings. This client handles authentication, token refreshing, and provides a convenient interface for integrating PetsSeries functionalities into your Python applications.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
- **Authentication Management:** Handles access and refresh tokens, including automatic refreshing when expired.
|
|
10
|
+
- **Comprehensive API Coverage:** Methods to interact with user info, homes, devices, meals, events, and device settings.
|
|
11
|
+
- **Event Parsing:** Automatically parses different event types into structured Python objects.
|
|
12
|
+
- **Easy Integration:** Simple initialization and usage patterns for quick integration into projects.
|
|
13
|
+
|
|
14
|
+
## Features to be Added
|
|
15
|
+
- **Schedule Management:** Methods to manage schedules
|
|
16
|
+
- **Camera Feed Access:** Methods to access camera feeds
|
|
17
|
+
- **Food Dispenser Control:** Methods to control food dispensers
|
|
18
|
+
|
|
19
|
+
(feel free to PR if you manage to implement any of these features)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
Ensure you have Python 3.10 or higher installed. You can install the package using pip:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -r requirements.txt
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Authentication
|
|
29
|
+
This client uses OAuth2 tokens (access_token and refresh_token) to authenticate with the PetsSeries API. Follow the steps below to obtain and set up your tokens.
|
|
30
|
+
|
|
31
|
+
### Obtaining Tokens
|
|
32
|
+
1. Login via Web Interface:
|
|
33
|
+
|
|
34
|
+
- Navigate to [PetsSeries Appliance Login](https://www.home.id/find-appliance).
|
|
35
|
+
- Select a PetsSeries product (Starts with PAW) and log in with your credentials.
|
|
36
|
+
|
|
37
|
+
2. Retrieve Tokens:
|
|
38
|
+
|
|
39
|
+
- After logging in, you will be redirected to a "Thanks for your purchase" screen.
|
|
40
|
+
- Open your browser's developer tools (usually by pressing F12 or Ctrl+Shift+I).
|
|
41
|
+
- Go to the Application tab and inspect the cookies.
|
|
42
|
+
- Locate and copy the cc-access-token and cc-refresh-token from the cookies.
|
|
43
|
+
|
|
44
|
+
3. Provide Tokens to the Client:
|
|
45
|
+
|
|
46
|
+
- You can provide the access_token and refresh_token when initializing the client. These tokens will be saved to tokens.json for future use.
|
|
47
|
+
|
|
48
|
+
### Example Initialization with Tokens
|
|
49
|
+
```python
|
|
50
|
+
import asyncio
|
|
51
|
+
from petsseries import PetsSeriesClient
|
|
52
|
+
|
|
53
|
+
async def main():
|
|
54
|
+
client = PetsSeriesClient(
|
|
55
|
+
access_token="your_access_token_here",
|
|
56
|
+
refresh_token="your_refresh_token_here"
|
|
57
|
+
)
|
|
58
|
+
await client.initialize()
|
|
59
|
+
# Your code here
|
|
60
|
+
|
|
61
|
+
asyncio.run(main())
|
|
62
|
+
```
|
|
63
|
+
After the first run, the tokens will be saved automatically, and you won't need to provide them again unless they are invalidated.
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
### Initialization
|
|
67
|
+
Initialize the PetsSeriesClient with optional access_token and refresh_token. If tokens are not provided, ensure that tokens.json exists with valid tokens.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import asyncio
|
|
71
|
+
from petsseries import PetsSeriesClient
|
|
72
|
+
|
|
73
|
+
async def initialize_client():
|
|
74
|
+
async with PetsSeriesClient() as client:
|
|
75
|
+
await client.initialize()
|
|
76
|
+
# Use the client for API calls
|
|
77
|
+
|
|
78
|
+
asyncio.run(initialize_client())
|
|
79
|
+
```
|
|
80
|
+
### Fetching Data
|
|
81
|
+
The client provides various methods to fetch data from the PetsSeries API.
|
|
82
|
+
|
|
83
|
+
#### Get User Info
|
|
84
|
+
```python
|
|
85
|
+
user = await client.get_user_info()
|
|
86
|
+
print(user.name, user.email)
|
|
87
|
+
```
|
|
88
|
+
#### Get Homes
|
|
89
|
+
```python
|
|
90
|
+
homes = await client.get_homes()
|
|
91
|
+
for home in homes:
|
|
92
|
+
print(home.name)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Get Devices
|
|
96
|
+
```python
|
|
97
|
+
for home in homes:
|
|
98
|
+
devices = await client.get_devices(home)
|
|
99
|
+
for device in devices:
|
|
100
|
+
print(device.name, device.id)
|
|
101
|
+
```
|
|
102
|
+
### Get Events
|
|
103
|
+
```python
|
|
104
|
+
from datetime import datetime
|
|
105
|
+
from pytz import timezone
|
|
106
|
+
|
|
107
|
+
from_date = datetime(2024, 9, 27, tzinfo=timezone("Europe/Amsterdam"))
|
|
108
|
+
to_date = datetime(2024, 9, 28, tzinfo=timezone("Europe/Amsterdam"))
|
|
109
|
+
|
|
110
|
+
events = await client.get_events(home, from_date, to_date)
|
|
111
|
+
for event in events:
|
|
112
|
+
print(event)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Managing Devices
|
|
116
|
+
You can manage device settings such as powering devices on/off and toggling motion notifications.
|
|
117
|
+
|
|
118
|
+
#### Device Power
|
|
119
|
+
```python
|
|
120
|
+
result = await client.power_on_device(home, device_id)
|
|
121
|
+
if result:
|
|
122
|
+
print("Device powered on successfully.")
|
|
123
|
+
|
|
124
|
+
result = await client.power_off_device(home, device_id)
|
|
125
|
+
if result:
|
|
126
|
+
print("Device powered off successfully.")
|
|
127
|
+
|
|
128
|
+
result = await client.toggle_device_power(home, device_id)
|
|
129
|
+
if result:
|
|
130
|
+
print("Device power toggled successfully.")
|
|
131
|
+
```
|
|
132
|
+
#### Motion Notifications
|
|
133
|
+
```python
|
|
134
|
+
result = await client.enable_motion_notifications(home, device_id)
|
|
135
|
+
if result:
|
|
136
|
+
print("Motion notifications enabled successfully.")
|
|
137
|
+
|
|
138
|
+
result = await client.disable_motion_notifications(home, device_id)
|
|
139
|
+
if result:
|
|
140
|
+
print("Motion notifications disabled successfully.")
|
|
141
|
+
|
|
142
|
+
result = await client.toggle_motion_notifications(home, device_id)
|
|
143
|
+
if result:
|
|
144
|
+
print("Motion notifications toggled successfully.")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Example
|
|
148
|
+
Here's a complete example demonstrating how to initialize the client, fetch user info, homes, devices, and manage device settings.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
import asyncio
|
|
152
|
+
from petsseries import PetsSeriesClient
|
|
153
|
+
|
|
154
|
+
async def main():
|
|
155
|
+
async with PetsSeriesClient(
|
|
156
|
+
access_token="your_access_token_here",
|
|
157
|
+
refresh_token="your_refresh_token_here"
|
|
158
|
+
) as client:
|
|
159
|
+
await client.initialize()
|
|
160
|
+
|
|
161
|
+
# Fetch user info
|
|
162
|
+
user = await client.get_user_info()
|
|
163
|
+
print(f"User: {user.name} ({user.email})")
|
|
164
|
+
|
|
165
|
+
# Fetch homes
|
|
166
|
+
homes = await client.get_homes()
|
|
167
|
+
for home in homes:
|
|
168
|
+
print(f"Home: {home.name}")
|
|
169
|
+
|
|
170
|
+
# Fetch devices in home
|
|
171
|
+
devices = await client.get_devices(home)
|
|
172
|
+
for device in devices:
|
|
173
|
+
print(f"Device: {device.name} (ID: {device.id})")
|
|
174
|
+
|
|
175
|
+
# Power off device
|
|
176
|
+
success = await client.power_off_device(home, device.id)
|
|
177
|
+
if success:
|
|
178
|
+
print(f"{device.name} powered off.")
|
|
179
|
+
|
|
180
|
+
# Toggle motion notifications
|
|
181
|
+
success = await client.toggle_motion_notifications(home, device.id)
|
|
182
|
+
if success:
|
|
183
|
+
print(f"Motion notifications toggled for {device.name}.")
|
|
184
|
+
|
|
185
|
+
from_date = dt.datetime(2021, 9, 27, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
186
|
+
to_date = dt.datetime(2100, 9, 28, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
187
|
+
print(from_date, to_date)
|
|
188
|
+
|
|
189
|
+
events = await client.get_events(home, from_date, to_date)
|
|
190
|
+
# Possible eventTypes are: ["motion_detected", "meal_dispensed", "meal_upcoming", "food_level_low"]
|
|
191
|
+
for event in events:
|
|
192
|
+
if event.type == "meal_dispensed":
|
|
193
|
+
logger.info(f"Event: {event}")
|
|
194
|
+
|
|
195
|
+
if __name__ == "__main__":
|
|
196
|
+
asyncio.run(main())
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Contributing
|
|
200
|
+
Contributions are more than welcome!
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
__Disclaimer:__ This project is not affiliated with PetsSeries or Versuni. It is developed independently and is intended for personal use. Use it responsibly and respect the terms of service of the official PetsSeries API.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: petsseries
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Unofficial Python client for interacting with the Philips Pets Series API
|
|
5
|
+
Home-page: https://github.com/abovecolin/petsseries
|
|
6
|
+
Author: AboveColin
|
|
7
|
+
Author-email: colin@cdevries.dev
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: aiohttp
|
|
13
|
+
Requires-Dist: aiofiles
|
|
14
|
+
Requires-Dist: certifi
|
|
15
|
+
Requires-Dist: PyJWT
|
|
16
|
+
|
|
17
|
+
# Unofficial PetsSeries API Client
|
|
18
|
+
|
|
19
|
+
_Disclaimer: This is an unofficial Python client for the PetsSeries API. It is not affiliated with, endorsed by, or in any way connected to the official PetsSeries, Versuni or Philips companies._
|
|
20
|
+
|
|
21
|
+
## Introduction
|
|
22
|
+
The Unofficial PetsSeries API Client is a Python library designed to interact with the PetsSeries backend services. It provides asynchronous methods to manage user information, homes, devices, meals, events, and device settings. This client handles authentication, token refreshing, and provides a convenient interface for integrating PetsSeries functionalities into your Python applications.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
- **Authentication Management:** Handles access and refresh tokens, including automatic refreshing when expired.
|
|
26
|
+
- **Comprehensive API Coverage:** Methods to interact with user info, homes, devices, meals, events, and device settings.
|
|
27
|
+
- **Event Parsing:** Automatically parses different event types into structured Python objects.
|
|
28
|
+
- **Easy Integration:** Simple initialization and usage patterns for quick integration into projects.
|
|
29
|
+
|
|
30
|
+
## Features to be Added
|
|
31
|
+
- **Schedule Management:** Methods to manage schedules
|
|
32
|
+
- **Camera Feed Access:** Methods to access camera feeds
|
|
33
|
+
- **Food Dispenser Control:** Methods to control food dispensers
|
|
34
|
+
|
|
35
|
+
(feel free to PR if you manage to implement any of these features)
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
Ensure you have Python 3.10 or higher installed. You can install the package using pip:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install -r requirements.txt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Authentication
|
|
45
|
+
This client uses OAuth2 tokens (access_token and refresh_token) to authenticate with the PetsSeries API. Follow the steps below to obtain and set up your tokens.
|
|
46
|
+
|
|
47
|
+
### Obtaining Tokens
|
|
48
|
+
1. Login via Web Interface:
|
|
49
|
+
|
|
50
|
+
- Navigate to [PetsSeries Appliance Login](https://www.home.id/find-appliance).
|
|
51
|
+
- Select a PetsSeries product (Starts with PAW) and log in with your credentials.
|
|
52
|
+
|
|
53
|
+
2. Retrieve Tokens:
|
|
54
|
+
|
|
55
|
+
- After logging in, you will be redirected to a "Thanks for your purchase" screen.
|
|
56
|
+
- Open your browser's developer tools (usually by pressing F12 or Ctrl+Shift+I).
|
|
57
|
+
- Go to the Application tab and inspect the cookies.
|
|
58
|
+
- Locate and copy the cc-access-token and cc-refresh-token from the cookies.
|
|
59
|
+
|
|
60
|
+
3. Provide Tokens to the Client:
|
|
61
|
+
|
|
62
|
+
- You can provide the access_token and refresh_token when initializing the client. These tokens will be saved to tokens.json for future use.
|
|
63
|
+
|
|
64
|
+
### Example Initialization with Tokens
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
from petsseries import PetsSeriesClient
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
client = PetsSeriesClient(
|
|
71
|
+
access_token="your_access_token_here",
|
|
72
|
+
refresh_token="your_refresh_token_here"
|
|
73
|
+
)
|
|
74
|
+
await client.initialize()
|
|
75
|
+
# Your code here
|
|
76
|
+
|
|
77
|
+
asyncio.run(main())
|
|
78
|
+
```
|
|
79
|
+
After the first run, the tokens will be saved automatically, and you won't need to provide them again unless they are invalidated.
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
### Initialization
|
|
83
|
+
Initialize the PetsSeriesClient with optional access_token and refresh_token. If tokens are not provided, ensure that tokens.json exists with valid tokens.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import asyncio
|
|
87
|
+
from petsseries import PetsSeriesClient
|
|
88
|
+
|
|
89
|
+
async def initialize_client():
|
|
90
|
+
async with PetsSeriesClient() as client:
|
|
91
|
+
await client.initialize()
|
|
92
|
+
# Use the client for API calls
|
|
93
|
+
|
|
94
|
+
asyncio.run(initialize_client())
|
|
95
|
+
```
|
|
96
|
+
### Fetching Data
|
|
97
|
+
The client provides various methods to fetch data from the PetsSeries API.
|
|
98
|
+
|
|
99
|
+
#### Get User Info
|
|
100
|
+
```python
|
|
101
|
+
user = await client.get_user_info()
|
|
102
|
+
print(user.name, user.email)
|
|
103
|
+
```
|
|
104
|
+
#### Get Homes
|
|
105
|
+
```python
|
|
106
|
+
homes = await client.get_homes()
|
|
107
|
+
for home in homes:
|
|
108
|
+
print(home.name)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Get Devices
|
|
112
|
+
```python
|
|
113
|
+
for home in homes:
|
|
114
|
+
devices = await client.get_devices(home)
|
|
115
|
+
for device in devices:
|
|
116
|
+
print(device.name, device.id)
|
|
117
|
+
```
|
|
118
|
+
### Get Events
|
|
119
|
+
```python
|
|
120
|
+
from datetime import datetime
|
|
121
|
+
from pytz import timezone
|
|
122
|
+
|
|
123
|
+
from_date = datetime(2024, 9, 27, tzinfo=timezone("Europe/Amsterdam"))
|
|
124
|
+
to_date = datetime(2024, 9, 28, tzinfo=timezone("Europe/Amsterdam"))
|
|
125
|
+
|
|
126
|
+
events = await client.get_events(home, from_date, to_date)
|
|
127
|
+
for event in events:
|
|
128
|
+
print(event)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Managing Devices
|
|
132
|
+
You can manage device settings such as powering devices on/off and toggling motion notifications.
|
|
133
|
+
|
|
134
|
+
#### Device Power
|
|
135
|
+
```python
|
|
136
|
+
result = await client.power_on_device(home, device_id)
|
|
137
|
+
if result:
|
|
138
|
+
print("Device powered on successfully.")
|
|
139
|
+
|
|
140
|
+
result = await client.power_off_device(home, device_id)
|
|
141
|
+
if result:
|
|
142
|
+
print("Device powered off successfully.")
|
|
143
|
+
|
|
144
|
+
result = await client.toggle_device_power(home, device_id)
|
|
145
|
+
if result:
|
|
146
|
+
print("Device power toggled successfully.")
|
|
147
|
+
```
|
|
148
|
+
#### Motion Notifications
|
|
149
|
+
```python
|
|
150
|
+
result = await client.enable_motion_notifications(home, device_id)
|
|
151
|
+
if result:
|
|
152
|
+
print("Motion notifications enabled successfully.")
|
|
153
|
+
|
|
154
|
+
result = await client.disable_motion_notifications(home, device_id)
|
|
155
|
+
if result:
|
|
156
|
+
print("Motion notifications disabled successfully.")
|
|
157
|
+
|
|
158
|
+
result = await client.toggle_motion_notifications(home, device_id)
|
|
159
|
+
if result:
|
|
160
|
+
print("Motion notifications toggled successfully.")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Example
|
|
164
|
+
Here's a complete example demonstrating how to initialize the client, fetch user info, homes, devices, and manage device settings.
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
import asyncio
|
|
168
|
+
from petsseries import PetsSeriesClient
|
|
169
|
+
|
|
170
|
+
async def main():
|
|
171
|
+
async with PetsSeriesClient(
|
|
172
|
+
access_token="your_access_token_here",
|
|
173
|
+
refresh_token="your_refresh_token_here"
|
|
174
|
+
) as client:
|
|
175
|
+
await client.initialize()
|
|
176
|
+
|
|
177
|
+
# Fetch user info
|
|
178
|
+
user = await client.get_user_info()
|
|
179
|
+
print(f"User: {user.name} ({user.email})")
|
|
180
|
+
|
|
181
|
+
# Fetch homes
|
|
182
|
+
homes = await client.get_homes()
|
|
183
|
+
for home in homes:
|
|
184
|
+
print(f"Home: {home.name}")
|
|
185
|
+
|
|
186
|
+
# Fetch devices in home
|
|
187
|
+
devices = await client.get_devices(home)
|
|
188
|
+
for device in devices:
|
|
189
|
+
print(f"Device: {device.name} (ID: {device.id})")
|
|
190
|
+
|
|
191
|
+
# Power off device
|
|
192
|
+
success = await client.power_off_device(home, device.id)
|
|
193
|
+
if success:
|
|
194
|
+
print(f"{device.name} powered off.")
|
|
195
|
+
|
|
196
|
+
# Toggle motion notifications
|
|
197
|
+
success = await client.toggle_motion_notifications(home, device.id)
|
|
198
|
+
if success:
|
|
199
|
+
print(f"Motion notifications toggled for {device.name}.")
|
|
200
|
+
|
|
201
|
+
from_date = dt.datetime(2021, 9, 27, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
202
|
+
to_date = dt.datetime(2100, 9, 28, tzinfo=dt.timezone(dt.timedelta(hours=2)))
|
|
203
|
+
print(from_date, to_date)
|
|
204
|
+
|
|
205
|
+
events = await client.get_events(home, from_date, to_date)
|
|
206
|
+
# Possible eventTypes are: ["motion_detected", "meal_dispensed", "meal_upcoming", "food_level_low"]
|
|
207
|
+
for event in events:
|
|
208
|
+
if event.type == "meal_dispensed":
|
|
209
|
+
logger.info(f"Event: {event}")
|
|
210
|
+
|
|
211
|
+
if __name__ == "__main__":
|
|
212
|
+
asyncio.run(main())
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Contributing
|
|
216
|
+
Contributions are more than welcome!
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
__Disclaimer:__ This project is not affiliated with PetsSeries or Versuni. It is developed independently and is intended for personal use. Use it responsibly and respect the terms of service of the official PetsSeries API.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Setup file for the petsseries package
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from setuptools import setup, find_packages
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="petsseries",
|
|
9
|
+
version="0.0.1",
|
|
10
|
+
description="A Unofficial Python client for interacting with the Philips Pets Series API",
|
|
11
|
+
author="AboveColin",
|
|
12
|
+
author_email="colin@cdevries.dev",
|
|
13
|
+
packages=find_packages(),
|
|
14
|
+
install_requires=["aiohttp", "aiofiles", "certifi", "PyJWT"],
|
|
15
|
+
python_requires=">=3.11",
|
|
16
|
+
url="https://github.com/abovecolin/petsseries",
|
|
17
|
+
classifiers=[
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
],
|
|
21
|
+
long_description_content_type="text/markdown",
|
|
22
|
+
long_description=open("README.md").read(), # pylint: disable=unspecified-encoding
|
|
23
|
+
)
|