petsseries 0.0.1__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.
@@ -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,4 @@
1
+ petsseries-0.0.1.dist-info/METADATA,sha256=eWX5nux3cBCSLWYl56byLABnpD0hatvwBKiSBvUYY00,7806
2
+ petsseries-0.0.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
3
+ petsseries-0.0.1.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ petsseries-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+