mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 21:40:16 +00:00
Correct spelling of aliases, deprecate old config options. (#8348)
* correct spelling of aliases * add deprecation * Fix style.
This commit is contained in:
committed by
Fabian Affolter
parent
143044f8f1
commit
fe6a4b8ae5
@@ -10,15 +10,15 @@ import functools as ft
|
||||
import logging
|
||||
|
||||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP,
|
||||
STATE_UNKNOWN)
|
||||
from homeassistant.core import CoreState, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.deprecation import get_deprecated
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import voluptuous as vol
|
||||
|
||||
REQUIREMENTS = ['rflink==0.0.34']
|
||||
|
||||
@@ -27,9 +27,12 @@ _LOGGER = logging.getLogger(__name__)
|
||||
ATTR_EVENT = 'event'
|
||||
ATTR_STATE = 'state'
|
||||
|
||||
CONF_ALIASES = 'aliases'
|
||||
CONF_ALIASSES = 'aliasses'
|
||||
CONF_GROUP_ALIASES = 'group_aliases'
|
||||
CONF_GROUP_ALIASSES = 'group_aliasses'
|
||||
CONF_GROUP = 'group'
|
||||
CONF_NOGROUP_ALIASES = 'nogroup_aliases'
|
||||
CONF_NOGROUP_ALIASSES = 'nogroup_aliasses'
|
||||
CONF_DEVICE_DEFAULTS = 'device_defaults'
|
||||
CONF_DEVICES = 'devices'
|
||||
@@ -219,8 +222,8 @@ class RflinkDevice(Entity):
|
||||
platform = None
|
||||
_state = STATE_UNKNOWN
|
||||
|
||||
def __init__(self, device_id, hass, name=None, aliasses=None, group=True,
|
||||
group_aliasses=None, nogroup_aliasses=None, fire_event=False,
|
||||
def __init__(self, device_id, hass, name=None, aliases=None, group=True,
|
||||
group_aliases=None, nogroup_aliases=None, fire_event=False,
|
||||
signal_repetitions=DEFAULT_SIGNAL_REPETITIONS):
|
||||
"""Initialize the device."""
|
||||
self.hass = hass
|
||||
@@ -398,3 +401,24 @@ class SwitchableRflinkDevice(RflinkCommand):
|
||||
def async_turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
return self._async_handle_command("turn_off")
|
||||
|
||||
|
||||
DEPRECATED_CONFIG_OPTIONS = [
|
||||
CONF_ALIASSES,
|
||||
CONF_GROUP_ALIASSES,
|
||||
CONF_NOGROUP_ALIASSES]
|
||||
REPLACEMENT_CONFIG_OPTIONS = [
|
||||
CONF_ALIASES,
|
||||
CONF_GROUP_ALIASES,
|
||||
CONF_NOGROUP_ALIASES]
|
||||
|
||||
|
||||
def remove_deprecated(config):
|
||||
"""Remove deprecated config options from device config."""
|
||||
for index, deprecated_option in enumerate(DEPRECATED_CONFIG_OPTIONS):
|
||||
if deprecated_option in config:
|
||||
replacement_option = REPLACEMENT_CONFIG_OPTIONS[index]
|
||||
# generate deprecation warning
|
||||
get_deprecated(config, replacement_option, deprecated_option)
|
||||
# remove old config value replacing new one
|
||||
config[replacement_option] = config.pop(deprecated_option)
|
||||
|
||||
Reference in New Issue
Block a user