pynintendoparental 1.1.1__py3-none-any.whl → 1.1.2__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.
- pynintendoparental/_version.py +1 -1
- pynintendoparental/device.py +26 -8
- pynintendoparental/exceptions.py +16 -5
- {pynintendoparental-1.1.1.dist-info → pynintendoparental-1.1.2.dist-info}/METADATA +1 -1
- {pynintendoparental-1.1.1.dist-info → pynintendoparental-1.1.2.dist-info}/RECORD +8 -8
- {pynintendoparental-1.1.1.dist-info → pynintendoparental-1.1.2.dist-info}/WHEEL +0 -0
- {pynintendoparental-1.1.1.dist-info → pynintendoparental-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {pynintendoparental-1.1.1.dist-info → pynintendoparental-1.1.2.dist-info}/top_level.txt +0 -0
pynintendoparental/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.1.
|
|
1
|
+
__version__ = "1.1.2"
|
pynintendoparental/device.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing import Callable
|
|
|
8
8
|
|
|
9
9
|
from .api import Api
|
|
10
10
|
from .const import _LOGGER, DAYS_OF_WEEK
|
|
11
|
-
from .exceptions import HttpException, BedtimeOutOfRangeError
|
|
11
|
+
from .exceptions import HttpException, BedtimeOutOfRangeError, DailyPlaytimeOutOfRangeError
|
|
12
12
|
from .enum import AlarmSettingState, RestrictionMode
|
|
13
13
|
from .player import Player
|
|
14
14
|
from .utils import is_awaitable
|
|
@@ -49,6 +49,20 @@ class Device:
|
|
|
49
49
|
self._callbacks: list[Callable] = []
|
|
50
50
|
_LOGGER.debug("Device init complete for %s", self.device_id)
|
|
51
51
|
|
|
52
|
+
@property
|
|
53
|
+
def model(self) -> str:
|
|
54
|
+
"""Return the model."""
|
|
55
|
+
model_map = {
|
|
56
|
+
"P00": "Switch",
|
|
57
|
+
"P01": "Switch 2"
|
|
58
|
+
}
|
|
59
|
+
return model_map.get(self.generation, "Unknown")
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def generation(self) -> str | None:
|
|
63
|
+
"""Return the generation."""
|
|
64
|
+
return self.extra.get("platformGeneration", None)
|
|
65
|
+
|
|
52
66
|
async def update(self):
|
|
53
67
|
"""Update data."""
|
|
54
68
|
_LOGGER.debug(">> Device.update()")
|
|
@@ -158,12 +172,14 @@ class Device:
|
|
|
158
172
|
self._calculate_times()
|
|
159
173
|
await self._execute_callbacks()
|
|
160
174
|
|
|
161
|
-
async def update_max_daily_playtime(self, minutes: int = 0):
|
|
175
|
+
async def update_max_daily_playtime(self, minutes: int | float = 0):
|
|
162
176
|
"""Updates the maximum daily playtime of a device."""
|
|
163
177
|
_LOGGER.debug(">> Device.update_max_daily_playtime(minutes=%s)",
|
|
164
178
|
minutes)
|
|
165
|
-
if minutes
|
|
166
|
-
|
|
179
|
+
if isinstance(minutes, float):
|
|
180
|
+
minutes = int(minutes)
|
|
181
|
+
if minutes > 360 or minutes < -1:
|
|
182
|
+
raise DailyPlaytimeOutOfRangeError(minutes)
|
|
167
183
|
ttpiod = True
|
|
168
184
|
if minutes == -1:
|
|
169
185
|
ttpiod = False
|
|
@@ -219,10 +235,12 @@ class Device:
|
|
|
219
235
|
current_day = day_of_week_regs.get(DAYS_OF_WEEK[datetime.now().weekday()], {})
|
|
220
236
|
self.timer_mode = self.parental_control_settings["playTimerRegulations"]["timerMode"]
|
|
221
237
|
if self.timer_mode == "EACH_DAY_OF_THE_WEEK":
|
|
222
|
-
|
|
238
|
+
regulations = current_day
|
|
223
239
|
else:
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
regulations = self.parental_control_settings.get("playTimerRegulations", {}).get("dailyRegulations", {})
|
|
241
|
+
|
|
242
|
+
limit_time = regulations.get("timeToPlayInOneDay", {}).get("limitTime")
|
|
243
|
+
self.limit_time = limit_time if limit_time is not None else -1
|
|
226
244
|
|
|
227
245
|
if self.timer_mode == "EACH_DAY_OF_THE_WEEK":
|
|
228
246
|
if current_day["bedtime"]["enabled"]:
|
|
@@ -277,7 +295,7 @@ class Device:
|
|
|
277
295
|
# 1. Calculate remaining time based on play limit
|
|
278
296
|
|
|
279
297
|
time_remaining_by_play_limit = 0.0
|
|
280
|
-
if self.limit_time
|
|
298
|
+
if self.limit_time in (-1, None):
|
|
281
299
|
# No specific play limit, effectively limited by end of day for this calculation step.
|
|
282
300
|
time_remaining_by_play_limit = float(minutes_in_day - current_minutes_past_midnight)
|
|
283
301
|
elif self.limit_time == 0:
|
pynintendoparental/exceptions.py
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"""Nintendo Parental exceptions."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from enum import StrEnum
|
|
4
|
+
|
|
5
|
+
class RangeErrorKeys(StrEnum):
|
|
6
|
+
"""Keys for range errors."""
|
|
7
|
+
|
|
8
|
+
DAILY_PLAYTIME = "daily_playtime_out_of_range"
|
|
9
|
+
BEDTIME = "bedtime_alarm_out_of_range"
|
|
4
10
|
|
|
5
11
|
class HttpException(Exception):
|
|
6
12
|
"""A HTTP error occured"""
|
|
@@ -27,11 +33,16 @@ class InputValidationError(Exception):
|
|
|
27
33
|
value: object
|
|
28
34
|
error_key: str
|
|
29
35
|
|
|
36
|
+
def __init__(self, value: object) -> None:
|
|
37
|
+
super().__init__(f"{self.__doc__} Received value: {value}")
|
|
38
|
+
self.value = value
|
|
39
|
+
|
|
30
40
|
class BedtimeOutOfRangeError(InputValidationError):
|
|
31
41
|
"""Bedtime is outside of the allowed range."""
|
|
32
42
|
|
|
33
|
-
error_key =
|
|
43
|
+
error_key = RangeErrorKeys.BEDTIME
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
class DailyPlaytimeOutOfRangeError(InputValidationError):
|
|
46
|
+
"""Daily playtime is outside of the allowed range."""
|
|
47
|
+
|
|
48
|
+
error_key = RangeErrorKeys.DAILY_PLAYTIME
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
pynintendoparental/__init__.py,sha256=pNcBsHRa4B85USP7uzwPEGF9fu3MA9YgW_hI82F_NXQ,2460
|
|
2
|
-
pynintendoparental/_version.py,sha256=
|
|
2
|
+
pynintendoparental/_version.py,sha256=5SgGjThsHu_ITn8V83BvCziqCwxdXxTQqcC3KQMHPfM,22
|
|
3
3
|
pynintendoparental/api.py,sha256=hMXq0eNIgFELlNZJtN0rK3plKyu9nirvwiUPNlkjOCY,7013
|
|
4
4
|
pynintendoparental/application.py,sha256=l-oVwM4hrVVUf_2djQ7rJVya7LQP38yhaLPAWt8V8TY,3941
|
|
5
5
|
pynintendoparental/const.py,sha256=sQZqU0f1NSClMPfCSJonlCunLdbPPiXjL-JS2LMZGd4,2101
|
|
6
|
-
pynintendoparental/device.py,sha256=
|
|
6
|
+
pynintendoparental/device.py,sha256=EEQfnab96CIGlB2n1gePQBn5SWx7cck8tX_qz8xAHjc,22956
|
|
7
7
|
pynintendoparental/enum.py,sha256=lzacGti7fcQqAOROjB9782De7bOMYKSEM61SQd6aYG4,401
|
|
8
|
-
pynintendoparental/exceptions.py,sha256
|
|
8
|
+
pynintendoparental/exceptions.py,sha256=-KuRBoMtzWKycjdgIsRYPzSVi_uzPjROq7blJSgq-iw,1450
|
|
9
9
|
pynintendoparental/player.py,sha256=WDl0pspHgrV9lGhDp-NKlfP8DV4Yxe02aYaGg9wTTeg,1785
|
|
10
10
|
pynintendoparental/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
pynintendoparental/utils.py,sha256=5-EP_rmPnSSWtbi18Y226GtjLhF3PLONKwmRdiy7m2c,198
|
|
12
12
|
pynintendoparental/authenticator/__init__.py,sha256=MZdA6qqHV0i7rspNL9Z9xl7aRy-EJEm3NIapiIgEJBA,7688
|
|
13
13
|
pynintendoparental/authenticator/const.py,sha256=_nUJVC0U64j_n1LaQd_KDg0EWFcezb87bQyYYXpbPPY,917
|
|
14
|
-
pynintendoparental-1.1.
|
|
15
|
-
pynintendoparental-1.1.
|
|
16
|
-
pynintendoparental-1.1.
|
|
17
|
-
pynintendoparental-1.1.
|
|
18
|
-
pynintendoparental-1.1.
|
|
14
|
+
pynintendoparental-1.1.2.dist-info/licenses/LICENSE,sha256=zsxHgHVMnyWq121yND8zBl9Rl9H6EF2K9N51B2ZSm_k,1071
|
|
15
|
+
pynintendoparental-1.1.2.dist-info/METADATA,sha256=wV4_2Gwy86YLWZe8SOu5svDLpH2VWsi5ORPCVfYzLKk,1871
|
|
16
|
+
pynintendoparental-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
pynintendoparental-1.1.2.dist-info/top_level.txt,sha256=QQ5bAl-Ljso16P8KLf1NHrFmKk9jLT7bVJG_rVlIXWk,19
|
|
18
|
+
pynintendoparental-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|