Skip to content

Commit a48f01f

Browse files
authored
Raise UpdateFailed if API returns None in sfr_box (home-assistant#157434)
1 parent 08b758b commit a48f01f

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

homeassistant/components/sfr_box/binary_sensor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,4 @@ class SFRBoxBinarySensor[_T](SFRCoordinatorEntity[_T], BinarySensorEntity):
9797
@property
9898
def is_on(self) -> bool | None:
9999
"""Return the native value of the device."""
100-
if self.coordinator.data is None:
101-
return None
102100
return self.entity_description.value_fn(self.coordinator.data)

homeassistant/components/sfr_box/coordinator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SFRRuntimeData:
3333
wan: SFRDataUpdateCoordinator[WanInfo]
3434

3535

36-
class SFRDataUpdateCoordinator[_DataT](DataUpdateCoordinator[_DataT | None]):
36+
class SFRDataUpdateCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
3737
"""Coordinator to manage data updates."""
3838

3939
config_entry: SFRConfigEntry
@@ -57,9 +57,11 @@ def __init__(
5757
update_interval=_SCAN_INTERVAL,
5858
)
5959

60-
async def _async_update_data(self) -> _DataT | None:
60+
async def _async_update_data(self) -> _DataT:
6161
"""Update data."""
6262
try:
63-
return await self._method(self.box)
63+
if data := await self._method(self.box):
64+
return data
6465
except SFRBoxError as err:
6566
raise UpdateFailed from err
67+
raise UpdateFailed("No data received from SFR Box")

homeassistant/components/sfr_box/sensor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,4 @@ class SFRBoxSensor[_T](SFRCoordinatorEntity[_T], SensorEntity):
253253
@property
254254
def native_value(self) -> StateType:
255255
"""Return the native value of the device."""
256-
if self.coordinator.data is None:
257-
return None
258256
return self.entity_description.value_fn(self.coordinator.data)

0 commit comments

Comments
 (0)