Skip to content

Commit bc2d4e8

Browse files
committed
Extend internal-use selfs
1 parent ad65d13 commit bc2d4e8

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

plugwise/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def __init__(
6969
self._elga = False
7070
self._is_thermostat = False
7171
self._last_active: dict[str, str | None] = {}
72+
self._loc_data: dict[str, ThermoLoc] = {}
7273
self._on_off_device = False
7374
self._opentherm_device = False
7475
self._schedule_old_states: dict[str, dict[str, str]] = {}
7576
self._smile_api: SmileAPI | SmileLegacyAPI
7677
self._stretch_v2 = False
7778
self._target_smile: str = NONE
7879
self.gateway_id: str = NONE
79-
self.loc_data: dict[str, ThermoLoc] = {}
8080
self.smile_fw_version: Version | None = None
8181
self.smile_hostname: str = NONE
8282
self.smile_hw_version: str | None = None
@@ -134,11 +134,11 @@ async def connect(self) -> Version | None:
134134
self._elga,
135135
self._is_thermostat,
136136
self._last_active,
137+
self._loc_data,
137138
self._on_off_device,
138139
self._opentherm_device,
139140
self._schedule_old_states,
140141
self.gateway_id,
141-
self.loc_data,
142142
self.smile_fw_version,
143143
self.smile_hostname,
144144
self.smile_hw_version,
@@ -155,11 +155,11 @@ async def connect(self) -> Version | None:
155155
self._request,
156156
self._websession,
157157
self._is_thermostat,
158+
self._loc_data,
158159
self._on_off_device,
159160
self._opentherm_device,
160161
self._stretch_v2,
161162
self._target_smile,
162-
self.loc_data,
163163
self.smile_fw_version,
164164
self.smile_hostname,
165165
self.smile_hw_version,

plugwise/data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _all_entity_data(self) -> None:
3636
self._update_gw_entities()
3737
if self.smile(ADAM):
3838
self._update_zones()
39-
self.gw_entities.update(self.zones)
39+
self.gw_entities.update(self._zones)
4040

4141
self.gw_data.update(
4242
{
@@ -55,9 +55,9 @@ def _all_entity_data(self) -> None:
5555
def _update_zones(self) -> None:
5656
"""Helper-function for _all_entity_data() and async_update().
5757
58-
Collect data for each zone/location and add to self.zones.
58+
Collect data for each zone/location and add to self._zones.
5959
"""
60-
for location_id, zone in self.zones.items():
60+
for location_id, zone in self._zones.items():
6161
data = self._get_location_data(location_id)
6262
zone.update(data)
6363

@@ -158,7 +158,7 @@ def _get_location_data(self, loc_id: str) -> GwEntityData:
158158
159159
Provide entity-data, based on Location ID (= loc_id).
160160
"""
161-
zone = self.zones[loc_id]
161+
zone = self._zones[loc_id]
162162
data = self._get_zone_data(loc_id)
163163
if ctrl_state := self._control_state(loc_id):
164164
data["control_state"] = ctrl_state

plugwise/helper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def __init__(self) -> None:
224224
self._is_thermostat: bool
225225
self._last_active: dict[str, str | None]
226226
self._last_modified: dict[str, str] = {}
227+
self._loc_data: dict[str, ThermoLoc]
227228
self._notifications: dict[str, dict[str, str]] = {}
228229
self._on_off_device: bool
229230
self._opentherm_device: bool
@@ -251,7 +252,6 @@ def __init__(self) -> None:
251252
self.gateway_id: str
252253
self.gw_data: GatewayData = {}
253254
self.gw_entities: dict[str, GwEntityData] = {}
254-
self.loc_data: dict[str, ThermoLoc]
255255
self.smile_fw_version: Version | None
256256
self.smile_hw_version: str | None
257257
self.smile_mac_address: str | None
@@ -261,7 +261,7 @@ def __init__(self) -> None:
261261
self.smile_type: str
262262
self.smile_zigbee_mac_address: str | None
263263
self.therms_with_offset_func: list[str] = []
264-
self.zones: dict[str, GwEntityData] = {}
264+
self._zones: dict[str, GwEntityData] = {}
265265
SmileCommon.__init__(self)
266266

267267
def _all_appliances(self) -> None:
@@ -354,11 +354,11 @@ def _all_locations(self) -> None:
354354
if loc.name == "Home":
355355
self._home_location = loc.loc_id
356356

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

359359
def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
360360
"""Collect P1 DSMR SmartMeter info."""
361-
loc_id = next(iter(self.loc_data.keys()))
361+
loc_id = next(iter(self._loc_data.keys()))
362362
location = self._domain_objects.find(f'./location[@id="{loc_id}"]')
363363
locator = MODULE_LOCATOR
364364
module_data = self._get_module_data(location, locator)
@@ -488,7 +488,7 @@ def _get_zone_data(self, loc_id: str) -> GwEntityData:
488488
Collect the location-data based on location id.
489489
"""
490490
data: GwEntityData = {"sensors": {}}
491-
zone = self.zones[loc_id]
491+
zone = self._zones[loc_id]
492492
measurements = ZONE_MEASUREMENTS
493493
if (
494494
location := self._domain_objects.find(f'./location[@id="{loc_id}"]')
@@ -861,7 +861,7 @@ def _scan_thermostats(self) -> None:
861861

862862
for loc_id, loc_data in list(self._thermo_locs.items()):
863863
if loc_data["primary_prio"] != 0:
864-
self.zones[loc_id] = {
864+
self._zones[loc_id] = {
865865
"dev_class": "climate",
866866
"name": loc_data["name"],
867867
"thermostats": {"primary": loc_data["primary"], "secondary": loc_data["secondary"]}
@@ -874,7 +874,7 @@ def _match_locations(self) -> dict[str, ThermoLoc]:
874874
Match appliances with locations.
875875
"""
876876
matched_locations: dict[str, ThermoLoc] = {}
877-
for location_id, location_details in self.loc_data.items():
877+
for location_id, location_details in self._loc_data.items():
878878
for appliance_details in self.gw_entities.values():
879879
if appliance_details["location"] == location_id:
880880
location_details.update(

plugwise/legacy/helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(self) -> None:
6868
self._home_location: str
6969
self._is_thermostat: bool
7070
self._last_modified: dict[str, str] = {}
71+
self._loc_data: dict[str, ThermoLoc]
7172
self._locations: etree
7273
self._modules: etree
7374
self._notifications: dict[str, dict[str, str]] = {}
@@ -81,7 +82,6 @@ def __init__(self) -> None:
8182
self.gateway_id: str
8283
self.gw_data: GatewayData = {}
8384
self.gw_entities: dict[str, GwEntityData] = {}
84-
self.loc_data: dict[str, ThermoLoc]
8585
self.smile_fw_version: Version | None
8686
self.smile_hw_version: str | None
8787
self.smile_mac_address: str | None
@@ -161,7 +161,7 @@ def _all_locations(self) -> None:
161161
# Legacy Anna without outdoor_temp and Stretches have no locations, create fake location-data
162162
if not (locations := self._locations.findall("./location")):
163163
self._home_location = FAKE_LOC
164-
self.loc_data[FAKE_LOC] = {"name": "Home"}
164+
self._loc_data[FAKE_LOC] = {"name": "Home"}
165165
return
166166

167167
for location in locations:
@@ -182,7 +182,7 @@ def _all_locations(self) -> None:
182182
loc.name = "Home"
183183
self._home_location = loc.loc_id
184184

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

187187
def _create_legacy_gateway(self) -> None:
188188
"""Create the (missing) gateway entities for legacy Anna, P1 and Stretch.
@@ -251,7 +251,7 @@ def _energy_entity_info_finder(self, appliance: etree, appl: Munch) -> Munch:
251251

252252
def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
253253
"""Collect P1 DSMR Smartmeter info."""
254-
loc_id = next(iter(self.loc_data.keys()))
254+
loc_id = next(iter(self._loc_data.keys()))
255255
appl.available = None
256256
appl.entity_id = loc_id
257257
appl.location = loc_id

plugwise/legacy/smile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def __init__(
4444
request: Callable[..., Awaitable[Any]],
4545
websession: aiohttp.ClientSession,
4646
_is_thermostat: bool,
47+
_loc_data: dict[str, ThermoLoc],
4748
_on_off_device: bool,
4849
_opentherm_device: bool,
4950
_stretch_v2: bool,
5051
_target_smile: str,
51-
loc_data: dict[str, ThermoLoc],
5252
smile_fw_version: Version | None,
5353
smile_hostname: str,
5454
smile_hw_version: str | None,
@@ -65,11 +65,11 @@ def __init__(
6565

6666
self._cooling_present = False
6767
self._is_thermostat = _is_thermostat
68+
self._loc_data = _loc_data
6869
self._on_off_device = _on_off_device
6970
self._opentherm_device = _opentherm_device
7071
self._stretch_v2 = _stretch_v2
7172
self._target_smile = _target_smile
72-
self.loc_data = loc_data
7373
self.request = request
7474
self.smile_fw_version = smile_fw_version
7575
self.smile_hostname = smile_hostname

plugwise/smile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def __init__(
5353
_elga: bool,
5454
_is_thermostat: bool,
5555
_last_active: dict[str, str | None],
56+
_loc_data: dict[str, ThermoLoc],
5657
_on_off_device: bool,
5758
_opentherm_device: bool,
5859
_schedule_old_states: dict[str, dict[str, str]],
5960
gateway_id: str,
60-
loc_data: dict[str, ThermoLoc],
6161
smile_fw_version: Version | None,
6262
smile_hostname: str | None,
6363
smile_hw_version: str | None,
@@ -76,11 +76,11 @@ def __init__(
7676
self._elga = _elga
7777
self._is_thermostat = _is_thermostat
7878
self._last_active = _last_active
79+
self._loc_data = _loc_data
7980
self._on_off_device = _on_off_device
8081
self._opentherm_device = _opentherm_device
8182
self._schedule_old_states = _schedule_old_states
8283
self.gateway_id = gateway_id
83-
self.loc_data = loc_data
8484
self.request = request
8585
self.smile_fw_version = smile_fw_version
8686
self.smile_hostname = smile_hostname
@@ -126,7 +126,7 @@ async def async_update(self) -> PlugwiseData:
126126
"""Perform an incremental update for updating the various device states."""
127127
self.gw_data: GatewayData = {}
128128
self.gw_entities: dict[str, GwEntityData] = {}
129-
self.zones: dict[str, GwEntityData] = {}
129+
self._zones: dict[str, GwEntityData] = {}
130130
try:
131131
await self.full_xml_update()
132132
self.get_all_gateway_entities()

tests/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def test_and_assert(test_dict, data, header):
642642
return # pragma: no cover
643643

644644
self.entity_list = list(data.entities.keys())
645-
location_list = smile.loc_data
645+
location_list = smile._loc_data
646646

647647
_LOGGER.info("Gateway id = %s", data.gateway["gateway_id"])
648648
_LOGGER.info("Hostname = %s", smile.smile_hostname)

0 commit comments

Comments
 (0)