mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove deprecated yaml config from broadlink (#62341)
This commit is contained in:
parent
3c913d4e88
commit
7919960570
@ -24,7 +24,6 @@ from homeassistant.components.remote import (
|
|||||||
ATTR_NUM_REPEATS,
|
ATTR_NUM_REPEATS,
|
||||||
DEFAULT_DELAY_SECS,
|
DEFAULT_DELAY_SECS,
|
||||||
DOMAIN as RM_DOMAIN,
|
DOMAIN as RM_DOMAIN,
|
||||||
PLATFORM_SCHEMA,
|
|
||||||
SERVICE_DELETE_COMMAND,
|
SERVICE_DELETE_COMMAND,
|
||||||
SERVICE_LEARN_COMMAND,
|
SERVICE_LEARN_COMMAND,
|
||||||
SERVICE_SEND_COMMAND,
|
SERVICE_SEND_COMMAND,
|
||||||
@ -32,7 +31,7 @@ from homeassistant.components.remote import (
|
|||||||
SUPPORT_LEARN_COMMAND,
|
SUPPORT_LEARN_COMMAND,
|
||||||
RemoteEntity,
|
RemoteEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, STATE_OFF
|
from homeassistant.const import STATE_OFF
|
||||||
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.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
@ -41,7 +40,7 @@ from homeassistant.util import dt
|
|||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import BroadlinkEntity
|
from .entity import BroadlinkEntity
|
||||||
from .helpers import data_packet, import_device
|
from .helpers import data_packet
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -85,22 +84,6 @@ SERVICE_DELETE_SCHEMA = COMMAND_SCHEMA.extend(
|
|||||||
{vol.Required(ATTR_DEVICE): vol.All(cv.string, vol.Length(min=1))}
|
{vol.Required(ATTR_DEVICE): vol.All(cv.string, vol.Length(min=1))}
|
||||||
)
|
)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|
||||||
{vol.Required(CONF_HOST): cv.string}, extra=vol.ALLOW_EXTRA
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
|
||||||
"""Import the device and discontinue platform.
|
|
||||||
|
|
||||||
This is for backward compatibility.
|
|
||||||
Do not use this method.
|
|
||||||
"""
|
|
||||||
import_device(hass, config[CONF_HOST])
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The remote platform is deprecated, please remove it from your configuration"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up a Broadlink remote."""
|
"""Set up a Broadlink remote."""
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
"""Support for Broadlink sensors."""
|
"""Support for Broadlink sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
PLATFORM_SCHEMA,
|
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
@ -21,13 +15,9 @@ from homeassistant.const import (
|
|||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import config_validation as cv
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import BroadlinkEntity
|
from .entity import BroadlinkEntity
|
||||||
from .helpers import import_device
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
@ -94,22 +84,6 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|
||||||
{vol.Required(CONF_HOST): cv.string}, extra=vol.ALLOW_EXTRA
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
|
||||||
"""Import the device and discontinue platform.
|
|
||||||
|
|
||||||
This is for backward compatibility.
|
|
||||||
Do not use this method.
|
|
||||||
"""
|
|
||||||
import_device(hass, config[CONF_HOST])
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The sensor platform is deprecated, please remove it from your configuration"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Broadlink sensor."""
|
"""Set up the Broadlink sensor."""
|
||||||
|
@ -13,7 +13,6 @@ from homeassistant.components.switch import (
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_COMMAND_OFF,
|
CONF_COMMAND_OFF,
|
||||||
CONF_COMMAND_ON,
|
CONF_COMMAND_ON,
|
||||||
CONF_FRIENDLY_NAME,
|
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_MAC,
|
CONF_MAC,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
@ -42,14 +41,6 @@ SWITCH_SCHEMA = vol.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
OLD_SWITCH_SCHEMA = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Optional(CONF_COMMAND_OFF): data_packet,
|
|
||||||
vol.Optional(CONF_COMMAND_ON): data_packet,
|
|
||||||
vol.Optional(CONF_FRIENDLY_NAME): cv.string,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = vol.All(
|
PLATFORM_SCHEMA = vol.All(
|
||||||
cv.deprecated(CONF_HOST),
|
cv.deprecated(CONF_HOST),
|
||||||
cv.deprecated(CONF_SLOTS),
|
cv.deprecated(CONF_SLOTS),
|
||||||
@ -59,9 +50,9 @@ PLATFORM_SCHEMA = vol.All(
|
|||||||
{
|
{
|
||||||
vol.Required(CONF_MAC): mac_address,
|
vol.Required(CONF_MAC): mac_address,
|
||||||
vol.Optional(CONF_HOST): cv.string,
|
vol.Optional(CONF_HOST): cv.string,
|
||||||
vol.Optional(CONF_SWITCHES, default=[]): vol.Any(
|
vol.Optional(CONF_SWITCHES, default=[]): vol.All(
|
||||||
cv.schema_with_slug_keys(OLD_SWITCH_SCHEMA),
|
cv.ensure_list,
|
||||||
vol.All(cv.ensure_list, [SWITCH_SCHEMA]),
|
[SWITCH_SCHEMA],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -78,17 +69,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
switches = config.get(CONF_SWITCHES)
|
switches = config.get(CONF_SWITCHES)
|
||||||
|
|
||||||
if not isinstance(switches, list):
|
|
||||||
switches = [
|
|
||||||
{CONF_NAME: switch.pop(CONF_FRIENDLY_NAME, name), **switch}
|
|
||||||
for name, switch in switches.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Your configuration for the switch platform is deprecated. "
|
|
||||||
"Please refer to the Broadlink documentation to catch up"
|
|
||||||
)
|
|
||||||
|
|
||||||
if switches:
|
if switches:
|
||||||
platform_data = hass.data[DOMAIN].platforms.setdefault(Platform.SWITCH, {})
|
platform_data = hass.data[DOMAIN].platforms.setdefault(Platform.SWITCH, {})
|
||||||
platform_data.setdefault(mac_addr, []).extend(switches)
|
platform_data.setdefault(mac_addr, []).extend(switches)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user