Skip to content

Commit 46c0665

Browse files
committed
Implement more none module_data guarding
1 parent adc9c0d commit 46c0665

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

plugwise/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def _appl_heater_central_info(
101101
module_data = self._get_module_data(xml_1, locator_1, xml_3)
102102
if not module_data["contents"]:
103103
module_data = self._get_module_data(xml_1, locator_2, xml_3)
104+
if not module_data["contents"]:
105+
return Munch() # no module-data present means the device has been removed
104106
appl.vendor_name = module_data["vendor_name"]
105107
appl.hardware = module_data["hardware_version"]
106108
appl.model_id = module_data["vendor_model"] if not legacy else None

plugwise/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def _get_p1_smartmeter_info(self) -> None:
171171
locator = MODULE_LOCATOR
172172
module_data = self._get_module_data(self._home_location, locator)
173173
if not module_data["contents"]:
174-
LOGGER.error("No module data found for SmartMeter") # pragma: no cover
175-
return # pragma: no cover
174+
return Munch() # no module-data present means the device has been removed
175+
176176
appl.available = None
177177
appl.entity_id = self._gateway_id
178178
appl.firmware = module_data["firmware_version"]

plugwise/legacy/helper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def _energy_entity_info_finder(self, appliance: etree, appl: Munch) -> Munch:
214214
module_data = self._get_module_data(
215215
appliance, locator, self._modules, legacy=True
216216
)
217+
if not module_data["contents"]:
218+
return Munch() # no module-data present means the device has been removed
219+
217220
appl.zigbee_mac = module_data["zigbee_mac_address"]
218221
# Filter appliance without zigbee_mac, it's an orphaned device
219222
if appl.zigbee_mac is None and self.smile.type != "power":

0 commit comments

Comments
 (0)