Skip to content

Commit 7695a9b

Browse files
committed
Define constant NONE and implement
1 parent 93ec446 commit 7695a9b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

plugwise/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@
375375
DEFAULT_TIMEOUT: Final = 30
376376
DEFAULT_USERNAME: Final = "smile"
377377
DEFAULT_PORT: Final = 80
378+
NONE: Final = "None"
378379
FAKE_LOC: Final = "0000aaaa0000aaaa0000aaaa0000aa00"
379380
SEVERITIES: Final[list[str]] = ["other", "info", "warning", "error"]
380381
SWITCH_GROUP_TYPES: Final[list[str]] = ["switching", "report"]

plugwise/helper.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
HOME_MEASUREMENTS,
3838
LOCATIONS,
3939
LOGGER,
40+
NONE,
4041
POWER_WATT,
4142
SENSORS,
4243
SPECIAL_PLUG_TYPES,
@@ -95,7 +96,7 @@ def schedules_schedule_temp(schedules: dict[str, Any], name: str) -> Any:
9596
"""Helper-function for schedules().
9697
Obtain the schedule temperature of the schedule/schedule.
9798
"""
98-
if name == "None":
99+
if name == NONE:
99100
return None # pragma: no cover
100101

101102
schedule_list: list[list[Any]] = []
@@ -1160,11 +1161,11 @@ def _schedules(
11601161
Obtain the available schedules/schedules. Adam: a schedule can be connected to more than one location.
11611162
NEW: when a location_id is present then the schedule is active. Valid for both Adam and non-legacy Anna.
11621163
"""
1163-
available: list[str] = ["None"]
1164+
available: list[str] = [NONE]
11641165
last_used: str | None = None
11651166
rule_ids: dict[str, str] = {}
11661167
schedule_temperature: str | None = None
1167-
selected = "None"
1168+
selected = NONE
11681169
tmp_last_used: str | None = None
11691170

11701171
# Legacy Anna schedule, only one schedule allowed
@@ -1213,7 +1214,7 @@ def _schedules(
12131214
schedules[name] = schedule
12141215

12151216
if schedules:
1216-
available.remove("None")
1217+
available.remove(NONE)
12171218
tmp_last_used = self._last_used_schedule(location, rule_ids)
12181219
if tmp_last_used in schedules:
12191220
last_used = tmp_last_used
@@ -1260,7 +1261,7 @@ def _object_value(self, obj_id: str, measurement: str) -> float | int | None:
12601261
search = self._domain_objects
12611262
locator = f'./location[@id="{obj_id}"]/logs/point_log[type="{measurement}"]/period/measurement'
12621263
if (found := search.find(locator)) is not None:
1263-
val = format_measure(found.text, None)
1264+
val = format_measure(found.text, NONE)
12641265
return val
12651266

12661267
return val
@@ -1279,7 +1280,7 @@ def _get_lock_state(self, xml: etree) -> dict[str, Any]:
12791280
if appl_class not in SPECIAL_PLUG_TYPES:
12801281
locator = f"./{actuator}/{func_type}/lock"
12811282
if (found := xml.find(locator)) is not None:
1282-
data["lock"] = format_measure(found.text, None)
1283+
data["lock"] = format_measure(found.text, NONE)
12831284

12841285
return data
12851286

0 commit comments

Comments
 (0)