Missing Shell Integration

Hello,

It seems to me i am missing the Shell Integration in my HA.

My setup is as following, installed following this link:https://www.home-assistant.io/docs/installation/raspberry-pi/

I am trying to send a shell. command to my pi to change sound volume but i do not see the shell service in the services list.
The HA mobile app is not reporting the shell imtegration as installed and i cannoy find it in the Integrations page to add it.

Am i missing it or am i just not looking in the right place? How to i go about and add it?

Thank you?

You add it in YAML (there is no UI integration, yet):

Hi Tom,

Thank you for your answer. This put me on the right track indeed.

Since I’ve been toying with HA only for a few weeks, it actually took me a few hours to finish the simple task of running a shell command from HA, so let me explain briefly what I did, in case some other newbie stumbles upon this.

So what Tom is suggesting here is that each shell command you need to run has to be added manually to the configuration.yaml file.
You need to edit the configuration.yaml and add a shell_command:line. All other indented lines after that will be the commands HA will see in the Services section.
I added the following, to help me control my pi’s audio volume


`
shell_command:
  vol_mic: sudo amixer set 'Headphone' -- -400
  vol_mare: sudo amixer set 'Headphone' -- 400
  volum_variabil: 'sudo amixer set ''Headphone'' -- {{ states("input_number.volume") }}'
`

This gives me 3 services in HA:

  • shell_command.vol_mic
  • shell_command.vol_mare
  • shell_command.volum_variabil

You will note the first 2 commands are not enclosed in quotes, but the 3rd one is. That is because the 3rd one uses a dynamic parameter for the command - the state of the input_number.volume helper entity - and that requires the entire string to be encased in quotes. However, since my command already contained a quoted string -‘Heaphones’- the name of my sound card, I had to escape those quotes by adding additional ’ symbols

Note that these commands will run with the same user that is running HA service - in my case, homeassistant, in a virtual python environment. So you need to make sure that your shell commands do indeed run before you code them in the yaml file.

Regards