pypetkitapi 1.0.0__py3-none-any.whl → 1.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/client.py +11 -13
- pypetkitapi/const.py +1 -0
- {pypetkitapi-1.0.0.dist-info → pypetkitapi-1.1.0.dist-info}/METADATA +1 -1
- {pypetkitapi-1.0.0.dist-info → pypetkitapi-1.1.0.dist-info}/RECORD +6 -6
- {pypetkitapi-1.0.0.dist-info → pypetkitapi-1.1.0.dist-info}/LICENSE +0 -0
- {pypetkitapi-1.0.0.dist-info → pypetkitapi-1.1.0.dist-info}/WHEEL +0 -0
pypetkitapi/client.py
CHANGED
@@ -19,6 +19,7 @@ from pypetkitapi.const import (
|
|
19
19
|
DEVICES_WATER_FOUNTAIN,
|
20
20
|
ERR_KEY,
|
21
21
|
LOGIN_DATA,
|
22
|
+
PET_DATA,
|
22
23
|
RES_KEY,
|
23
24
|
SUCCESS_KEY,
|
24
25
|
Header,
|
@@ -48,10 +49,11 @@ class PetKitClient:
|
|
48
49
|
_session: SessionInfo | None = None
|
49
50
|
_servers_list: list[RegionInfo] = []
|
50
51
|
account_data: list[AccountData] = []
|
51
|
-
petkit_entities: dict[
|
52
|
-
|
53
|
-
int,
|
54
|
-
|
52
|
+
petkit_entities: dict[
|
53
|
+
str,
|
54
|
+
dict[int, Feeder | Litter | WaterFountain | Pet]
|
55
|
+
| dict[int, FeederRecord | LitterRecord | WaterFountainRecord],
|
56
|
+
]
|
55
57
|
|
56
58
|
def __init__(
|
57
59
|
self,
|
@@ -67,6 +69,7 @@ class PetKitClient:
|
|
67
69
|
self.region = region.lower()
|
68
70
|
self.timezone = timezone
|
69
71
|
self._session = None
|
72
|
+
self.petkit_entities = {DEVICE_RECORDS: {}, DEVICE_DATA: {}, PET_DATA: {}}
|
70
73
|
self.aiohttp_session = session or aiohttp.ClientSession()
|
71
74
|
self.req = PrepReq(
|
72
75
|
base_url=PetkitDomain.PASSPORT_PETKIT, session=self.aiohttp_session
|
@@ -169,7 +172,6 @@ class PetKitClient:
|
|
169
172
|
elif half_max_age < token_age <= max_age:
|
170
173
|
_LOGGER.debug("Token still OK, but refreshing session")
|
171
174
|
await self.refresh_session()
|
172
|
-
return
|
173
175
|
|
174
176
|
async def get_session_id(self) -> dict:
|
175
177
|
"""Return the session ID."""
|
@@ -192,7 +194,7 @@ class PetKitClient:
|
|
192
194
|
for account in self.account_data:
|
193
195
|
if account.pet_list:
|
194
196
|
for pet in account.pet_list:
|
195
|
-
self.petkit_entities[pet.pet_id] = pet
|
197
|
+
self.petkit_entities[PET_DATA][pet.pet_id] = pet
|
196
198
|
|
197
199
|
async def get_devices_data(self) -> None:
|
198
200
|
"""Get the devices data from the PetKit servers."""
|
@@ -300,12 +302,7 @@ class PetKitClient:
|
|
300
302
|
|
301
303
|
_LOGGER.debug("Reading device type : %s (id=%s)", device_type, device_id)
|
302
304
|
|
303
|
-
|
304
|
-
self.petkit_entities[device_id] = device_data
|
305
|
-
elif data_class.data_type == DEVICE_RECORDS:
|
306
|
-
self.petkit_entities_records[device_id] = device_data
|
307
|
-
else:
|
308
|
-
_LOGGER.error("Unknown data type: %s", data_class.data_type)
|
305
|
+
self.petkit_entities[data_class.data_type][device_id] = device_data
|
309
306
|
|
310
307
|
async def send_api_request(
|
311
308
|
self,
|
@@ -314,7 +311,8 @@ class PetKitClient:
|
|
314
311
|
setting: dict | None = None,
|
315
312
|
) -> None:
|
316
313
|
"""Control the device using the PetKit API."""
|
317
|
-
|
314
|
+
device_dict = self.petkit_entities.get(DEVICE_DATA, {})
|
315
|
+
device = device_dict.get(device_id)
|
318
316
|
if not device:
|
319
317
|
raise PypetkitError(f"Device with ID {device_id} not found.")
|
320
318
|
|
pypetkitapi/const.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
pypetkitapi/__init__.py,sha256=eVpyGMD3tkYtiHUkdKEeNSZhQlZ4woI2Y5oVoV7CwXM,61
|
2
|
-
pypetkitapi/client.py,sha256=
|
2
|
+
pypetkitapi/client.py,sha256=lC5kWLDcZcB5WHZeoyg0RagEKzK6F0Vk_H8Be_1MyDM,16493
|
3
3
|
pypetkitapi/command.py,sha256=gw3_J_oZHuuGLk66P8uRSqSrySjYa8ArpKaPHi2ybCw,7155
|
4
|
-
pypetkitapi/const.py,sha256=
|
4
|
+
pypetkitapi/const.py,sha256=Mxgezd9sy-LtpgjYuVKb9ii9HSUnz8FVyKx1GXbXBAU,3291
|
5
5
|
pypetkitapi/containers.py,sha256=m7vzWcJG0U1EPftuBF6OB8eTVRhCoA2DFqekxI6LozI,3428
|
6
6
|
pypetkitapi/exceptions.py,sha256=NWmpsI2ewC4HaIeu_uFwCeuPIHIJxZBzjoCP7aNwvhs,1139
|
7
7
|
pypetkitapi/feeder_container.py,sha256=XpZqeQ8E4_ud3juxDBKGTMfmCfvc9QYcJInacmbWK-o,12785
|
8
8
|
pypetkitapi/litter_container.py,sha256=TK2-_yg3EmT0RQzMLurud2PHwa2P-o2KGyV9m_SQ7qw,11651
|
9
9
|
pypetkitapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
pypetkitapi/water_fountain_container.py,sha256=xmqYuxyppRLhqi7cF4JNRprhgmz3KKrbi4iv942wNaU,6566
|
11
|
-
pypetkitapi-1.
|
12
|
-
pypetkitapi-1.
|
13
|
-
pypetkitapi-1.
|
14
|
-
pypetkitapi-1.
|
11
|
+
pypetkitapi-1.1.0.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
|
12
|
+
pypetkitapi-1.1.0.dist-info/METADATA,sha256=9OvaTvc__catDl-YG3HWqk9ycquCVymNfAS6TrEQtBk,4590
|
13
|
+
pypetkitapi-1.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
14
|
+
pypetkitapi-1.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|