diff --git a/homeassistant/components/shelly/button.py b/homeassistant/components/shelly/button.py index ad03a373dba..2ab23441c98 100644 --- a/homeassistant/components/shelly/button.py +++ b/homeassistant/components/shelly/button.py @@ -237,12 +237,18 @@ class ShellyButton(ShellyBaseButton): self._attr_device_info = get_block_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, suggested_area=coordinator.suggested_area, ) else: self._attr_device_info = get_rpc_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, suggested_area=coordinator.suggested_area, ) self._attr_device_info = DeviceInfo( diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index abc387f3efd..2a09e867dce 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -213,6 +213,9 @@ class BlockSleepingClimate( self._attr_device_info = get_block_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, sensor_block, suggested_area=coordinator.suggested_area, ) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 18430da8841..eba6b846fe4 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -145,11 +145,21 @@ class ShellyCoordinatorBase[_DeviceT: BlockDevice | RpcDevice]( hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop) ) + @cached_property + def configuration_url(self) -> str: + """Return the configuration URL for the device.""" + return f"http://{get_host(self.config_entry.data[CONF_HOST])}:{get_http_port(self.config_entry.data)}" + @cached_property def model(self) -> str: """Model of the device.""" return cast(str, self.config_entry.data[CONF_MODEL]) + @cached_property + def model_name(self) -> str | None: + """Model name of the device.""" + return get_shelly_model_name(self.model, self.sleep_period, self.device) + @cached_property def mac(self) -> str: """Mac address of the device.""" @@ -175,11 +185,11 @@ class ShellyCoordinatorBase[_DeviceT: BlockDevice | RpcDevice]( connections={(CONNECTION_NETWORK_MAC, self.mac)}, identifiers={(DOMAIN, self.mac)}, manufacturer="Shelly", - model=get_shelly_model_name(self.model, self.sleep_period, self.device), + model=self.model_name, model_id=self.model, sw_version=self.sw_version, hw_version=f"gen{get_device_entry_gen(self.config_entry)}", - configuration_url=f"http://{get_host(self.config_entry.data[CONF_HOST])}:{get_http_port(self.config_entry.data)}", + configuration_url=self.configuration_url, ) # We want to use the main device area as the suggested area for sub-devices. if (area_id := device_entry.area_id) is not None: diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index b80ac877a84..33a45a0e10f 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -371,6 +371,9 @@ class ShellyBlockEntity(CoordinatorEntity[ShellyBlockCoordinator]): self._attr_device_info = get_block_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, block, suggested_area=coordinator.suggested_area, ) @@ -417,6 +420,9 @@ class ShellyRpcEntity(CoordinatorEntity[ShellyRpcCoordinator]): self._attr_device_info = get_rpc_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, key, suggested_area=coordinator.suggested_area, ) @@ -536,6 +542,9 @@ class ShellyRestAttributeEntity(CoordinatorEntity[ShellyBlockCoordinator]): self._attr_device_info = get_block_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, suggested_area=coordinator.suggested_area, ) self._last_value = None @@ -647,6 +656,9 @@ class ShellySleepingBlockAttributeEntity(ShellyBlockAttributeEntity): self._attr_device_info = get_block_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, block, suggested_area=coordinator.suggested_area, ) @@ -717,6 +729,9 @@ class ShellySleepingRpcAttributeEntity(ShellyRpcAttributeEntity): self._attr_device_info = get_rpc_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, key, suggested_area=coordinator.suggested_area, ) diff --git a/homeassistant/components/shelly/event.py b/homeassistant/components/shelly/event.py index 2eb9ff00964..9e1c748c790 100644 --- a/homeassistant/components/shelly/event.py +++ b/homeassistant/components/shelly/event.py @@ -209,6 +209,9 @@ class ShellyRpcEvent(CoordinatorEntity[ShellyRpcCoordinator], EventEntity): self._attr_device_info = get_rpc_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, key, suggested_area=coordinator.suggested_area, ) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index cefcbb86a98..cdfa97357f2 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -141,6 +141,9 @@ class RpcEmeterPhaseSensor(RpcSensor): self._attr_device_info = get_rpc_device_info( coordinator.device, coordinator.mac, + coordinator.configuration_url, + coordinator.model, + coordinator.model_name, key, emeter_phase=description.emeter_phase, suggested_area=coordinator.suggested_area, diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index 1af365debfb..2ee960348dd 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -749,6 +749,9 @@ async def get_rpc_scripts_event_types( def get_rpc_device_info( device: RpcDevice, mac: str, + configuration_url: str, + model: str, + model_name: str | None = None, key: str | None = None, emeter_phase: str | None = None, suggested_area: str | None = None, @@ -771,8 +774,11 @@ def get_rpc_device_info( identifiers={(DOMAIN, f"{mac}-{key}-{emeter_phase.lower()}")}, name=get_rpc_sub_device_name(device, key, emeter_phase), manufacturer="Shelly", + model=model_name, + model_id=model, suggested_area=suggested_area, via_device=(DOMAIN, mac), + configuration_url=configuration_url, ) if ( @@ -786,8 +792,11 @@ def get_rpc_device_info( identifiers={(DOMAIN, f"{mac}-{key}")}, name=get_rpc_sub_device_name(device, key), manufacturer="Shelly", + model=model_name, + model_id=model, suggested_area=suggested_area, via_device=(DOMAIN, mac), + configuration_url=configuration_url, ) @@ -810,6 +819,9 @@ def get_blu_trv_device_info( def get_block_device_info( device: BlockDevice, mac: str, + configuration_url: str, + model: str, + model_name: str | None = None, block: Block | None = None, suggested_area: str | None = None, ) -> DeviceInfo: @@ -826,8 +838,11 @@ def get_block_device_info( identifiers={(DOMAIN, f"{mac}-{block.description}")}, name=get_block_sub_device_name(device, block), manufacturer="Shelly", + model=model_name, + model_id=model, suggested_area=suggested_area, via_device=(DOMAIN, mac), + configuration_url=configuration_url, )