Skip to content

Commit 82a7e0c

Browse files
authored
Merge pull request #686 from plugwise/revert_main
Revert unintended updates - II
2 parents c827059 + 6fd9fdc commit 82a7e0c

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

plugwise/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ async def connect(self) -> Version | None:
186186
async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
187187
"""Helper-function for connect().
188188
189-
Detect which type of Plugwise Gateway is being connected.
189+
Detect which type of Smile is connected.
190190
"""
191191
model: str = "Unknown"
192192
if (gateway := result.find("./gateway")) is not None:
@@ -260,10 +260,7 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
260260
async def _smile_detect_legacy(
261261
self, result: etree, dsmrmain: etree, model: str
262262
) -> str:
263-
"""Helper-function for _smile_detect().
264-
265-
Detect which type of legacy Plugwise Gateway is being connected.
266-
"""
263+
"""Helper-function for _smile_detect()."""
267264
return_model = model
268265
# Stretch: find the MAC of the zigbee master_controller (= Stick)
269266
if (network := result.find("./module/protocols/master_controller")) is not None:
@@ -308,15 +305,15 @@ async def _smile_detect_legacy(
308305
return return_model
309306

310307
async def full_xml_update(self) -> None:
311-
"""Perform a first fetch of the Plugwise server XML data."""
308+
"""Helper-function used for testing."""
312309
await self._smile_api.full_xml_update()
313310

314311
def get_all_gateway_entities(self) -> None:
315-
"""Collect the Plugwise gateway entities and their data and states from the received raw XML-data."""
312+
"""Helper-function used for testing."""
316313
self._smile_api.get_all_gateway_entities()
317314

318315
async def async_update(self) -> PlugwiseData:
319-
"""Update the Plughwise gateway entities and their data and states."""
316+
"""Update the various entities and their states."""
320317
data = PlugwiseData(devices={}, gateway={})
321318
try:
322319
data = await self._smile_api.async_update()

plugwise/helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def __init__(self) -> None:
275275
self.smile_type: str
276276
self.smile_version: version.Version | None
277277
self.smile_zigbee_mac_address: str | None
278+
self.therms_with_offset_func: list[str] = []
278279
self._zones: dict[str, GwEntityData] = {}
279280
SmileCommon.__init__(self)
280281

plugwise/legacy/smile.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
self._previous_day_number: str = "0"
8484

8585
async def full_xml_update(self) -> None:
86-
"""Perform a first fetch of the Plugwise server XML data."""
86+
"""Perform a first fetch of all XML data, needed for initialization."""
8787
self._domain_objects = await self.request(DOMAIN_OBJECTS)
8888
self._locations = await self.request(LOCATIONS)
8989
self._modules = await self.request(MODULES)
@@ -92,23 +92,24 @@ async def full_xml_update(self) -> None:
9292
self._appliances = await self.request(APPLIANCES)
9393

9494
def get_all_gateway_entities(self) -> None:
95-
"""Collect the Plugwise gateway entities and their data and states from the received raw XML-data.
95+
"""Collect the gateway entities from the received raw XML-data.
9696
97-
First, collect all the connected entities and their initial data.
98-
Collect and add switching- and/or pump-group entities.
99-
Finally, collect the data and states for each entity.
97+
Run this functions once to gather the initial device configuration,
98+
then regularly run async_update() to refresh the device data.
10099
"""
100+
# Gather all the devices and their initial data
101101
self._all_appliances()
102+
103+
# Collect and add switching- and/or pump-group devices
102104
if group_data := self._get_group_switches():
103105
self.gw_entities.update(group_data)
104106

107+
# Collect the remaining data for all entities
105108
self._all_entity_data()
106109

107110
async def async_update(self) -> PlugwiseData:
108-
"""Perform an full update update at day-change: re-collect all gateway entities and their data and states.
109-
110-
Otherwise perform an incremental update: only collect the entities updated data and states.
111-
"""
111+
"""Perform an incremental update for updating the various device states."""
112+
# Perform a full update at day-change
112113
day_number = dt.datetime.now().strftime("%w")
113114
if (
114115
day_number # pylint: disable=consider-using-assignment-expr
@@ -128,6 +129,7 @@ async def async_update(self) -> PlugwiseData:
128129
raise DataMissingError(
129130
"No (full) Plugwise legacy data received"
130131
) from err
132+
# Otherwise perform an incremental update
131133
else:
132134
try:
133135
self._domain_objects = await self.request(DOMAIN_OBJECTS)

plugwise/smile.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,45 @@ def __init__(
9393
self.smile_name = smile_name
9494
self.smile_type = smile_type
9595
self.smile_version = smile_version
96-
self.therms_with_offset_func: list[str] = []
9796
SmileData.__init__(self)
9897

9998
async def full_xml_update(self) -> None:
100-
"""Perform a first fetch of the Plugwise server XML data."""
99+
"""Perform a first fetch of all XML data, needed for initialization."""
101100
self._domain_objects = await self.request(DOMAIN_OBJECTS)
102101
self._get_plugwise_notifications()
103102

104103
def get_all_gateway_entities(self) -> None:
105-
"""Collect the Plugwise gateway entities and their data and states from the received raw XML-data.
104+
"""Collect the gateway entities from the received raw XML-data.
106105
107-
First, collect all the connected entities and their initial data.
108-
If a thermostat-gateway, collect a list of thermostats with offset-capability.
109-
Collect and add switching- and/or pump-group entities.
110-
Finally, collect the data and states for each entity.
106+
Run this functions once to gather the initial configuration,
107+
then regularly run async_update() to refresh the entity data.
111108
"""
109+
# Gather all the entities and their initial data
112110
self._all_appliances()
113111
if self._is_thermostat:
112+
if self.smile(ADAM):
113+
self._scan_thermostats()
114+
# Collect a list of thermostats with offset-capability
114115
self.therms_with_offset_func = (
115116
self._get_appliances_with_offset_functionality()
116117
)
117-
if self.smile(ADAM):
118-
self._scan_thermostats()
119118

119+
# Collect and add switching- and/or pump-group devices
120120
if group_data := self._get_group_switches():
121121
self.gw_entities.update(group_data)
122122

123+
# Collect the remaining data for all entities
123124
self._all_entity_data()
124125

125126
async def async_update(self) -> PlugwiseData:
126-
"""Perform an full update: re-collect all gateway entities and their data and states.
127-
128-
Any change in the connected entities will be detected immediately.
129-
"""
127+
"""Perform an incremental update for updating the various device states."""
130128
self.gw_data: GatewayData = {}
131129
self.gw_entities: dict[str, GwEntityData] = {}
132130
self._zones: dict[str, GwEntityData] = {}
133131
try:
134132
await self.full_xml_update()
135133
self.get_all_gateway_entities()
136-
# Set self._cooling_enabled - required for set_temperature(),
134+
# Set self._cooling_enabled - required for set_temperature,
137135
# also, check for a failed data-retrieval
138136
if "heater_id" in self.gw_data:
139137
heat_cooler = self.gw_entities[self.gw_data["heater_id"]]

0 commit comments

Comments
 (0)