-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Fields to Script UI #18250
Add Fields to Script UI #18250
Conversation
Thanks! Great that you add this to the UI. Some feedback points:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't show Fields on default, because it's a pretty advanced option. Let's add an option in the overflow menu, like we do with modes in the automation editor.
@matthiasdebaat I disagree about hiding it by default. IMO, it's what makes scripts more useful and versatile than probably most users realize. That said, I agree that they seem advanced, but I think that's more due to the docs and some of the confusing terminology used (e.g. "inputs" vs. "fields", "sequence" vs. "actions", "selector" which should probably just be something like "field type", etc.). Maybe this is an opportunity to make that more user friendly rather than hiding it?
As a very simple example, I have a TTS announcement script with the string to say as input. It has logic to handle volumes, time of day to talk or be quiet, etc. So if any of my automations need to make an announcement, they just call that script rather than repeating that everywhere.
Remove example, because it's not used.
Should be removed from the docs too.
.label=${this.hass.localize("ui.common.menu")} | ||
.path=${mdiDotsVertical} | ||
></ha-icon-button> | ||
<mwc-list-item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a menu item to edit in Yaml mode here.
}, | ||
{ | ||
name: "default", | ||
selector: { object: {} }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @matthiasdebaat this should be below the selector type, and it should just render that selector.
}, | ||
{ | ||
name: "selector", | ||
selector: { object: {} }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why, but I don't like displaying a code editor here. It makes it too complex for many users, and is unnecessary since many selectors have no options.
How about just displaying a select drop down with the different selector types? As a first cut, could leave any non-default options only available in Yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I struggled a little bit with this too.
I think the problem with just a dropdown is that some selectors (like number
) have mandatory options, like min/max. So you can't really just have a "default" number selector without requiring extra input.
It's almost like we want a ha-selector-selector
that lets you pick a type of selector from a list, and based on what is chosen, shows an additional form of more options.
At the simplest level we could just mandate that it is a text:
selector and not have any option at all, that might cover a lot of usecases. Don't know if that's too limited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right. I can try to come up with something for a selector picker as a separate PR to help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we do want a selector
selector in the future, but with all the options this can be a lot of work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we do want a
selector
selector in the future, but with all the options this can be a lot of work.
Yup... I got maybe 100 lines into it and quickly realized that. 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you were still working on this, but I did play with creating a ha-selector-selector. Styling/css is a bit rough still but it seems functional.
I don't think we need all options of all selectors to get started with it, we can just cover some of the more common ones, and have a manual yaml option for those that fall outside the initial scope.
Dunno if you were farther along than this, so do let me know if you want to drive it, otherwise I can continue fleshing this out.
I don't think the amount of work will be too bad, as we just need to define one form schema per selector type (and we can ignore many of them that don't have any options).
What is meant exactly by "not used"? If you put a value in example, than it shows up in the example in developer tools, and it is filled when you click "Fill example data". Do we just mean that it's very niche? Or that it is not considered to be useful? Or that it is deprecated? It still has functionality... |
Oh yeah I forgot about that - probably because I don't use it ever. 😏 My vote is to just plan to deprecate it, and just leave it as a Yaml-only setting for now. At the very least it should be moved to the bottom. |
Updates:
I will point out one thing that seems slightly dangerous about rendering the selector for I've got around this for a moment by clearing |
I think I got all the requests addressed, so flipping this out of draft. The selector field is still a possible sore spot, not sure if its ok as-is, or if we want to see something else. Maybe enhance it in a follow up. |
f0ac87b
to
c5132f1
Compare
I think this needs some attention, maybe we should only clear it when the type of the selector is changed? Or... Something to think about |
Is there some way the form could catch if one of its children throws an exception, and clear it in that case? |
We could listen for the "error" and "unhandledrejection" event, and use those? |
I think the better option is to make our selectors better, they should handle wrong values instead if throw and not render... |
Did a few, there might be more... |
Proposed change
Add a fields editor to the UI for scripts.
Type of change
Example configuration
Additional information
Support fields & variables in script editor #13771
https://community.home-assistant.io/t/wth-are-fields-variables-in-scripts-automations-arent-included-in-the-ui/467210
Checklist
If user exposed functionality or configuration variables are added/changed: