Add configuration url to Synology DSM (#57704)

This commit is contained in:
Michael 2021-10-14 23:13:01 +02:00 committed by GitHub
parent 9c7dc5865c
commit 2e5af5d8e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -362,6 +362,10 @@ class SynoApi:
"""Initialize the API wrapper class.""" """Initialize the API wrapper class."""
self._hass = hass self._hass = hass
self._entry = entry self._entry = entry
if entry.data.get(CONF_SSL):
self.config_url = f"https://{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}"
else:
self.config_url = f"http://{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}"
# DSM APIs # DSM APIs
self.dsm: SynologyDSM = None self.dsm: SynologyDSM = None
@ -609,13 +613,14 @@ class SynologyDSMBaseEntity(CoordinatorEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device information.""" """Return the device information."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self._api.information.serial)}, identifiers={(DOMAIN, self._api.information.serial)},
"name": "Synology NAS", name="Synology NAS",
"manufacturer": "Synology", manufacturer="Synology",
"model": self._api.information.model, model=self._api.information.model,
"sw_version": self._api.information.version_string, sw_version=self._api.information.version_string,
} configuration_url=self._api.config_url,
)
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Register entity for updates from API.""" """Register entity for updates from API."""
@ -677,13 +682,12 @@ class SynologyDSMDeviceEntity(SynologyDSMBaseEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device information.""" """Return the device information."""
return { return DeviceInfo(
"identifiers": { identifiers={(DOMAIN, f"{self._api.information.serial}_{self._device_id}")},
(DOMAIN, f"{self._api.information.serial}_{self._device_id}") name=f"Synology NAS ({self._device_name} - {self._device_type})",
}, manufacturer=self._device_manufacturer,
"name": f"Synology NAS ({self._device_name} - {self._device_type})", model=self._device_model,
"manufacturer": self._device_manufacturer, sw_version=self._device_firmware,
"model": self._device_model, via_device=(DOMAIN, self._api.information.serial),
"sw_version": self._device_firmware, configuration_url=self._api.config_url,
"via_device": (DOMAIN, self._api.information.serial), )
}