core icon indicating copy to clipboard operation
core copied to clipboard

input_text: name not optional

Open c727 opened this issue 9 years ago • 10 comments

@BioSehnsucht docs say it's optional: https://home-assistant.io/components/input_text/

Home Assistant release (hass --version): 0.55

Python release (python3 --version): 3.6

Component/platform: input_text

Description of problem: (friendly)name required

Expected: (friendly)name not required

Problem-relevant configuration.yaml entries and steps to reproduce:

input_text:
  ok:
    name: ok
  not_ok:

c727 avatar Oct 15 '17 14:10 c727

I can reproduce this error - in the config schema of input_text.py all values are with vol.Optional, but currently I don't know where this error comes from...

DanielXYZ2000 avatar Oct 15 '17 18:10 DanielXYZ2000

Here all keys are set to required: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/input_text.py#L68

I'm not sure of the background for this though.

MartinHjelmare avatar Oct 15 '17 19:10 MartinHjelmare

As I understand that, only the CONFIG_SCHEMA is required, I would guess that "name" shall be something like vol.Required(CONF_NAME): cv.string but I did not find this way in other sources

DanielXYZ2000 avatar Oct 15 '17 20:10 DanielXYZ2000

I suspect the problem is if your configuration is verbatim, you can't give an empty dict by just leaving an empty hanging configuration, you have to specify empty dict with {}. There's probably an error message being output by HASS somewhere about an empty Dict. We should probably update the documentation to make it clear this is how to handle adding an input_text that has no configuration ...

Ex:

input_text:
  ok1:
    name: works1
  ok2:
    min: 0
  ok3: {}
  bad1:

BioSehnsucht avatar Oct 16 '17 07:10 BioSehnsucht

but here both are ok for example

input_boolean:
  switch1:
  switch2:
    name: Switch 2

c727 avatar Oct 16 '17 12:10 c727

Interesting. Perhaps YAML "knows" that following with another same-level entry means that switch1 should be an empty Dict {} automatically, but when it's the last thing at that level it doesn't know if it was malformed or not?

Can you test whether using {} solves the problem as originally posted ? (i.e. as follows, does not_ok actually work?):

input_text:
  ok:
    name: ok
  not_ok: {}

Using {} works for me.

BioSehnsucht avatar Oct 16 '17 18:10 BioSehnsucht

@BioSehnsucht

input_boolean:
  switch1:
  switch2:

is also working

yes

input_text:
  ok: {}

is working but if you see the syntax for input_boolean it still looks broken for me

c727 avatar Oct 19 '17 21:10 c727

Might be a difference in using cv.slug: vol.All({ vs cv.slug: vol.Any({, only difference in how they handle configuration that I can see. I'm not sure what the reasoning for picking one over the other would be, I am by no means an expert here.

BioSehnsucht avatar Oct 20 '17 21:10 BioSehnsucht

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

balloobbot avatar Mar 02 '18 23:03 balloobbot

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

balloobbot avatar Mar 30 '18 20:03 balloobbot