Skip to content

Commit

Permalink
Fix synology_dsm availablity (#115073)
Browse files Browse the repository at this point in the history
* Remove reload on update failure from synology_dsm

fixes #115062

The coordinator will retry on its own later, there is no
reason to reload here.  This was added in #42697

* fix available checks
  • Loading branch information
bdraco authored Apr 7, 2024
1 parent b456a21 commit f2fe2c4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def is_on(self) -> bool:
@property
def available(self) -> bool:
"""Return True if entity is available."""
return bool(self._api.security)
return bool(self._api.security) and super().available

@property
def extra_state_attributes(self) -> dict[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def device_info(self) -> DeviceInfo:
@property
def available(self) -> bool:
"""Return the availability of the camera."""
return self.camera_data.is_enabled and self.coordinator.last_update_success
return self.camera_data.is_enabled and super().available

@property
def is_recording(self) -> bool:
Expand Down
13 changes: 1 addition & 12 deletions homeassistant/components/synology_dsm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,7 @@ async def async_unload(self) -> None:

async def async_update(self) -> None:
"""Update function for updating API information."""
try:
await self._update()
except SYNOLOGY_CONNECTION_EXCEPTIONS as err:
LOGGER.debug(
"Connection error during update of '%s' with exception: %s",
self._entry.unique_id,
err,
)
LOGGER.warning(
"Connection error during update, fallback by reloading the entry"
)
await self._hass.config_entries.async_reload(self._entry.entry_id)
await self._update()

async def _update(self) -> None:
"""Update function for updating API information."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def native_value(self) -> StateType:
@property
def available(self) -> bool:
"""Return True if entity is available."""
return bool(self._api.utilisation)
return bool(self._api.utilisation) and super().available


class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SynoDSMSensor):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def async_turn_off(self, **kwargs: Any) -> None:
@property
def available(self) -> bool:
"""Return True if entity is available."""
return bool(self._api.surveillance_station)
return bool(self._api.surveillance_station) and super().available

@property
def device_info(self) -> DeviceInfo:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/synology_dsm/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SynoDSMUpdateEntity(
@property
def available(self) -> bool:
"""Return True if entity is available."""
return bool(self._api.upgrade)
return bool(self._api.upgrade) and super().available

@property
def installed_version(self) -> str | None:
Expand Down

0 comments on commit f2fe2c4

Please sign in to comment.