diff --git a/homeassistant/components/dnsip/__init__.py b/homeassistant/components/dnsip/__init__.py index 2f20f18580e..f679fb4ad30 100644 --- a/homeassistant/components/dnsip/__init__.py +++ b/homeassistant/components/dnsip/__init__.py @@ -1,15 +1,11 @@ """The dnsip component.""" from __future__ import annotations -import logging - from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from .const import PLATFORMS -_LOGGER = logging.getLogger(__name__) - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up DNS IP from a config entry.""" diff --git a/homeassistant/components/dnsip/config_flow.py b/homeassistant/components/dnsip/config_flow.py index 2db0034b697..a5b51f06a45 100644 --- a/homeassistant/components/dnsip/config_flow.py +++ b/homeassistant/components/dnsip/config_flow.py @@ -82,14 +82,6 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Return Option handler.""" return DnsIPOptionsFlowHandler(config_entry) - async def async_step_import(self, config: dict[str, Any]) -> FlowResult: - """Import a configuration from config.yaml.""" - - hostname = config.get(CONF_HOSTNAME, DEFAULT_HOSTNAME) - self._async_abort_entries_match({CONF_HOSTNAME: hostname}) - config[CONF_HOSTNAME] = hostname - return await self.async_step_user(user_input=config) - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: diff --git a/homeassistant/components/dnsip/sensor.py b/homeassistant/components/dnsip/sensor.py index 7dfc3aaa544..a770afe388d 100644 --- a/homeassistant/components/dnsip/sensor.py +++ b/homeassistant/components/dnsip/sensor.py @@ -6,20 +6,14 @@ import logging import aiodns from aiodns.error import DNSError -import voluptuous as vol -from homeassistant.components.sensor import ( - PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA, - SensorEntity, -) -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.components.sensor import SensorEntity +from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import ( CONF_HOSTNAME, @@ -27,10 +21,6 @@ from .const import ( CONF_IPV6, CONF_RESOLVER, CONF_RESOLVER_IPV6, - DEFAULT_HOSTNAME, - DEFAULT_IPV6, - DEFAULT_RESOLVER, - DEFAULT_RESOLVER_IPV6, DOMAIN, ) @@ -38,38 +28,6 @@ _LOGGER = logging.getLogger(__name__) SCAN_INTERVAL = timedelta(seconds=120) -PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend( - { - vol.Optional(CONF_NAME): cv.string, - vol.Optional(CONF_HOSTNAME, default=DEFAULT_HOSTNAME): cv.string, - vol.Optional(CONF_RESOLVER, default=DEFAULT_RESOLVER): cv.string, - vol.Optional(CONF_RESOLVER_IPV6, default=DEFAULT_RESOLVER_IPV6): cv.string, - vol.Optional(CONF_IPV6, default=DEFAULT_IPV6): cv.boolean, - } -) - - -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_devices: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the DNS IP sensor.""" - _LOGGER.warning( - "Configuration of the DNS IP platform in YAML is deprecated and will be " - "removed in Home Assistant 2022.4; Your existing configuration " - "has been imported into the UI automatically and can be safely removed " - "from your configuration.yaml file" - ) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=config, - ) - ) - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback diff --git a/tests/components/dnsip/test_config_flow.py b/tests/components/dnsip/test_config_flow.py index f4684eb1cc4..51e169b8bb5 100644 --- a/tests/components/dnsip/test_config_flow.py +++ b/tests/components/dnsip/test_config_flow.py @@ -146,66 +146,6 @@ async def test_form_error(hass: HomeAssistant) -> None: assert result2["errors"] == {"base": "invalid_hostname"} -@pytest.mark.parametrize( - "p_input,p_output,p_options", - [ - ( - {CONF_HOSTNAME: "home-assistant.io"}, - { - "hostname": "home-assistant.io", - "name": "home-assistant.io", - "ipv4": True, - "ipv6": True, - }, - { - "resolver": "208.67.222.222", - "resolver_ipv6": "2620:0:ccc::2", - }, - ), - ( - {}, - { - "hostname": "myip.opendns.com", - "name": "myip", - "ipv4": True, - "ipv6": True, - }, - { - "resolver": "208.67.222.222", - "resolver_ipv6": "2620:0:ccc::2", - }, - ), - ], -) -async def test_import_flow_success( - hass: HomeAssistant, - p_input: dict[str, str], - p_output: dict[str, str], - p_options: dict[str, str], -) -> None: - """Test a successful import of YAML.""" - - with patch( - "homeassistant.components.dnsip.config_flow.aiodns.DNSResolver", - return_value=RetrieveDNS(), - ), patch( - "homeassistant.components.dnsip.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=p_input, - ) - await hass.async_block_till_done() - - assert result2["type"] == RESULT_TYPE_CREATE_ENTRY - assert result2["title"] == p_output["name"] - assert result2["data"] == p_output - assert result2["options"] == p_options - assert len(mock_setup_entry.mock_calls) == 1 - - async def test_flow_already_exist(hass: HomeAssistant) -> None: """Test flow when unique id already exist."""