Skip to content

Commit 3b53442

Browse files
committed
Type as DeviceData, not as DeviceDataPoints
1 parent 572d503 commit 3b53442

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

plugwise/helper.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import asyncio
88
import datetime as dt
9-
from typing import cast
109

1110
# This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts)
1211
from aiohttp import BasicAuth, ClientError, ClientResponse, ClientSession, ClientTimeout
@@ -73,6 +72,8 @@
7372
version_to_model,
7473
)
7574

75+
# from typing import cast
76+
7677

7778
def update_helper(
7879
data: DeviceDataPoints,
@@ -103,7 +104,7 @@ def check_model(name: str | None, vendor_name: str | None) -> str | None:
103104
return name
104105

105106

106-
def _get_actuator_functionalities(xml: etree, data: DeviceDataPoints) -> None:
107+
def _get_actuator_functionalities(xml: etree, data: DeviceData) -> None:
107108
"""Helper-function for _get_appliance_data()."""
108109
for item in ACTIVE_ACTUATORS:
109110
temp_dict: ActuatorData = {}
@@ -874,7 +875,7 @@ def _rule_ids_by_tag(self, tag: str, loc_id: str) -> dict[str, str]:
874875
def _appliance_measurements(
875876
self,
876877
appliance: etree,
877-
data: DeviceDataPoints,
878+
data: DeviceData,
878879
measurements: dict[str, DATA | UOM],
879880
) -> None:
880881
"""Helper-function for _get_appliance_data() - collect appliance measurement data."""
@@ -916,7 +917,7 @@ def _appliance_measurements(
916917
name = f"{measurement}_interval"
917918
data[name] = format_measure(appl_i_loc.text, ENERGY_WATT_HOUR)
918919

919-
def _wireless_availablity(self, appliance: etree, data: DeviceDataPoints) -> None:
920+
def _wireless_availablity(self, appliance: etree, data: DeviceData) -> None:
920921
"""
921922
Helper-function for _get_appliance_data().
922923
@@ -936,7 +937,7 @@ def _wireless_availablity(self, appliance: etree, data: DeviceDataPoints) -> Non
936937
if module_data["reachable"] is not None:
937938
data["available"] = module_data["reachable"]
938939

939-
def _get_regulation_mode(self, appliance: etree, data: DeviceDataPoints) -> None:
940+
def _get_regulation_mode(self, appliance: etree, data: DeviceData) -> None:
940941
"""
941942
Helper-function for _get_appliance_data().
942943
@@ -947,7 +948,7 @@ def _get_regulation_mode(self, appliance: etree, data: DeviceDataPoints) -> None
947948
data["regulation_mode"] = search.find("mode").text
948949
self._cooling_enabled = search.find("mode").text == "cooling"
949950

950-
def _cleanup_data(self, data: DeviceDataPoints) -> None:
951+
def _cleanup_data(self, data: DeviceData) -> None:
951952
"""
952953
Helper-function for _get_appliance_data().
953954
@@ -966,7 +967,7 @@ def _cleanup_data(self, data: DeviceDataPoints) -> None:
966967
if not self._elga and "cooling_enabled" in data:
967968
data.pop("cooling_enabled") # pragma: no cover
968969

969-
def _process_c_heating_state(self, data: DeviceDataPoints) -> None:
970+
def _process_c_heating_state(self, data: DeviceData) -> None:
970971
"""
971972
Helper-function for _get_appliance_data().
972973
@@ -976,15 +977,15 @@ def _process_c_heating_state(self, data: DeviceDataPoints) -> None:
976977
# Anna + OnOff heater: use central_heating_state to show heating_state
977978
# Solution for Core issue #81839
978979
if self.smile_name == "Smile Anna":
979-
data["heating_state"] = data["c_heating_state"]
980+
data["heating_state"] = data["c_heating_state"] is True
980981

981982
if self.smile_name == "Adam":
982983
data["heating_state"] = False
983984
# Adam + OnOff cooling: use central_heating_state to show heating/cooling_state
984985
if self._cooling_enabled:
985-
data["cooling_state"] = data["c_heating_state"]
986+
data["cooling_state"] = data["c_heating_state"] is True
986987
else:
987-
data["heating_state"] = data["c_heating_state"]
988+
data["heating_state"] = data["c_heating_state"] is True
988989

989990
def _get_appliance_data(self, d_id: str) -> DeviceData:
990991
"""
@@ -993,10 +994,10 @@ def _get_appliance_data(self, d_id: str) -> DeviceData:
993994
Collect the appliance-data based on device id.
994995
Determined from APPLIANCES, for legacy from DOMAIN_OBJECTS.
995996
"""
996-
data: DeviceDataPoints = {}
997+
data: DeviceData = {}
997998
# P1 legacy has no APPLIANCES, also not present in DOMAIN_OBJECTS
998999
if self._smile_legacy and self.smile_type == "power":
999-
return cast(DeviceData, data)
1000+
return data
10001001

10011002
measurements = DEVICE_MEASUREMENTS
10021003
if d_id == self._heater_id:
@@ -1440,7 +1441,7 @@ def _object_value(self, obj_id: str, measurement: str) -> float | int | None:
14401441

14411442
return val
14421443

1443-
def _get_lock_state(self, xml: etree, data: DeviceDataPoints) -> None:
1444+
def _get_lock_state(self, xml: etree, data: DeviceData) -> None:
14441445
"""
14451446
Helper-function for _get_appliance_data().
14461447
@@ -1457,7 +1458,7 @@ def _get_lock_state(self, xml: etree, data: DeviceDataPoints) -> None:
14571458
data["lock"] = found.text == "true"
14581459

14591460
def _get_toggle_state(
1460-
self, xml: etree, toggle: str, name: str, data: DeviceDataPoints
1461+
self, xml: etree, toggle: str, name: str, data: DeviceData
14611462
) -> None:
14621463
"""
14631464
Helper-function for _get_appliance_data().

0 commit comments

Comments
 (0)