Skip to content

Commit 3879759

Browse files
committed
Move remove_empty_platform_dicts() to util.py
1 parent 4d3726b commit 3879759

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

plugwise/data.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@
1717
DeviceData,
1818
)
1919
from plugwise.helper import SmileHelper
20-
21-
22-
def remove_empty_platform_dicts(data: DeviceData) -> None:
23-
"""Helper-function for removing any empty platform dicts."""
24-
if not data["binary_sensors"]:
25-
data.pop("binary_sensors")
26-
if not data["sensors"]:
27-
data.pop("sensors")
28-
if not data["switches"]:
29-
data.pop("switches")
20+
from plugwise.util import remove_empty_platform_dicts
3021

3122

3223
class SmileData(SmileHelper):

plugwise/legacy/data.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@
88
# Version detection
99
from plugwise.constants import NONE, SWITCH_GROUP_TYPES, ZONE_THERMOSTATS, DeviceData
1010
from plugwise.legacy.helper import SmileLegacyHelper
11-
12-
13-
def remove_empty_platform_dicts(data: DeviceData) -> None:
14-
"""Helper-function for removing any empty platform dicts."""
15-
if not data["binary_sensors"]:
16-
data.pop("binary_sensors")
17-
if not data["sensors"]:
18-
data.pop("sensors")
19-
if not data["switches"]:
20-
data.pop("switches")
11+
from plugwise.util import remove_empty_platform_dicts
2112

2213

2314
class SmileLegacyData(SmileLegacyHelper):

plugwise/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
PERCENTAGE,
1111
SPECIAL_FORMAT,
1212
TEMP_CELSIUS,
13+
DeviceData,
1314
)
1415

1516

@@ -62,3 +63,13 @@ def version_to_model(version: str | None) -> str | None:
6263
model = HW_MODELS.get(version[-2:] + version[-4:-2] + version[-6:-4])
6364

6465
return model if model is not None else "Unknown"
66+
67+
68+
def remove_empty_platform_dicts(data: DeviceData) -> None:
69+
"""Helper-function for removing any empty platform dicts."""
70+
if not data["binary_sensors"]:
71+
data.pop("binary_sensors")
72+
if not data["sensors"]:
73+
data.pop("sensors")
74+
if not data["switches"]:
75+
data.pop("switches")

0 commit comments

Comments
 (0)