diff --git a/homeassistant/components/sabnzbd/__init__.py b/homeassistant/components/sabnzbd/__init__.py index 37d6f54e405..3383c41059f 100644 --- a/homeassistant/components/sabnzbd/__init__.py +++ b/homeassistant/components/sabnzbd/__init__.py @@ -23,12 +23,13 @@ from homeassistant.const import ( DATA_RATE_MEGABYTES_PER_SECOND, Platform, ) -from homeassistant.core import ServiceCall, callback +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import discovery from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.json import load_json, save_json _LOGGER = logging.getLogger(__name__) @@ -197,11 +198,13 @@ async def async_configure_sabnzbd( async_request_configuration(hass, config, base_url, web_root) -async def async_setup(hass, config): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the SABnzbd component.""" - async def sabnzbd_discovered(service, info): + async def sabnzbd_discovered(service: str, info: DiscoveryInfoType | None) -> None: """Handle service discovery.""" + if not info: + return ssl = info.get("properties", {}).get("https", "0") == "1" await async_configure_sabnzbd(hass, info, ssl) diff --git a/homeassistant/helpers/discovery.py b/homeassistant/helpers/discovery.py index 63f6c3395e9..ed90b5b893b 100644 --- a/homeassistant/helpers/discovery.py +++ b/homeassistant/helpers/discovery.py @@ -7,12 +7,11 @@ There are two different types of discoveries that can be fired/listened for. """ from __future__ import annotations -from collections.abc import Callable +from collections.abc import Awaitable, Callable from typing import Any, TypedDict from homeassistant import core, setup from homeassistant.const import Platform -from homeassistant.core import CALLBACK_TYPE from homeassistant.loader import bind_hass from .dispatcher import async_dispatcher_connect, async_dispatcher_send @@ -37,7 +36,7 @@ class DiscoveryDict(TypedDict): def async_listen( hass: core.HomeAssistant, service: str, - callback: CALLBACK_TYPE, + callback: Callable[[str, DiscoveryInfoType | None], Awaitable[None] | None], ) -> None: """Set up listener for discovery of specific service.