rename FAKE_NONE -> NONE_STR

This commit is contained in:
Bas Nijholt 2020-09-24 23:54:14 +02:00
commit 049fb8b983
3 changed files with 12 additions and 12 deletions

View file

@ -8,7 +8,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant import config_entries
from homeassistant.core import callback
from .const import DOMAIN, EXTRA_VALIDATION, FAKE_NONE, VALIDATION_TUPLES
from .const import DOMAIN, EXTRA_VALIDATION, NONE_STR, VALIDATION_TUPLES
_LOGGER = logging.getLogger(__name__)
@ -51,7 +51,7 @@ def validate_options(user_input, errors):
# these are unserializable validators
try:
value = user_input.get(key)
if value is not None and value != FAKE_NONE:
if value is not None and value != NONE_STR:
validate(value)
except vol.Invalid:
_LOGGER.exception("Configuration option %s=%s is incorrect", key, value)

View file

@ -35,7 +35,7 @@ CONF_SUNSET_TIME = "sunset_time"
CONF_TRANSITION, DEFAULT_TRANSITION = "transition", 60
UNDO_UPDATE_LISTENER = "undo_update_listener"
FAKE_NONE = "None" # TODO: use `from homeassistant.const import ENTITY_MATCH_NONE`?
NONE_STR = "None" # TODO: use `from homeassistant.const import ENTITY_MATCH_NONE`?
def int_between(a, b):
@ -45,8 +45,8 @@ def int_between(a, b):
VALIDATION_TUPLES = [
(CONF_LIGHTS, DEFAULT_LIGHTS, cv.entity_ids),
(CONF_DISABLE_BRIGHTNESS_ADJUST, DEFAULT_DISABLE_BRIGHTNESS_ADJUST, bool),
(CONF_DISABLE_ENTITY, FAKE_NONE, str),
(CONF_DISABLE_STATE, FAKE_NONE, str),
(CONF_DISABLE_ENTITY, NONE_STR, str),
(CONF_DISABLE_STATE, NONE_STR, str),
(CONF_INITIAL_TRANSITION, DEFAULT_INITIAL_TRANSITION, VALID_TRANSITION),
(CONF_INTERVAL, DEFAULT_INTERVAL, cv.positive_int),
(CONF_MAX_BRIGHTNESS, DEFAULT_MAX_BRIGHTNESS, int_between(1, 100)),
@ -56,12 +56,12 @@ VALIDATION_TUPLES = [
(CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool),
(CONF_SLEEP_BRIGHTNESS, DEFAULT_SLEEP_BRIGHTNESS, int_between(1, 100)),
(CONF_SLEEP_COLOR_TEMP, DEFAULT_SLEEP_COLOR_TEMP, int_between(1000, 10000)),
(CONF_SLEEP_ENTITY, FAKE_NONE, str),
(CONF_SLEEP_STATE, FAKE_NONE, str),
(CONF_SLEEP_ENTITY, NONE_STR, str),
(CONF_SLEEP_STATE, NONE_STR, str),
(CONF_SUNRISE_OFFSET, DEFAULT_SUNRISE_OFFSET, int),
(CONF_SUNRISE_TIME, FAKE_NONE, str),
(CONF_SUNRISE_TIME, NONE_STR, str),
(CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET, int),
(CONF_SUNSET_TIME, FAKE_NONE, str),
(CONF_SUNSET_TIME, NONE_STR, str),
(CONF_TRANSITION, DEFAULT_TRANSITION, VALID_TRANSITION),
]
@ -97,7 +97,7 @@ def maybe_coerse(key, validation):
def replace_none(x):
return x if x != FAKE_NONE else vol.UNDEFINED
return x if x != NONE_STR else vol.UNDEFINED
validation_tuples = [

View file

@ -67,8 +67,8 @@ from .const import (
CONF_TRANSITION,
DOMAIN,
EXTRA_VALIDATION,
FAKE_NONE,
ICON,
NONE_STR,
SUN_EVENT_MIDNIGHT,
SUN_EVENT_NOON,
VALIDATION_TUPLES,
@ -106,7 +106,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
def replace_none(value):
"""Replaces "None" -> None."""
return value if value != FAKE_NONE else None
return value if value != NONE_STR else None
def validate(config_entry):