Remove deprecated async_setup_platforms() for xiaomi_miio (#54930)

This commit is contained in:
Teemu R 2021-08-20 20:13:58 +02:00 committed by GitHub
parent dbc4470979
commit 3048923dc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 186 deletions

View file

@ -14,23 +14,19 @@ from miio.gateway.gateway import (
GATEWAY_MODEL_EU,
GatewayException,
)
import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import (
ATTR_BATTERY_LEVEL,
ATTR_TEMPERATURE,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
CONF_HOST,
CONF_NAME,
CONF_TOKEN,
DEVICE_CLASS_CO2,
DEVICE_CLASS_GAS,
@ -47,7 +43,6 @@ from homeassistant.const import (
TIME_HOURS,
VOLUME_CUBIC_METERS,
)
import homeassistant.helpers.config_validation as cv
from .const import (
CONF_DEVICE,
@ -78,14 +73,6 @@ _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "Xiaomi Miio Sensor"
UNIT_LUMEN = "lm"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}
)
ATTR_ACTUAL_SPEED = "actual_speed"
ATTR_AIR_QUALITY = "air_quality"
ATTR_AQI = "aqi"
@ -326,21 +313,6 @@ MODEL_TO_SENSORS_MAP = {
}
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Import Miio configuration from YAML."""
_LOGGER.warning(
"Loading Xiaomi Miio Sensor via platform setup is deprecated. "
"Please remove it from your configuration"
)
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=config,
)
)
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Xiaomi sensor from a config entry."""
entities = []