|
25 | 25 | PlugwiseData, |
26 | 26 | ThermoLoc, |
27 | 27 | ) |
28 | | -from plugwise.exceptions import ConnectionFailedError, PlugwiseError |
| 28 | +from plugwise.exceptions import ConnectionFailedError, DataMissingError, PlugwiseError |
29 | 29 | from plugwise.legacy.data import SmileLegacyData |
30 | 30 |
|
31 | 31 | import aiohttp |
@@ -120,18 +120,28 @@ async def async_update(self) -> PlugwiseData: |
120 | 120 | ) |
121 | 121 | self.gw_data: GatewayData = {} |
122 | 122 | self.gw_entities: dict[str, GwEntityData] = {} |
123 | | - await self.full_xml_update() |
124 | | - self.get_all_gateway_entities() |
| 123 | + try: |
| 124 | + await self.full_xml_update() |
| 125 | + self.get_all_gateway_entities() |
| 126 | + # Detect failed data-retrieval |
| 127 | + _ = self.gw_entities[self.gateway_id]["location"] |
| 128 | + except KeyError as err: |
| 129 | + raise DataMissingError("No Plugwise data received") from err |
125 | 130 | # Otherwise perform an incremental update |
126 | 131 | else: |
127 | | - self._domain_objects = await self.request(DOMAIN_OBJECTS) |
128 | | - match self._target_smile: |
129 | | - case "smile_v2": |
130 | | - self._modules = await self.request(MODULES) |
131 | | - case self._target_smile if self._target_smile in REQUIRE_APPLIANCES: |
132 | | - self._appliances = await self.request(APPLIANCES) |
133 | | - |
134 | | - self._update_gw_entities() |
| 132 | + try: |
| 133 | + self._domain_objects = await self.request(DOMAIN_OBJECTS) |
| 134 | + match self._target_smile: |
| 135 | + case "smile_v2": |
| 136 | + self._modules = await self.request(MODULES) |
| 137 | + case self._target_smile if self._target_smile in REQUIRE_APPLIANCES: |
| 138 | + self._appliances = await self.request(APPLIANCES) |
| 139 | + |
| 140 | + self._update_gw_entities() |
| 141 | + # Detect failed data-retrieval |
| 142 | + _ = self.gw_entities[self.gateway_id]["location"] |
| 143 | + except KeyError as err: |
| 144 | + raise DataMissingError("No Plugwise data received") from err |
135 | 145 |
|
136 | 146 | self._previous_day_number = day_number |
137 | 147 | return PlugwiseData( |
|
0 commit comments