10000 Enhance Synology DSM handling of external USB drives by lezmaka · Pull Request #145943 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Enhance Synology DSM handling of external USB drives #145943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
19 changes: 19 additions & 0 deletions homeassistant/components/synology_dsm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,25 @@ def native_value(self) -> StateType:

return attr # type: ignore[no-any-return]

@property
def available(self) -> bool:
"""Return True if entity is available."""
found = False
external_usb = self._api.external_usb
assert external_usb is not None
if "device" in self.entity_description.key:
for device in external_usb.get_devices.values():
if device.device_name == self._device_id:
found = True
break
elif "partition" in self.entity_description.key:
for device in external_usb.get_devices.values():
for partition in device.device_partitions.values():
if partition.partition_title == self._device_id:
found = True
break
return found and super().available


class SynoDSMInfoSensor(SynoDSMSensor):
"""Representation a Synology information sensor."""
Expand Down
0