From 405effcf666bb511550eee58ca889503463d87bf Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 6 Nov 2026 11:30:39 +0100 Subject: [PATCH] Use typed config entry in shelly (#190841) Co-authored-by: Claude --- homeassistant/components/shelly/utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index da84bec59e36..f2848974b011 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -33,7 +33,6 @@ from yarl import URL from homeassistant.components import network from homeassistant.components.http import HomeAssistantView from homeassistant.components.network import async_get_source_ip -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_MODEL, CONF_PORT, EVENT_HOMEASSISTANT_STOP from homeassistant.core import Event, HomeAssistant, callback from homeassistant.helpers import ( @@ -81,6 +80,9 @@ from .const import ( All_LIGHT_TYPES, ) +if TYPE_CHECKING: + from .coordinator import ShellyConfigEntry + @callback def async_remove_shelly_entity( @@ -459,7 +461,7 @@ def get_rpc_sub_device_name( return f"{component.title()} {component_id}" -def get_device_entry_gen(entry: ConfigEntry) -> int: +def get_device_entry_gen(entry: ShellyConfigEntry) -> int: """Return the device generation from config entry.""" return entry.data.get(CONF_GEN, 1) # type: ignore[no-any-return] @@ -547,7 +549,7 @@ def get_rpc_input_triggers(device: RpcDevice) -> list[tuple[str, str]]: @callback def update_device_fw_info( - hass: HomeAssistant, shellydevice: BlockDevice | RpcDevice, entry: ConfigEntry + hass: HomeAssistant, shellydevice: BlockDevice | RpcDevice, entry: ShellyConfigEntry ) -> None: """Update the firmware version information in the device registry.""" assert entry.unique_id @@ -941,7 +943,7 @@ def get_block_device_info( @callback def remove_stale_blu_trv_devices( - hass: HomeAssistant, rpc_device: RpcDevice, entry: ConfigEntry + hass: HomeAssistant, rpc_device: RpcDevice, entry: ShellyConfigEntry ) -> None: """Remove stale BLU TRV devices.""" dev_reg = dr.async_get(hass) @@ -972,7 +974,7 @@ def remove_stale_blu_trv_devices( @callback -def remove_empty_sub_devices(hass: HomeAssistant, entry: ConfigEntry) -> None: +def remove_empty_sub_devices(hass: HomeAssistant, entry: ShellyConfigEntry) -> None: """Remove sub devices without entities.""" dev_reg = dr.async_get(hass) entity_reg = er.async_get(hass) @@ -1055,9 +1057,9 @@ def async_migrate_rpc_virtual_components_unique_ids( return None -def is_rpc_ble_scanner_supported(entry: ConfigEntry) -> bool: +def is_rpc_ble_scanner_supported(entry: ShellyConfigEntry) -> bool: """Return true if BLE scanner is supported.""" - return ( + return bool( entry.runtime_data.rpc_supports_scripts and not entry.runtime_data.rpc_zigbee_firmware ) @@ -1098,7 +1100,7 @@ async def check_coiot_config(device: BlockDevice, hass: HomeAssistant) -> bool: async def async_manage_coiot_issues_task( - hass: HomeAssistant, entry: ConfigEntry + hass: HomeAssistant, entry: ShellyConfigEntry ) -> None: """CoIoT configuration or push updates issues task.""" config_issue_id = COIOT_UNCONFIGURED_ISSUE_ID.format(unique=entry.unique_id)