Skip to content

Commit 787dc15

Browse files
committed
Try 6
1 parent 1e92c17 commit 787dc15

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

plugwise/smile.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ def __init__(
119119
self._cooling_enabled = False
120120
self._cooling_present = _cooling_present
121121
self._elga = _elga
122+
self._gateway_id = _gateway_id
122123
self._heater_id: str
123124
self._is_thermostat = _is_thermostat
124125
self._last_active = _last_active
125126
self._loc_data = _loc_data
126127
self._on_off_device = _on_off_device
127128
self._opentherm_device = _opentherm_device
128129
self._schedule_old_states = _schedule_old_states
129-
self.gateway_id = _gateway_id
130130
self.request = request
131131
self.smile_fw_version = smile_fw_version
132132
self.smile_hostname = smile_hostname
@@ -151,7 +151,7 @@ def _all_entity_data(self) -> None:
151151

152152
self.gw_data.update(
153153
{
154-
"gateway_id": self.gateway_id,
154+
"gateway_id": self._gateway_id,
155155
"item_count": self._count,
156156
"notifications": self._notifications,
157157
"reboot": True,
@@ -180,7 +180,7 @@ def _update_gw_entities(self) -> None:
180180
mac_list: list[str] = []
181181
for entity_id, entity in self.gw_entities.items():
182182
data = self._get_entity_data(entity_id)
183-
if entity_id == self.gateway_id:
183+
if entity_id == self._gateway_id:
184184
mac_list = self._detect_low_batteries()
185185
self._add_or_update_notifications(entity_id, entity, data)
186186

@@ -234,7 +234,7 @@ def _add_or_update_notifications(
234234
) -> None:
235235
"""Helper-function adding or updating the Plugwise notifications."""
236236
if (
237-
entity_id == self.gateway_id
237+
entity_id == self._gateway_id
238238
and (self._is_thermostat or self.smile_type == "power")
239239
) or (
240240
"binary_sensors" in entity
@@ -350,7 +350,7 @@ def _get_p1_smartmeter_info(self) -> None:
350350
LOGGER.error("No module data found for SmartMeter") # pragma: no cover
351351
return # pragma: no cover
352352
appl.available = None
353-
appl.entity_id = self.gateway_id
353+
appl.entity_id = self._gateway_id
354354
appl.firmware = module_data["firmware_version"]
355355
appl.hardware = module_data["hardware_version"]
356356
appl.location = self._home_loc_id
@@ -363,8 +363,8 @@ def _get_p1_smartmeter_info(self) -> None:
363363
appl.zigbee_mac = None
364364

365365
# Replace the entity_id of the gateway by the smartmeter location_id
366-
self.gw_entities[self._home_loc_id] = self.gw_entities.pop(self.gateway_id)
367-
self.gateway_id = self._home_loc_id
366+
self.gw_entities[self._home_loc_id] = self.gw_entities.pop(self._gateway_id)
367+
self._gateway_id = self._home_loc_id
368368

369369
self._create_gw_entities(appl)
370370

@@ -437,7 +437,7 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree) -> Munch:
437437

438438
def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
439439
"""Helper-function for _appliance_info_finder()."""
440-
self.gateway_id = appliance.attrib["id"]
440+
self._gateway_id = appliance.attrib["id"]
441441
appl.firmware = str(self.smile_fw_version)
442442
appl.hardware = self.smile_hw_version
443443
appl.mac = self.smile_mac_address
@@ -715,7 +715,7 @@ def _get_actuator_mode(
715715
716716
Collect the requested gateway mode.
717717
"""
718-
if not (self.smile(ADAM) and entity_id == self.gateway_id):
718+
if not (self.smile(ADAM) and entity_id == self._gateway_id):
719719
return None
720720

721721
if (search := search_actuator_functionalities(appliance, key)) is not None:
@@ -756,7 +756,7 @@ def _get_gateway_mode(
756756

757757
def _get_gateway_outdoor_temp(self, entity_id: str, data: GwEntityData) -> None:
758758
"""Adam & Anna: the Smile outdoor_temperature is present in the Home location."""
759-
if self._is_thermostat and entity_id == self.gateway_id:
759+
if self._is_thermostat and entity_id == self._gateway_id:
760760
locator = "./logs/point_log[type='outdoor_temperature']/period/measurement"
761761
if (found := self._home_location.find(locator)) is not None:
762762
value = format_measure(found.text, NONE)
@@ -1295,7 +1295,7 @@ def _climate_data(
12951295

12961296
def check_reg_mode(self, mode: str) -> bool:
12971297
"""Helper-function for device_data_climate()."""
1298-
gateway = self.gw_entities[self.gateway_id]
1298+
gateway = self.gw_entities[self._gateway_id]
12991299
return (
13001300
"regulation_modes" in gateway and gateway["select_regulation_mode"] == mode
13011301
)
@@ -1349,7 +1349,7 @@ def get_all_gateway_entities(self) -> None:
13491349
Finally, collect the data and states for each entity.
13501350
"""
13511351
self._all_appliances()
1352-
LOGGER.debug("HOI gateway_id: %s", self.gateway_id)
1352+
LOGGER.debug("HOI gateway_id: %s", self._gateway_id)
13531353
if self._is_thermostat:
13541354
self.therms_with_offset_func = (
13551355
self._get_appliances_with_offset_functionality()
@@ -1361,7 +1361,7 @@ def get_all_gateway_entities(self) -> None:
13611361
self.gw_entities.update(group_data)
13621362

13631363
self._all_entity_data()
1364-
LOGGER.debug("HOI 1 gateway_id: %s", self.gateway_id)
1364+
LOGGER.debug("HOI 1 gateway_id: %s", self._gateway_id)
13651365

13661366
async def async_update(self) -> PlugwiseData:
13671367
"""Perform an full update: re-collect all gateway entities and their data and states.
@@ -1373,9 +1373,9 @@ async def async_update(self) -> PlugwiseData:
13731373
self._zones: dict[str, GwEntityData] = {}
13741374
try:
13751375
await self.full_xml_update()
1376-
LOGGER.debug("HOI 2a gateway_id: %s", self.gateway_id)
1376+
LOGGER.debug("HOI 2a gateway_id: %s", self._gateway_id)
13771377
self.get_all_gateway_entities()
1378-
LOGGER.debug("HOI 2b gateway_id: %s", self.gateway_id)
1378+
LOGGER.debug("HOI 2b gateway_id: %s", self._gateway_id)
13791379
# Set self._cooling_enabled - required for set_temperature(),
13801380
# also, check for a failed data-retrieval
13811381
if "heater_id" in self.gw_data:
@@ -1388,11 +1388,11 @@ async def async_update(self) -> PlugwiseData:
13881388
"cooling_enabled"
13891389
]
13901390
else: # cover failed data-retrieval for P1
1391-
_ = self.gw_entities[self.gateway_id]["location"]
1391+
_ = self.gw_entities[self._gateway_id]["location"]
13921392
except KeyError as err:
13931393
raise DataMissingError("No Plugwise actual data received") from err
13941394

1395-
LOGGER.debug("HOI 2c gateway_id: %s", self.gateway_id)
1395+
LOGGER.debug("HOI 2c gateway_id: %s", self._gateway_id)
13961396
LOGGER.debug("HOI 2c last-active: %s", self._last_active)
13971397
return PlugwiseData(
13981398
devices=self.gw_entities,
@@ -1521,7 +1521,7 @@ async def set_gateway_mode(self, mode: str) -> None:
15211521
vacation_time = time_2 + "T23:00:00.000Z"
15221522
valid = f"<valid_from>{vacation_time}</valid_from><valid_to>{end_time}</valid_to>"
15231523

1524-
uri = f"{APPLIANCES};id={self.gateway_id}/gateway_mode_control"
1524+
uri = f"{APPLIANCES};id={self._gateway_id}/gateway_mode_control"
15251525
data = f"<gateway_mode_control_functionality><mode>{mode}</mode>{valid}</gateway_mode_control_functionality>"
15261526

15271527
await self.call_request(uri, method="put", data=data)

0 commit comments

Comments
 (0)