Clean up upnp YAML config (#56200)
* Put back local_ip option to config schema + deprecate config schema * More cleanup * Remove log Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
0a426b5686
commit
30c25d4448
2 changed files with 17 additions and 11 deletions
|
@ -5,6 +5,7 @@ import asyncio
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from ipaddress import ip_address
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -18,6 +19,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
|
@ -25,13 +27,13 @@ from homeassistant.helpers.update_coordinator import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
CONF_LOCAL_IP,
|
||||||
CONFIG_ENTRY_HOSTNAME,
|
CONFIG_ENTRY_HOSTNAME,
|
||||||
CONFIG_ENTRY_SCAN_INTERVAL,
|
CONFIG_ENTRY_SCAN_INTERVAL,
|
||||||
CONFIG_ENTRY_ST,
|
CONFIG_ENTRY_ST,
|
||||||
CONFIG_ENTRY_UDN,
|
CONFIG_ENTRY_UDN,
|
||||||
DEFAULT_SCAN_INTERVAL,
|
DEFAULT_SCAN_INTERVAL,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
DOMAIN_CONFIG,
|
|
||||||
DOMAIN_DEVICES,
|
DOMAIN_DEVICES,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
)
|
)
|
||||||
|
@ -43,22 +45,26 @@ NOTIFICATION_TITLE = "UPnP/IGD Setup"
|
||||||
PLATFORMS = ["binary_sensor", "sensor"]
|
PLATFORMS = ["binary_sensor", "sensor"]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
|
vol.All(
|
||||||
|
cv.deprecated(DOMAIN),
|
||||||
{
|
{
|
||||||
DOMAIN: vol.Schema(
|
DOMAIN: vol.Schema(
|
||||||
{},
|
vol.All(
|
||||||
|
cv.deprecated(CONF_LOCAL_IP),
|
||||||
|
{
|
||||||
|
vol.Optional(CONF_LOCAL_IP): vol.All(ip_address, cv.string),
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
),
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up UPnP component."""
|
"""Set up UPnP component."""
|
||||||
LOGGER.debug("async_setup, config: %s", config)
|
|
||||||
conf_default = CONFIG_SCHEMA({DOMAIN: {}})[DOMAIN]
|
|
||||||
conf = config.get(DOMAIN, conf_default)
|
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
DOMAIN_CONFIG: conf,
|
|
||||||
DOMAIN_DEVICES: {},
|
DOMAIN_DEVICES: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ from homeassistant.const import TIME_SECONDS
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__package__)
|
LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
|
CONF_LOCAL_IP = "local_ip"
|
||||||
DOMAIN = "upnp"
|
DOMAIN = "upnp"
|
||||||
DOMAIN_CONFIG = "config"
|
|
||||||
DOMAIN_DEVICES = "devices"
|
DOMAIN_DEVICES = "devices"
|
||||||
BYTES_RECEIVED = "bytes_received"
|
BYTES_RECEIVED = "bytes_received"
|
||||||
BYTES_SENT = "bytes_sent"
|
BYTES_SENT = "bytes_sent"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue