Skip to content

Commit 75eb4a0

Browse files
committed
Move check_model(), fix imports
1 parent bef6e9d commit 75eb4a0

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

plugwise/helper.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
DEVICE_MEASUREMENTS,
2121
DHW_SETPOINT,
2222
DOMAIN_OBJECTS,
23-
ENERGY_KILO_WATT_HOUR,
2423
ENERGY_WATT_HOUR,
2524
HEATER_CENTRAL_MEASUREMENTS,
2625
LIMITS,
@@ -30,7 +29,6 @@
3029
OBSOLETE_MEASUREMENTS,
3130
OFF,
3231
P1_MEASUREMENTS,
33-
POWER_WATT,
3432
SENSORS,
3533
SPECIAL_PLUG_TYPES,
3634
SPECIALS,
@@ -61,10 +59,10 @@
6159
ResponseError,
6260
)
6361
from plugwise.util import (
62+
check_model,
6463
escape_illegal_xml_characters,
6564
format_measure,
6665
power_data_local_format,
67-
version_to_model,
6866
)
6967

7068
# This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts)
@@ -77,14 +75,6 @@
7775
from munch import Munch
7876

7977

80-
def check_model(name: str | None, vendor_name: str | None) -> str | None:
81-
"""Model checking before using version_to_model."""
82-
if vendor_name == "Plugwise" and ((model := version_to_model(name)) != "Unknown"):
83-
return model
84-
85-
return name
86-
87-
8878
class SmileComm:
8979
"""The SmileComm class."""
9080

plugwise/legacy/helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
BINARY_SENSORS,
1818
DATA,
1919
DEVICE_MEASUREMENTS,
20-
ENERGY_KILO_WATT_HOUR,
2120
ENERGY_WATT_HOUR,
2221
FAKE_APPL,
2322
FAKE_LOC,
@@ -26,7 +25,6 @@
2625
NONE,
2726
OBSOLETE_MEASUREMENTS,
2827
P1_LEGACY_MEASUREMENTS,
29-
POWER_WATT,
3028
SENSORS,
3129
SPECIAL_PLUG_TYPES,
3230
SPECIALS,

plugwise/util.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@
44
import re
55

66
from plugwise.constants import (
7+
ATTR_UNIT_OF_MEASUREMENT,
78
ELECTRIC_POTENTIAL_VOLT,
89
ENERGY_KILO_WATT_HOUR,
910
HW_MODELS,
1011
PERCENTAGE,
12+
POWER_WATT,
1113
SPECIAL_FORMAT,
1214
TEMP_CELSIUS,
1315
DeviceData,
1416
)
1517

1618

19+
def check_model(name: str | None, vendor_name: str | None) -> str | None:
20+
"""Model checking before using version_to_model."""
21+
if vendor_name == "Plugwise" and ((model := version_to_model(name)) != "Unknown"):
22+
return model
23+
24+
return name
25+
26+
1727
def escape_illegal_xml_characters(xmldata: str) -> str:
1828
"""Replace illegal &-characters."""
1929
return re.sub(r"&([^a-zA-Z#])", r"&\1", xmldata)

0 commit comments

Comments
 (0)