rename replace_none -> replace_none_str

This commit is contained in:
Bas Nijholt 2020-09-26 13:01:43 +02:00
commit 34acd03f46
3 changed files with 7 additions and 7 deletions

View file

@ -15,10 +15,10 @@ hues. Hormone production, brainwave activity, mood and wakefulness are
just some of the cognitive functions tied to cyclical natural light.
http://en.wikipedia.org/wiki/Zeitgeber
Here's some further reading:
Further reading:
http://www.cambridgeincolour.com/tutorials/sunrise-sunset-calculator.htm
http://en.wikipedia.org/wiki/Color_temperature
- http://www.cambridgeincolour.com/tutorials/sunrise-sunset-calculator.htm
- http://en.wikipedia.org/wiki/Color_temperature
Technical notes: I had to make a lot of assumptions when writing this app
* There are no considerations for weather or altitude, but does use your

View file

@ -100,7 +100,7 @@ def maybe_coerce(key, validation):
return validation
def replace_none(value, replace_with=None):
def replace_none_str(value, replace_with=None):
"""Replaces "None" -> replace_with."""
return value if value != NONE_STR else replace_with
@ -112,7 +112,7 @@ validation_tuples = [
_DOMAIN_SCHEMA = vol.Schema(
{
vol.Optional(key, default=replace_none(default, vol.UNDEFINED)): validation
vol.Optional(key, default=replace_none_str(default, vol.UNDEFINED)): validation
for key, default, validation in validation_tuples
}
)

View file

@ -79,7 +79,7 @@ from .const import (
SUN_EVENT_MIDNIGHT,
SUN_EVENT_NOON,
VALIDATION_TUPLES,
replace_none,
replace_none_str,
)
_SUPPORT_OPTS = {
@ -146,7 +146,7 @@ def validate(config_entry):
data = deepcopy(defaults)
data.update(config_entry.options) # come from options flow
data.update(config_entry.data) # all yaml settings come from data
data = {key: replace_none(value) for key, value in data.items()}
data = {key: replace_none_str(value) for key, value in data.items()}
for key, (validate, _) in EXTRA_VALIDATION.items():
value = data.get(key)
if value is not None: