Add a service description to shell commands?

Hi there,

I got a service running as a shell command implementation and wanted to add a service description to it.
Like pictured here:

I already tried creating a services.yml in the pyscript folder where the script (being called) is located and also in the “custom_components” folder. But this did not have the desired effect…

Is it even possible to do so?

regards Steffen

A script provides a description option (whose value appears in the Services menu). However, there’s nothing in the documentation for the Shell Command integration that indicates you can annotate it with a description.

As you have already discovered, adding/modifying services.yaml doesn’t work.

Just name the shell commands

configuration.yaml

shell_command: !include shell.yaml

shell.yaml

make_fart_directory: >-
  mkdir -p /config/fart/derp

Then when you call the service, the name will show as shell command: make_fart_directory

With “service description” I meant the description of available parameters and possibility to add example data (described here: Integration Services | Home Assistant Developer Docs
). Like pictured in the screenshot (below the yaml configuration field)…

Not a alternative description for the shell command itself.

hmm, so as a workaround I could create a script with my description/examples which then calls the shell command?

The script example was only meant to show that, in contrast to shell_command, not only does script support the feature you want but makes it convenient to implement (i.e. no editing of other YAML files is needed).

I suppose you could “wrap” your shell_command in a script but it would be a roundabout way to get a service description. In addition, the Services menu will have two services with similar names (like shell_command.do_something and script.do_something) unless you give the shell command a very different name.

Shell commands don’t support parameters… Like not just the description, you literally cannot parameterize them. You can use templates in the shell command but you can only refer to other things in the state machine like the example from the doc shows:

shell_command:
  set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'

So I’m not really sure what parameters you would be documenting? Nothing you pass in to the service call will have any effect on the service call.

If you want to parameterize a shell command then you need to wrap it in a script. Not just for documentation purposes, literally to make the parameters work. You have to do something hacky in the script like take in parameters, set helpers from from those parameters, and then call a shell command that refers to those helpers.

This is why I basically never use shell command and just use command line notify instead. It’s essentially the same thing except whatever you pass in as the message actually gets passed into your command as stdin. So you don’t have to make a bunch of helpers to “parameterize” your shell command.