Only Switch a Single Key to YAML-Edit Mode when the Value Is A Template #25004
-
In Scripting and Automations rather than switch an action editor to entirely YAML mode, just switch the particular key to YAML mode. This is a feature, in my view, that is hard to argue against. As Home Assistant has matured it has made a lot of progress towards its goal of moving configuration to the UI. One wonderful aspect of this is the ability for Actions that take parameters to have specialized field UIs like object selectors, selection lists, switches for boolean values, etc.. These fields can have default values and be declared mandatory. These things can be configured in Scripts as well as in services.yaml supporting Python Scripting. All of this beautify UI capability goes away in one fell swoop the moment just one field takes a template value. Suddenly you loose this well-structured UI you have developed for your script or that an Action has provided and you have to go back to figuring out what the key structure is, what keys you might have to add and what their allowed values are. You loose all of this simply because you need a single field to be passed the value of a template! Further, whereas you have the entire structure available to clue you in on all of the different keys whose values can be configured, the moment you jump to YAML mode those keys do not appear if they haven't already been configured. This creates the awkward workflow of being certain that you have filled in all of hour non-template values before entering a template value or you won't even know what keys you are supposed to fill in as, if they weren't already configured, they don't even show up in the YAML. A clean approach to addressing this problem is if a field needs to be edited in YAML mode maybe just to turn that particular field into a multi-line edit field. These fields exist. I have seen and used them. When you hit enter they expand down. You can build little YAML sub structures in them or make each line a list element. Why suddenly make editing the entire Action a research project where a second earlier it was a nice, clean UI, providing a clear understand of field values with explanations of the values, all just for the sake of one value needing to be a template? If Home Assistant is serious about continually migrating this system to being more and more configurable in the UI then I really think this is an essential change. Here is a use case that has highlighted this issue for me personally. I provide an abstracted interface to notifications via a notification script. When I need to perform notifications, instead of directly calling a bunch of different notification actions, I call one script with booleans to optionally turn on different notifiers and provide URLs and select sound files for phone notifications if they are turned on. One script handles most of my notification use cases and setting them up is a piece of cake because of the script's field definitions. However, if I use a template value for the message I instantaneously loose nice, clean UI and the keys I have not yet filled in are not in the YAML that shows up! I really think this is a must-do. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks, it's a good idea. We have merged it for next major release. |
Beta Was this translation helpful? Give feedback.
Thanks, it's a good idea. We have merged it for next major release.