Allow passing None as input_text config (#26409)

This commit is contained in:
Paulus Schoutsen 2019-09-03 18:55:58 -07:00 committed by Andrew Sayre
parent b968b53e38
commit 53720c5c48
2 changed files with 28 additions and 14 deletions

View File

@ -58,6 +58,7 @@ def _cv_input_text(cfg):
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: cv.schema_with_slug_keys(
vol.Any(
vol.All(
{
vol.Optional(CONF_NAME): cv.string,
@ -72,6 +73,8 @@ CONFIG_SCHEMA = vol.Schema(
),
},
_cv_input_text,
),
None,
)
)
},
@ -87,6 +90,8 @@ async def async_setup(hass, config):
entities = []
for object_id, cfg in config[DOMAIN].items():
if cfg is None:
cfg = {}
name = cfg.get(CONF_NAME)
minimum = cfg.get(CONF_MIN)
maximum = cfg.get(CONF_MAX)

View File

@ -186,3 +186,12 @@ async def test_input_text_context(hass, hass_admin_user):
assert state2 is not None
assert state.state != state2.state
assert state2.context.user_id == hass_admin_user.id
async def test_config_none(hass):
"""Set up input_text without any config."""
await async_setup_component(hass, DOMAIN, {DOMAIN: {"b1": None}})
state = hass.states.get("input_text.b1")
assert state
assert str(state.state) == "unknown"