mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Use new ServiceInfo location in components (part 3) (#135687)
This commit is contained in:
parent
19a89ebcf3
commit
406c00997f
@ -12,7 +12,6 @@ import getmac
|
|||||||
from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator
|
from samsungtvws.encrypted.authenticator import SamsungTVEncryptedWSAsyncAuthenticator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp, ssdp, zeroconf
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigEntryState,
|
ConfigEntryState,
|
||||||
@ -32,6 +31,14 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.data_entry_flow import AbortFlow
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_MANUFACTURER,
|
||||||
|
ATTR_UPNP_MODEL_NAME,
|
||||||
|
ATTR_UPNP_UDN,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .bridge import SamsungTVBridge, async_get_device_info, mac_from_device_info
|
from .bridge import SamsungTVBridge, async_get_device_info, mac_from_device_info
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -439,11 +446,11 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
raise AbortFlow(RESULT_NOT_SUPPORTED)
|
raise AbortFlow(RESULT_NOT_SUPPORTED)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by ssdp discovery."""
|
"""Handle a flow initialized by ssdp discovery."""
|
||||||
LOGGER.debug("Samsung device found via SSDP: %s", discovery_info)
|
LOGGER.debug("Samsung device found via SSDP: %s", discovery_info)
|
||||||
model_name: str = discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME) or ""
|
model_name: str = discovery_info.upnp.get(ATTR_UPNP_MODEL_NAME) or ""
|
||||||
if discovery_info.ssdp_st == UPNP_SVC_RENDERING_CONTROL:
|
if discovery_info.ssdp_st == UPNP_SVC_RENDERING_CONTROL:
|
||||||
self._ssdp_rendering_control_location = discovery_info.ssdp_location
|
self._ssdp_rendering_control_location = discovery_info.ssdp_location
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
@ -456,12 +463,10 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"Set SSDP MainTvAgent location to: %s",
|
"Set SSDP MainTvAgent location to: %s",
|
||||||
self._ssdp_main_tv_agent_location,
|
self._ssdp_main_tv_agent_location,
|
||||||
)
|
)
|
||||||
self._udn = self._upnp_udn = _strip_uuid(
|
self._udn = self._upnp_udn = _strip_uuid(discovery_info.upnp[ATTR_UPNP_UDN])
|
||||||
discovery_info.upnp[ssdp.ATTR_UPNP_UDN]
|
|
||||||
)
|
|
||||||
if hostname := urlparse(discovery_info.ssdp_location or "").hostname:
|
if hostname := urlparse(discovery_info.ssdp_location or "").hostname:
|
||||||
self._host = hostname
|
self._host = hostname
|
||||||
self._manufacturer = discovery_info.upnp.get(ssdp.ATTR_UPNP_MANUFACTURER)
|
self._manufacturer = discovery_info.upnp.get(ATTR_UPNP_MANUFACTURER)
|
||||||
self._abort_if_manufacturer_is_not_samsung()
|
self._abort_if_manufacturer_is_not_samsung()
|
||||||
|
|
||||||
# Set defaults, in case they cannot be extracted from device_info
|
# Set defaults, in case they cannot be extracted from device_info
|
||||||
@ -486,7 +491,7 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by dhcp discovery."""
|
"""Handle a flow initialized by dhcp discovery."""
|
||||||
LOGGER.debug("Samsung device found via DHCP: %s", discovery_info)
|
LOGGER.debug("Samsung device found via DHCP: %s", discovery_info)
|
||||||
@ -498,7 +503,7 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by zeroconf discovery."""
|
"""Handle a flow initialized by zeroconf discovery."""
|
||||||
LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info)
|
LOGGER.debug("Samsung device found via ZEROCONF: %s", discovery_info)
|
||||||
|
@ -10,7 +10,6 @@ from screenlogicpy.const.common import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWA
|
|||||||
from screenlogicpy.requests import login
|
from screenlogicpy.requests import login
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -21,6 +20,7 @@ from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
|||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, MIN_SCAN_INTERVAL
|
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, MIN_SCAN_INTERVAL
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class ScreenlogicConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_step_gateway_select()
|
return await self.async_step_gateway_select()
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery."""
|
"""Handle dhcp discovery."""
|
||||||
mac = format_mac(discovery_info.macaddress)
|
mac = format_mac(discovery_info.macaddress)
|
||||||
|
@ -6,10 +6,10 @@ from typing import Any
|
|||||||
from pysmappee import helper, mqtt
|
from pysmappee import helper, mqtt
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS
|
from homeassistant.const import CONF_HOST, CONF_IP_ADDRESS
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -43,7 +43,7 @@ class SmappeeFlowHandler(
|
|||||||
return logging.getLogger(__name__)
|
return logging.getLogger(__name__)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ from pysmlight import Api2
|
|||||||
from pysmlight.exceptions import SmlightAuthError, SmlightConnectionError
|
from pysmlight.exceptions import SmlightAuthError, SmlightConnectionError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered Lan coordinator."""
|
"""Handle a discovered Lan coordinator."""
|
||||||
local_name = discovery_info.hostname[:-1]
|
local_name = discovery_info.hostname[:-1]
|
||||||
|
@ -9,9 +9,13 @@ from urllib.parse import urlparse
|
|||||||
from songpal import Device, SongpalException
|
from songpal import Device, SongpalException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_FRIENDLY_NAME,
|
||||||
|
ATTR_UPNP_UDN,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from .const import CONF_ENDPOINT, DOMAIN
|
from .const import CONF_ENDPOINT, DOMAIN
|
||||||
|
|
||||||
@ -99,15 +103,15 @@ class SongpalConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered Songpal device."""
|
"""Handle a discovered Songpal device."""
|
||||||
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
await self.async_set_unique_id(discovery_info.upnp[ATTR_UPNP_UDN])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
_LOGGER.debug("Discovered: %s", discovery_info)
|
_LOGGER.debug("Discovered: %s", discovery_info)
|
||||||
|
|
||||||
friendly_name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
friendly_name = discovery_info.upnp[ATTR_UPNP_FRIENDLY_NAME]
|
||||||
hostname = urlparse(discovery_info.ssdp_location).hostname
|
hostname = urlparse(discovery_info.ssdp_location).hostname
|
||||||
scalarweb_info = discovery_info.upnp["X_ScalarWebAPI_DeviceInfo"]
|
scalarweb_info = discovery_info.upnp["X_ScalarWebAPI_DeviceInfo"]
|
||||||
endpoint = scalarweb_info["X_ScalarWebAPI_BaseURL"]
|
endpoint = scalarweb_info["X_ScalarWebAPI_BaseURL"]
|
||||||
|
@ -10,7 +10,6 @@ from typing import TYPE_CHECKING, Any
|
|||||||
from pysqueezebox import Server, async_discover
|
from pysqueezebox import Server, async_discover
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||||
@ -18,6 +17,7 @@ from homeassistant.data_entry_flow import AbortFlow
|
|||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import CONF_HTTPS, DEFAULT_PORT, DOMAIN
|
from .const import CONF_HTTPS, DEFAULT_PORT, DOMAIN
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ class SqueezeboxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_step_edit()
|
return await self.async_step_edit()
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery of a Squeezebox player."""
|
"""Handle dhcp discovery of a Squeezebox player."""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
|
@ -9,12 +9,12 @@ from aiosteamist import Steamist
|
|||||||
from discovery30303 import Device30303, normalize_mac
|
from discovery30303 import Device30303, normalize_mac
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MODEL, CONF_NAME
|
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MODEL, CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
|
||||||
from .const import CONNECTION_EXCEPTIONS, DISCOVER_SCAN_TIMEOUT, DOMAIN
|
from .const import CONNECTION_EXCEPTIONS, DISCOVER_SCAN_TIMEOUT, DOMAIN
|
||||||
@ -41,7 +41,7 @@ class SteamistConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._discovered_device: Device30303 | None = None
|
self._discovered_device: Device30303 | None = None
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery via dhcp."""
|
"""Handle discovery via dhcp."""
|
||||||
self._discovered_device = Device30303(
|
self._discovered_device = Device30303(
|
||||||
|
@ -8,10 +8,15 @@ from pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported
|
|||||||
from url_normalize import url_normalize
|
from url_normalize import url_normalize
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME, CONF_URL
|
from homeassistant.const import CONF_NAME, CONF_URL
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_FRIENDLY_NAME,
|
||||||
|
ATTR_UPNP_PRESENTATION_URL,
|
||||||
|
ATTR_UPNP_UDN,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from .const import DEFAULT_MODEL, DEFAULT_NAME_TEMPLATE, DOMAIN
|
from .const import DEFAULT_MODEL, DEFAULT_NAME_TEMPLATE, DOMAIN
|
||||||
|
|
||||||
@ -33,15 +38,15 @@ class SyncThruConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self._async_check_and_create("user", user_input)
|
return await self._async_check_and_create("user", user_input)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle SSDP initiated flow."""
|
"""Handle SSDP initiated flow."""
|
||||||
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
|
await self.async_set_unique_id(discovery_info.upnp[ATTR_UPNP_UDN])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
self.url = url_normalize(
|
self.url = url_normalize(
|
||||||
discovery_info.upnp.get(
|
discovery_info.upnp.get(
|
||||||
ssdp.ATTR_UPNP_PRESENTATION_URL,
|
ATTR_UPNP_PRESENTATION_URL,
|
||||||
f"http://{urlparse(discovery_info.ssdp_location or '').hostname}/",
|
f"http://{urlparse(discovery_info.ssdp_location or '').hostname}/",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -52,11 +57,11 @@ class SyncThruConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
# Update unique id of entry with the same URL
|
# Update unique id of entry with the same URL
|
||||||
if not existing_entry.unique_id:
|
if not existing_entry.unique_id:
|
||||||
self.hass.config_entries.async_update_entry(
|
self.hass.config_entries.async_update_entry(
|
||||||
existing_entry, unique_id=discovery_info.upnp[ssdp.ATTR_UPNP_UDN]
|
existing_entry, unique_id=discovery_info.upnp[ATTR_UPNP_UDN]
|
||||||
)
|
)
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
self.name = discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "")
|
self.name = discovery_info.upnp.get(ATTR_UPNP_FRIENDLY_NAME, "")
|
||||||
if self.name:
|
if self.name:
|
||||||
# Remove trailing " (ip)" if present for consistency with user driven config
|
# Remove trailing " (ip)" if present for consistency with user driven config
|
||||||
self.name = re.sub(r"\s+\([\d.]+\)\s*$", "", self.name)
|
self.name = re.sub(r"\s+\([\d.]+\)\s*$", "", self.name)
|
||||||
|
@ -18,7 +18,6 @@ from synology_dsm.exceptions import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp, zeroconf
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -41,6 +40,12 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_FRIENDLY_NAME,
|
||||||
|
ATTR_UPNP_SERIAL,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType, VolDictType
|
from homeassistant.helpers.typing import DiscoveryInfoType, VolDictType
|
||||||
from homeassistant.util.network import is_ip_address as is_ip
|
from homeassistant.util.network import is_ip_address as is_ip
|
||||||
|
|
||||||
@ -243,7 +248,7 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_validate_input_create_entry(user_input, step_id=step)
|
return await self.async_validate_input_create_entry(user_input, step_id=step)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered synology_dsm via zeroconf."""
|
"""Handle a discovered synology_dsm via zeroconf."""
|
||||||
discovered_macs = [
|
discovered_macs = [
|
||||||
@ -258,13 +263,13 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self._async_from_discovery(host, friendly_name, discovered_macs)
|
return await self._async_from_discovery(host, friendly_name, discovered_macs)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered synology_dsm via ssdp."""
|
"""Handle a discovered synology_dsm via ssdp."""
|
||||||
parsed_url = urlparse(discovery_info.ssdp_location)
|
parsed_url = urlparse(discovery_info.ssdp_location)
|
||||||
upnp_friendly_name: str = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]
|
upnp_friendly_name: str = discovery_info.upnp[ATTR_UPNP_FRIENDLY_NAME]
|
||||||
friendly_name = upnp_friendly_name.split("(", 1)[0].strip()
|
friendly_name = upnp_friendly_name.split("(", 1)[0].strip()
|
||||||
mac_address = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]
|
mac_address = discovery_info.upnp[ATTR_UPNP_SERIAL]
|
||||||
discovered_macs = [format_synology_mac(mac_address)]
|
discovered_macs = [format_synology_mac(mac_address)]
|
||||||
# Synology NAS can broadcast on multiple IP addresses, since they can be connected to multiple ethernets.
|
# Synology NAS can broadcast on multiple IP addresses, since they can be connected to multiple ethernets.
|
||||||
# The serial of the NAS is actually its MAC address.
|
# The serial of the NAS is actually its MAC address.
|
||||||
|
@ -16,13 +16,13 @@ from systembridgeconnector.websocket_client import WebSocketClient
|
|||||||
from systembridgemodels.modules import GetData, Module
|
from systembridgemodels.modules import GetData, Module
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DATA_WAIT_TIMEOUT, DOMAIN
|
from .const import DATA_WAIT_TIMEOUT, DOMAIN
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ class SystemBridgeConfigFlow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
properties = discovery_info.properties
|
properties = discovery_info.properties
|
||||||
|
@ -10,7 +10,6 @@ from PyTado.interface import Tado
|
|||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -20,6 +19,10 @@ from homeassistant.config_entries import (
|
|||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import (
|
||||||
|
ATTR_PROPERTIES_ID,
|
||||||
|
ZeroconfServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_FALLBACK,
|
CONF_FALLBACK,
|
||||||
@ -104,14 +107,14 @@ class TadoConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle HomeKit discovery."""
|
"""Handle HomeKit discovery."""
|
||||||
self._async_abort_entries_match()
|
self._async_abort_entries_match()
|
||||||
properties = {
|
properties = {
|
||||||
key.lower(): value for (key, value) in discovery_info.properties.items()
|
key.lower(): value for (key, value) in discovery_info.properties.items()
|
||||||
}
|
}
|
||||||
await self.async_set_unique_id(properties[zeroconf.ATTR_PROPERTIES_ID])
|
await self.async_set_unique_id(properties[ATTR_PROPERTIES_ID])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ from gotailwind import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import AbortFlow
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
@ -27,6 +26,7 @@ from homeassistant.helpers.selector import (
|
|||||||
TextSelectorType,
|
TextSelectorType,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery of a Tailwind device."""
|
"""Handle zeroconf discovery of a Tailwind device."""
|
||||||
if not (device_id := discovery_info.properties.get("device_id")):
|
if not (device_id := discovery_info.properties.get("device_id")):
|
||||||
|
@ -5,10 +5,11 @@ from typing import Any
|
|||||||
from technove import Station as TechnoVEStation, TechnoVE, TechnoVEConnectionError
|
from technove import Station as TechnoVEStation, TechnoVE, TechnoVEConnectionError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import onboarding, zeroconf
|
from homeassistant.components import onboarding
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ class TechnoVEConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Abort quick if the device with provided mac is already configured
|
# Abort quick if the device with provided mac is already configured
|
||||||
|
@ -4,8 +4,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components import onboarding, zeroconf
|
from homeassistant.components import onboarding
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ class ThreadConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_create_entry(title="Thread", data={})
|
return self.async_create_entry(title="Thread", data={})
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Set up because the user has border routers."""
|
"""Set up because the user has border routers."""
|
||||||
await self._async_handle_discovery_without_unique_id()
|
await self._async_handle_discovery_without_unique_id()
|
||||||
|
@ -8,10 +8,10 @@ from typing import Any
|
|||||||
from tololib import ToloClient, ToloCommunicationError
|
from tololib import ToloClient, ToloCommunicationError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by discovery."""
|
"""Handle a flow initialized by discovery."""
|
||||||
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
await self.async_set_unique_id(format_mac(discovery_info.macaddress))
|
||||||
|
@ -10,10 +10,13 @@ from pytradfri import Gateway, RequestError
|
|||||||
from pytradfri.api.aiocoap_api import APIFactory
|
from pytradfri.api.aiocoap_api import APIFactory
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import (
|
||||||
|
ATTR_PROPERTIES_ID,
|
||||||
|
ZeroconfServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from .const import CONF_GATEWAY_ID, CONF_IDENTITY, CONF_KEY, DOMAIN
|
from .const import CONF_GATEWAY_ID, CONF_IDENTITY, CONF_KEY, DOMAIN
|
||||||
|
|
||||||
@ -78,12 +81,10 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle homekit discovery."""
|
"""Handle homekit discovery."""
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(discovery_info.properties[ATTR_PROPERTIES_ID])
|
||||||
discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID]
|
|
||||||
)
|
|
||||||
self._abort_if_unique_id_configured({CONF_HOST: discovery_info.host})
|
self._abort_if_unique_id_configured({CONF_HOST: discovery_info.host})
|
||||||
|
|
||||||
host = discovery_info.host
|
host = discovery_info.host
|
||||||
@ -96,7 +97,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
if not entry.unique_id:
|
if not entry.unique_id:
|
||||||
self.hass.config_entries.async_update_entry(
|
self.hass.config_entries.async_update_entry(
|
||||||
entry,
|
entry,
|
||||||
unique_id=discovery_info.properties[zeroconf.ATTR_PROPERTIES_ID],
|
unique_id=discovery_info.properties[ATTR_PROPERTIES_ID],
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
|
@ -9,10 +9,10 @@ from aiohttp import ClientError
|
|||||||
from ttls.client import Twinkly
|
from ttls.client import Twinkly
|
||||||
from voluptuous import Required, Schema
|
from voluptuous import Required, Schema
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import DEV_ID, DEV_MODEL, DEV_NAME, DOMAIN
|
from .const import DEV_ID, DEV_MODEL, DEV_NAME, DOMAIN
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class TwinklyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle dhcp discovery for twinkly."""
|
"""Handle dhcp discovery for twinkly."""
|
||||||
self._async_abort_entries_match({CONF_HOST: discovery_info.ip})
|
self._async_abort_entries_match({CONF_HOST: discovery_info.ip})
|
||||||
|
@ -18,7 +18,6 @@ from urllib.parse import urlparse
|
|||||||
from aiounifi.interfaces.sites import Sites
|
from aiounifi.interfaces.sites import Sites
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_REAUTH,
|
SOURCE_REAUTH,
|
||||||
ConfigEntryState,
|
ConfigEntryState,
|
||||||
@ -36,6 +35,11 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_MODEL_DESCRIPTION,
|
||||||
|
ATTR_UPNP_SERIAL,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from . import UnifiConfigEntry
|
from . import UnifiConfigEntry
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -212,12 +216,12 @@ class UnifiFlowHandler(ConfigFlow, domain=UNIFI_DOMAIN):
|
|||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered UniFi device."""
|
"""Handle a discovered UniFi device."""
|
||||||
parsed_url = urlparse(discovery_info.ssdp_location)
|
parsed_url = urlparse(discovery_info.ssdp_location)
|
||||||
model_description = discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_DESCRIPTION]
|
model_description = discovery_info.upnp[ATTR_UPNP_MODEL_DESCRIPTION]
|
||||||
mac_address = format_mac(discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL])
|
mac_address = format_mac(discovery_info.upnp[ATTR_UPNP_SERIAL])
|
||||||
|
|
||||||
self.config = {
|
self.config = {
|
||||||
CONF_HOST: parsed_url.hostname,
|
CONF_HOST: parsed_url.hostname,
|
||||||
|
@ -14,7 +14,6 @@ from uiprotect.exceptions import ClientError, NotAuthorized
|
|||||||
from unifi_discovery import async_console_is_alive
|
from unifi_discovery import async_console_is_alive
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp, ssdp
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_IGNORE,
|
SOURCE_IGNORE,
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
@ -36,6 +35,8 @@ from homeassistant.helpers.aiohttp_client import (
|
|||||||
async_create_clientsession,
|
async_create_clientsession,
|
||||||
async_get_clientsession,
|
async_get_clientsession,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
|
||||||
from homeassistant.helpers.storage import STORAGE_DIR
|
from homeassistant.helpers.storage import STORAGE_DIR
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
from homeassistant.loader import async_get_integration
|
from homeassistant.loader import async_get_integration
|
||||||
@ -107,14 +108,14 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self._discovered_device: dict[str, str] = {}
|
self._discovered_device: dict[str, str] = {}
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery via dhcp."""
|
"""Handle discovery via dhcp."""
|
||||||
_LOGGER.debug("Starting discovery via: %s", discovery_info)
|
_LOGGER.debug("Starting discovery via: %s", discovery_info)
|
||||||
return await self._async_discovery_handoff()
|
return await self._async_discovery_handoff()
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered UniFi device."""
|
"""Handle a discovered UniFi device."""
|
||||||
_LOGGER.debug("Starting discovery via: %s", discovery_info)
|
_LOGGER.debug("Starting discovery via: %s", discovery_info)
|
||||||
|
@ -8,9 +8,9 @@ import velbusaio.controller
|
|||||||
from velbusaio.exceptions import VelbusConnectionFailed
|
from velbusaio.exceptions import VelbusConnectionFailed
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import usb
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_NAME, CONF_PORT
|
||||||
|
from homeassistant.helpers.service_info.usb import UsbServiceInfo
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
@ -69,9 +69,7 @@ class VelbusConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors=self._errors,
|
errors=self._errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_usb(
|
async def async_step_usb(self, discovery_info: UsbServiceInfo) -> ConfigFlowResult:
|
||||||
self, discovery_info: usb.UsbServiceInfo
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Handle USB Discovery."""
|
"""Handle USB Discovery."""
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}"
|
f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}"
|
||||||
|
@ -12,11 +12,11 @@ from PyViCare.PyViCareUtils import (
|
|||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_HEATING_TYPE,
|
CONF_HEATING_TYPE,
|
||||||
@ -109,7 +109,7 @@ class ViCareConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Invoke when a Viessmann MAC address is discovered on the network."""
|
"""Invoke when a Viessmann MAC address is discovered on the network."""
|
||||||
formatted_mac = format_mac(discovery_info.macaddress)
|
formatted_mac = format_mac(discovery_info.macaddress)
|
||||||
|
@ -11,7 +11,6 @@ from pyvizio import VizioAsync, async_guess_device_type
|
|||||||
from pyvizio.const import APP_HOME
|
from pyvizio.const import APP_HOME
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.components.media_player import MediaPlayerDeviceClass
|
from homeassistant.components.media_player import MediaPlayerDeviceClass
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
@ -32,6 +31,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
from homeassistant.util.network import is_ip_address
|
from homeassistant.util.network import is_ip_address
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -257,7 +257,7 @@ class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
|
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
host = discovery_info.host
|
host = discovery_info.host
|
||||||
|
@ -8,12 +8,12 @@ from typing import Any
|
|||||||
from pyvolumio import CannotConnectError, Volumio
|
from pyvolumio import CannotConnectError, Volumio
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class VolumioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
self._host = discovery_info.host
|
self._host = discovery_info.host
|
||||||
|
@ -9,7 +9,6 @@ from urllib.parse import urlparse
|
|||||||
from aiowebostv import WebOsTvPairError
|
from aiowebostv import WebOsTvPairError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -19,6 +18,11 @@ from homeassistant.config_entries import (
|
|||||||
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST
|
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_FRIENDLY_NAME,
|
||||||
|
ATTR_UPNP_UDN,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from . import async_control_connect
|
from . import async_control_connect
|
||||||
from .const import CONF_SOURCES, DEFAULT_NAME, DOMAIN, WEBOSTV_EXCEPTIONS
|
from .const import CONF_SOURCES, DEFAULT_NAME, DOMAIN, WEBOSTV_EXCEPTIONS
|
||||||
@ -89,7 +93,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(step_id="pairing", errors=errors)
|
return self.async_show_form(step_id="pairing", errors=errors)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by discovery."""
|
"""Handle a flow initialized by discovery."""
|
||||||
assert discovery_info.ssdp_location
|
assert discovery_info.ssdp_location
|
||||||
@ -97,10 +101,10 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
assert host
|
assert host
|
||||||
self._host = host
|
self._host = host
|
||||||
self._name = discovery_info.upnp.get(
|
self._name = discovery_info.upnp.get(
|
||||||
ssdp.ATTR_UPNP_FRIENDLY_NAME, DEFAULT_NAME
|
ATTR_UPNP_FRIENDLY_NAME, DEFAULT_NAME
|
||||||
).replace("[LG]", "LG")
|
).replace("[LG]", "LG")
|
||||||
|
|
||||||
uuid = discovery_info.upnp[ssdp.ATTR_UPNP_UDN]
|
uuid = discovery_info.upnp[ATTR_UPNP_UDN]
|
||||||
assert uuid
|
assert uuid
|
||||||
uuid = uuid.removeprefix("uuid:")
|
uuid = uuid.removeprefix("uuid:")
|
||||||
await self.async_set_unique_id(uuid)
|
await self.async_set_unique_id(uuid)
|
||||||
|
@ -5,9 +5,15 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import pywilight
|
import pywilight
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
|
from homeassistant.helpers.service_info.ssdp import (
|
||||||
|
ATTR_UPNP_MANUFACTURER,
|
||||||
|
ATTR_UPNP_MODEL_NAME,
|
||||||
|
ATTR_UPNP_MODEL_NUMBER,
|
||||||
|
ATTR_UPNP_SERIAL,
|
||||||
|
SsdpServiceInfo,
|
||||||
|
)
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -53,25 +59,25 @@ class WiLightFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_create_entry(title=self._title, data=data)
|
return self.async_create_entry(title=self._title, data=data)
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a discovered WiLight."""
|
"""Handle a discovered WiLight."""
|
||||||
# Filter out basic information
|
# Filter out basic information
|
||||||
if (
|
if (
|
||||||
not discovery_info.ssdp_location
|
not discovery_info.ssdp_location
|
||||||
or ssdp.ATTR_UPNP_MANUFACTURER not in discovery_info.upnp
|
or ATTR_UPNP_MANUFACTURER not in discovery_info.upnp
|
||||||
or ssdp.ATTR_UPNP_SERIAL not in discovery_info.upnp
|
or ATTR_UPNP_SERIAL not in discovery_info.upnp
|
||||||
or ssdp.ATTR_UPNP_MODEL_NAME not in discovery_info.upnp
|
or ATTR_UPNP_MODEL_NAME not in discovery_info.upnp
|
||||||
or ssdp.ATTR_UPNP_MODEL_NUMBER not in discovery_info.upnp
|
or ATTR_UPNP_MODEL_NUMBER not in discovery_info.upnp
|
||||||
):
|
):
|
||||||
return self.async_abort(reason="not_wilight_device")
|
return self.async_abort(reason="not_wilight_device")
|
||||||
# Filter out non-WiLight devices
|
# Filter out non-WiLight devices
|
||||||
if discovery_info.upnp[ssdp.ATTR_UPNP_MANUFACTURER] != WILIGHT_MANUFACTURER:
|
if discovery_info.upnp[ATTR_UPNP_MANUFACTURER] != WILIGHT_MANUFACTURER:
|
||||||
return self.async_abort(reason="not_wilight_device")
|
return self.async_abort(reason="not_wilight_device")
|
||||||
|
|
||||||
host = urlparse(discovery_info.ssdp_location).hostname
|
host = urlparse(discovery_info.ssdp_location).hostname
|
||||||
serial_number = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]
|
serial_number = discovery_info.upnp[ATTR_UPNP_SERIAL]
|
||||||
model_name = discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_NAME]
|
model_name = discovery_info.upnp[ATTR_UPNP_MODEL_NAME]
|
||||||
|
|
||||||
if not self._wilight_update(host, serial_number, model_name):
|
if not self._wilight_update(host, serial_number, model_name):
|
||||||
return self.async_abort(reason="not_wilight_device")
|
return self.async_abort(reason="not_wilight_device")
|
||||||
|
@ -10,10 +10,11 @@ from pywizlight.discovery import DiscoveredBulb
|
|||||||
from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError
|
from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import dhcp, onboarding
|
from homeassistant.components import onboarding
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.data_entry_flow import AbortFlow
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
from homeassistant.util.network import is_ip_address
|
from homeassistant.util.network import is_ip_address
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DISCOVER_SCAN_TIMEOUT, DOMAIN, WIZ_CONNECT_EXCEPTIONS
|
from .const import DEFAULT_NAME, DISCOVER_SCAN_TIMEOUT, DOMAIN, WIZ_CONNECT_EXCEPTIONS
|
||||||
@ -38,7 +39,7 @@ class WizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._discovered_devices: dict[str, DiscoveredBulb] = {}
|
self._discovered_devices: dict[str, DiscoveredBulb] = {}
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery via dhcp."""
|
"""Handle discovery via dhcp."""
|
||||||
self._discovered_device = DiscoveredBulb(
|
self._discovered_device = DiscoveredBulb(
|
||||||
|
@ -7,7 +7,7 @@ from typing import Any
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from wled import WLED, Device, WLEDConnectionError
|
from wled import WLED, Device, WLEDConnectionError
|
||||||
|
|
||||||
from homeassistant.components import onboarding, zeroconf
|
from homeassistant.components import onboarding
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -17,6 +17,7 @@ from homeassistant.config_entries import (
|
|||||||
from homeassistant.const import CONF_HOST, CONF_MAC
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT, DOMAIN
|
from .const import CONF_KEEP_MAIN_LIGHT, DEFAULT_KEEP_MAIN_LIGHT, DOMAIN
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
# Abort quick if the mac address is provided by discovery info
|
# Abort quick if the mac address is provided by discovery info
|
||||||
|
@ -8,10 +8,10 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import SOURCE_HASSIO, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_HASSIO, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
from homeassistant.helpers.service_info.hassio import HassioServiceInfo
|
from homeassistant.helpers.service_info.hassio import HassioServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .data import WyomingService
|
from .data import WyomingService
|
||||||
@ -117,7 +117,7 @@ class WyomingConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
_LOGGER.debug("Zeroconf discovery info: %s", discovery_info)
|
_LOGGER.debug("Zeroconf discovery info: %s", discovery_info)
|
||||||
|
@ -7,11 +7,11 @@ from typing import Any
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from xiaomi_gateway import MULTICAST_PORT, XiaomiGateway, XiaomiGatewayDiscovery
|
from xiaomi_gateway import MULTICAST_PORT, XiaomiGateway, XiaomiGatewayDiscovery
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL
|
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_INTERFACE,
|
CONF_INTERFACE,
|
||||||
@ -153,7 +153,7 @@ class XiaomiAqaraFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
name = discovery_info.name
|
name = discovery_info.name
|
||||||
|
@ -11,7 +11,6 @@ from micloud import MiCloud
|
|||||||
from micloud.micloudexception import MiCloudAccessDenied
|
from micloud.micloudexception import MiCloudAccessDenied
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -21,6 +20,7 @@ from homeassistant.config_entries import (
|
|||||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MAC, CONF_MODEL, CONF_TOKEN
|
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MAC, CONF_MODEL, CONF_TOKEN
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_CLOUD_COUNTRY,
|
CONF_CLOUD_COUNTRY,
|
||||||
@ -145,7 +145,7 @@ class XiaomiMiioFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self.async_step_cloud()
|
return await self.async_step_cloud()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
name = discovery_info.name
|
name = discovery_info.name
|
||||||
|
@ -11,7 +11,7 @@ import yeelight
|
|||||||
from yeelight.aio import AsyncBulb
|
from yeelight.aio import AsyncBulb
|
||||||
from yeelight.main import get_known_models
|
from yeelight.main import get_known_models
|
||||||
|
|
||||||
from homeassistant.components import dhcp, onboarding, ssdp, zeroconf
|
from homeassistant.components import onboarding
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigEntryState,
|
ConfigEntryState,
|
||||||
@ -23,6 +23,9 @@ from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_MODEL, CON
|
|||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
|
||||||
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
from homeassistant.helpers.typing import VolDictType
|
from homeassistant.helpers.typing import VolDictType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -69,21 +72,21 @@ class YeelightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._discovered_devices: dict[str, Any] = {}
|
self._discovered_devices: dict[str, Any] = {}
|
||||||
|
|
||||||
async def async_step_homekit(
|
async def async_step_homekit(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery from homekit."""
|
"""Handle discovery from homekit."""
|
||||||
self._discovered_ip = discovery_info.host
|
self._discovered_ip = discovery_info.host
|
||||||
return await self._async_handle_discovery()
|
return await self._async_handle_discovery()
|
||||||
|
|
||||||
async def async_step_dhcp(
|
async def async_step_dhcp(
|
||||||
self, discovery_info: dhcp.DhcpServiceInfo
|
self, discovery_info: DhcpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery from dhcp."""
|
"""Handle discovery from dhcp."""
|
||||||
self._discovered_ip = discovery_info.ip
|
self._discovered_ip = discovery_info.ip
|
||||||
return await self._async_handle_discovery()
|
return await self._async_handle_discovery()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery from zeroconf."""
|
"""Handle discovery from zeroconf."""
|
||||||
self._discovered_ip = discovery_info.host
|
self._discovered_ip = discovery_info.host
|
||||||
@ -91,7 +94,7 @@ class YeelightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return await self._async_handle_discovery_with_unique_id()
|
return await self._async_handle_discovery_with_unique_id()
|
||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: SsdpServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle discovery from ssdp."""
|
"""Handle discovery from ssdp."""
|
||||||
self._discovered_ip = urlparse(discovery_info.ssdp_headers["location"]).hostname
|
self._discovered_ip = urlparse(discovery_info.ssdp_headers["location"]).hostname
|
||||||
|
Loading…
x
Reference in New Issue
Block a user