Skip to content

Commit beb2eda

Browse files
committed
Re-enable show_setup()
1 parent 7331b42 commit beb2eda

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

plugwise/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
STATUS,
1616
SYSTEM,
1717
PlugwiseData,
18+
ThermoLoc,
1819
)
1920
from plugwise.exceptions import (
2021
InvalidSetupError,
@@ -76,6 +77,7 @@ def __init__(
7677
self._stretch_v2 = False
7778
self._stretch_v3 = False
7879
self._target_smile: str
80+
self.loc_data: dict[str, ThermoLoc] = {}
7981
self.smile_fw_version: str | None
8082
self.smile_hostname: str
8183
self.smile_hw_version: str | None = None
@@ -133,6 +135,7 @@ async def connect(self) -> bool:
133135
self._opentherm_device,
134136
self._schedule_old_states,
135137
self._target_smile,
138+
self.loc_data,
136139
self.smile_fw_version,
137140
self.smile_hostname,
138141
self.smile_hw_version,
@@ -158,6 +161,7 @@ async def connect(self) -> bool:
158161
self._stretch_v2,
159162
self._stretch_v3,
160163
self._target_smile,
164+
self.loc_data,
161165
self.smile_fw_version,
162166
self.smile_hostname,
163167
self.smile_hw_version,

plugwise/helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ def __init__(self) -> None:
231231
self._is_thermostat = False
232232
self._last_active: dict[str, str | None] = {}
233233
self._last_modified: dict[str, str] = {}
234-
self._loc_data: dict[str, ThermoLoc] = {}
235234
self._notifications: dict[str, dict[str, str]] = {}
236235
self._on_off_device = False
237236
self._opentherm_device = False
@@ -263,6 +262,7 @@ def __init__(self) -> None:
263262
self.gateway_id: str
264263
self.gw_data: GatewayData = {}
265264
self.gw_devices: dict[str, DeviceData] = {}
265+
self.loc_data: dict[str, ThermoLoc]
266266
self.smile_fw_version: str | None = None
267267
self.smile_hw_version: str | None = None
268268
self.smile_mac_address: str | None = None
@@ -286,7 +286,7 @@ def _all_locations(self) -> None:
286286
if loc.name == "Home":
287287
self._home_location = loc.loc_id
288288

289-
self._loc_data[loc.loc_id] = {"name": loc.name}
289+
self.loc_data[loc.loc_id] = {"name": loc.name}
290290

291291
def _get_module_data(
292292
self, appliance: etree, locator: str, mod_type: str
@@ -491,7 +491,7 @@ def _check_heater_central(self) -> str:
491491

492492
def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
493493
"""Collect P1 DSMR Smartmeter info."""
494-
loc_id = next(iter(self._loc_data.keys()))
494+
loc_id = next(iter(self.loc_data.keys()))
495495
appl.dev_id = self.gateway_id
496496
appl.location = loc_id
497497
appl.mac = None
@@ -1039,7 +1039,7 @@ def _match_locations(self) -> dict[str, ThermoLoc]:
10391039
Match appliances with locations.
10401040
"""
10411041
matched_locations: dict[str, ThermoLoc] = {}
1042-
for location_id, location_details in self._loc_data.items():
1042+
for location_id, location_details in self.loc_data.items():
10431043
for appliance_details in self.gw_devices.values():
10441044
if appliance_details["location"] == location_id:
10451045
location_details.update(

plugwise/legacy/helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def __init__(self) -> None:
9393
self._last_active: dict[str, str | None] = {}
9494
self._last_modified: dict[str, str] = {}
9595
self._locations: etree
96-
self._loc_data: dict[str, ThermoLoc] = {}
9796
self._modules: etree
9897
self._notifications: dict[str, dict[str, str]] = {}
9998
self._on_off_device = False
@@ -109,6 +108,7 @@ def __init__(self) -> None:
109108
self.gateway_id: str
110109
self.gw_data: GatewayData = {}
111110
self.gw_devices: dict[str, DeviceData] = {}
111+
self.loc_data: dict[str, ThermoLoc]
112112
self.smile_fw_version: str | None = None
113113
self.smile_hw_version: str | None = None
114114
self.smile_legacy = False
@@ -130,7 +130,7 @@ def _all_locations(self) -> None:
130130
# Legacy Anna without outdoor_temp and Stretches have no locations, create fake location-data
131131
if not (locations := self._locations.findall("./location")):
132132
self._home_location = FAKE_LOC
133-
self._loc_data[FAKE_LOC] = {"name": "Home"}
133+
self.loc_data[FAKE_LOC] = {"name": "Home"}
134134
return
135135

136136
for location in locations:
@@ -151,7 +151,7 @@ def _all_locations(self) -> None:
151151
loc.name = "Home"
152152
self._home_location = loc.loc_id
153153

154-
self._loc_data[loc.loc_id] = {"name": loc.name}
154+
self.loc_data[loc.loc_id] = {"name": loc.name}
155155

156156
def _get_module_data(
157157
self, appliance: etree, locator: str, mod_type: str
@@ -300,7 +300,7 @@ def _check_heater_central(self) -> str:
300300

301301
def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
302302
"""Collect P1 DSMR Smartmeter info."""
303-
loc_id = next(iter(self._loc_data.keys()))
303+
loc_id = next(iter(self.loc_data.keys()))
304304
appl.dev_id = loc_id
305305
appl.location = loc_id
306306
appl.mac = None

plugwise/legacy/smile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
DeviceData,
2222
GatewayData,
2323
PlugwiseData,
24+
ThermoLoc,
2425
)
2526
from plugwise.exceptions import PlugwiseError
2627
from plugwise.helper import SmileComm
@@ -47,6 +48,7 @@ def __init__(
4748
_stretch_v2: bool,
4849
_stretch_v3: bool,
4950
_target_smile: str,
51+
loc_data: dict[str, ThermoLoc],
5052
smile_fw_version: str | None,
5153
smile_hostname: str,
5254
smile_hw_version: str | None,
@@ -79,6 +81,7 @@ def __init__(
7981
self._stretch_v2 = _stretch_v2
8082
self._stretch_v3 = _stretch_v3
8183
self._target_smile = _target_smile
84+
self.loc_data = loc_data
8285
self.smile_fw_version = smile_fw_version
8386
self.smile_hostname = smile_hostname
8487
self.smile_hw_version = smile_hw_version

plugwise/smile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
DeviceData,
2424
GatewayData,
2525
PlugwiseData,
26+
ThermoLoc,
2627
)
2728
from plugwise.data import SmileData
2829
from plugwise.exceptions import PlugwiseError
@@ -54,6 +55,7 @@ def __init__(
5455
_opentherm_device: bool,
5556
_schedule_old_states: dict[str, dict[str, str]],
5657
_target_smile: str | None,
58+
loc_data: dict[str, ThermoLoc],
5759
smile_fw_version: str | None,
5860
smile_hostname: str | None,
5961
smile_hw_version: str | None,
@@ -87,6 +89,7 @@ def __init__(
8789
self._opentherm_device = _opentherm_device
8890
self._schedule_old_states = _schedule_old_states
8991
self._target_smile = _target_smile
92+
self.loc_data = loc_data
9093
self.smile_fw_version = smile_fw_version
9194
self.smile_hostname = smile_hostname
9295
self.smile_hw_version = smile_hw_version

tests/test_init.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def show_setup(location_list, device_list):
535535
)
536536
if device_count == 0: # pragma: no cover
537537
_LOGGER.info(" ! no devices found in this location")
538-
assert False
539538

540539
@pytest.mark.asyncio
541540
async def device_test(
@@ -590,14 +589,13 @@ async def device_test(
590589
return # pragma: no cover
591590

592591
self.device_list = list(data.devices.keys())
593-
# _temp_list = [d["location"] for d in self.device_list if "location" in d]
594-
# location_list = list(dict.fromkeys(_temp_list))
592+
location_list = smile.loc_data
595593

596594
_LOGGER.info("Gateway id = %s", data.gateway["gateway_id"])
597595
_LOGGER.info("Hostname = %s", smile.smile_hostname)
598596
_LOGGER.info("Gateway data = %s", data.gateway)
599597
_LOGGER.info("Device list = %s", data.devices)
600-
# self.show_setup(location_list, data.devices)
598+
self.show_setup(location_list, data.devices)
601599

602600
# Perform tests and asserts
603601
tests = 0

0 commit comments

Comments
 (0)