"Scene entity ID": add validation and improve description

AutomationActionScenes: Create

When I’m prompted to type the Scene entity ID, there is no validation of the value.

I’ve inputted restore desk light, was able to save the automation, but it didn’t work. I’ve found this in logs instead:

2024-05-08 02:19:46.754 ERROR (MainThread) [homeassistant.components.automation.enterance_toggle_desk_light] Entrance: toggle desk light: Error executing script. Invalid data for call_service at pos 1: invalid slug restore desk light (try restore_desk_light) for dictionary value @ data['scene_id']

Feature Request 1: add the validation for the field, so that inputting invalid value woudn’t be possible.

Feature Request 2: add a better description for the field.

As for the second point, the obvious questions appear:

  • what are the rules for the entity id? like: can I use spaces? :wink: Hopefully some of them can be automatically validated by Feature Request number one.
  • if this is entity id, do I need to start it with scene. prefix or something? or will it be added automatically? (I already know from debugging, that the prefix is being added automatically, but it isn’t obvious without experimentation/debugging)
  • is the id unique for this particular automation only, or global for the whole HA? it’s important as one should think how much unique does it have to be… (it’s global, again: not obvious for newcomers for sure)

It also has to be lower case… IE lower_case_chase …

you mean, as the rule for entity id? maybe. i’d assume it can’t contain any special utf8 chars as well, although i may be wrong.

anyway, i’m not trying to list all the entity id naming rules here → i don’t even know them.

but i do know the “never trust the user input rule” of software development → hence there should be at least some validation in place. not only for less bugs, but also just for a better user experience.

I’ve been bitten by having capitols while naming a temporary scene in an automation. I grabbed a context ID from this. as a cheap way to make a unique name, but then I had to |lower it to work.