|
6 | 6 | from typing import TYPE_CHECKING |
7 | 7 |
|
8 | 8 | from pysmaev.const import SmaEvChargerMeasurements |
| 9 | +from pysmaev.exceptions import SmaEvChargerChannelError |
9 | 10 | from pysmaev.helpers import get_measurements_channel, get_parameters_channel |
10 | 11 |
|
11 | 12 | from homeassistant.components.sensor import ( |
@@ -237,18 +238,21 @@ def __init__( |
237 | 238 | @callback |
238 | 239 | def _handle_coordinator_update(self) -> None: |
239 | 240 | """Handle updated data from the coordinator.""" |
240 | | - if self.entity_description.type == SMAEV_MEASUREMENT: |
241 | | - channel = get_measurements_channel( |
242 | | - self.coordinator.data[SMAEV_MEASUREMENT], |
243 | | - self.entity_description.channel, |
244 | | - ) |
245 | | - value = channel[0][SMAEV_VALUE] |
246 | | - else: # SMAEV_PARAMETER |
247 | | - channel = get_parameters_channel( |
248 | | - self.coordinator.data[SMAEV_PARAMETER], |
249 | | - self.entity_description.channel, |
250 | | - ) |
251 | | - value = channel[SMAEV_VALUE] |
| 241 | + try: |
| 242 | + if self.entity_description.type == SMAEV_MEASUREMENT: |
| 243 | + channel = get_measurements_channel( |
| 244 | + self.coordinator.data[SMAEV_MEASUREMENT], |
| 245 | + self.entity_description.channel, |
| 246 | + ) |
| 247 | + value = channel[0][SMAEV_VALUE] |
| 248 | + else: # SMAEV_PARAMETER |
| 249 | + channel = get_parameters_channel( |
| 250 | + self.coordinator.data[SMAEV_PARAMETER], |
| 251 | + self.entity_description.channel, |
| 252 | + ) |
| 253 | + value = channel[SMAEV_VALUE] |
| 254 | + except SmaEvChargerChannelError: |
| 255 | + return |
252 | 256 |
|
253 | 257 | value = self.entity_description.value_mapping.get(value, value) |
254 | 258 |
|
|
0 commit comments