Remove deprecated YAML configuration from Stookalert (#61007)
This commit is contained in:
parent
eb5a321a9f
commit
e62148b8ff
3 changed files with 4 additions and 59 deletions
|
@ -4,59 +4,21 @@ from __future__ import annotations
|
|||
from datetime import timedelta
|
||||
|
||||
import stookalert
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import 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_PROVINCE, DOMAIN, LOGGER, PROVINCES
|
||||
from .const import CONF_PROVINCE, DOMAIN
|
||||
|
||||
DEFAULT_NAME = "Stookalert"
|
||||
ATTRIBUTION = "Data provided by rivm.nl"
|
||||
SCAN_INTERVAL = timedelta(minutes=60)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_PROVINCE): vol.In(PROVINCES),
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Import the Stookalert platform into a config entry."""
|
||||
LOGGER.warning(
|
||||
"Configuration of the Stookalert platform in YAML is deprecated and will be "
|
||||
"removed in Home Assistant 2022.1; 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={
|
||||
CONF_PROVINCE: config[CONF_PROVINCE],
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
@ -71,7 +33,7 @@ async def async_setup_entry(
|
|||
class StookalertBinarySensor(BinarySensorEntity):
|
||||
"""Defines a Stookalert binary sensor."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
_attr_attribution = "Data provided by rivm.nl"
|
||||
_attr_device_class = BinarySensorDeviceClass.SAFETY
|
||||
|
||||
def __init__(self, client: stookalert.stookalert, entry: ConfigEntry) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue