From 0b813f86000d7c9def779253ba29c4125523b78e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 21 Feb 2022 22:50:59 -1000 Subject: [PATCH] Add configuration_url to lookin (#67021) --- homeassistant/components/lookin/__init__.py | 1 + homeassistant/components/lookin/entity.py | 10 ++++++---- homeassistant/components/lookin/models.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/lookin/__init__.py b/homeassistant/components/lookin/__init__.py index cedc4fc77fe..c15d46c5158 100644 --- a/homeassistant/components/lookin/__init__.py +++ b/homeassistant/components/lookin/__init__.py @@ -153,6 +153,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) hass.data[DOMAIN][entry.entry_id] = LookinData( + host=host, lookin_udp_subs=lookin_udp_subs, lookin_device=lookin_device, meteo_coordinator=meteo_coordinator, diff --git a/homeassistant/components/lookin/entity.py b/homeassistant/components/lookin/entity.py index 58eafd3843f..6ff167d86fe 100644 --- a/homeassistant/components/lookin/entity.py +++ b/homeassistant/components/lookin/entity.py @@ -18,7 +18,7 @@ from .models import LookinData LOGGER = logging.getLogger(__name__) -def _lookin_device_to_device_info(lookin_device: Device) -> DeviceInfo: +def _lookin_device_to_device_info(lookin_device: Device, host: str) -> DeviceInfo: """Convert a lookin device into DeviceInfo.""" return DeviceInfo( identifiers={(DOMAIN, lookin_device.id)}, @@ -26,17 +26,19 @@ def _lookin_device_to_device_info(lookin_device: Device) -> DeviceInfo: manufacturer="LOOKin", model=MODEL_NAMES[lookin_device.model], sw_version=lookin_device.firmware, + configuration_url=f"http://{host}/device", ) def _lookin_controlled_device_to_device_info( - lookin_device: Device, uuid: str, device: Climate | Remote + lookin_device: Device, uuid: str, device: Climate | Remote, host: str ) -> DeviceInfo: return DeviceInfo( identifiers={(DOMAIN, uuid)}, name=device.name, model=device.device_type, via_device=(DOMAIN, lookin_device.id), + configuration_url=f"http://{host}/data/{uuid}", ) @@ -62,7 +64,7 @@ class LookinDeviceCoordinatorEntity(LookinDeviceMixIn, CoordinatorEntity): super().__init__(lookin_data.meteo_coordinator) self._set_lookin_device_attrs(lookin_data) self._attr_device_info = _lookin_device_to_device_info( - lookin_data.lookin_device + lookin_data.lookin_device, lookin_data.host ) @@ -102,7 +104,7 @@ class LookinCoordinatorEntity(LookinDeviceMixIn, LookinEntityMixIn, CoordinatorE self._set_lookin_device_attrs(lookin_data) self._set_lookin_entity_attrs(uuid, device, lookin_data) self._attr_device_info = _lookin_controlled_device_to_device_info( - self._lookin_device, uuid, device + self._lookin_device, uuid, device, lookin_data.host ) self._attr_unique_id = uuid self._attr_name = device.name diff --git a/homeassistant/components/lookin/models.py b/homeassistant/components/lookin/models.py index 3587136c4a2..f0dffe66ec0 100644 --- a/homeassistant/components/lookin/models.py +++ b/homeassistant/components/lookin/models.py @@ -13,6 +13,7 @@ from .coordinator import LookinDataUpdateCoordinator class LookinData: """Data for the lookin integration.""" + host: str lookin_udp_subs: LookinUDPSubscriptions lookin_device: Device meteo_coordinator: LookinDataUpdateCoordinator