Volume slider for integrated 3.5mm speaker

The device itself is just a regular 3.5mm speaker connected to the Pi. It has no intelligence, bare metal speaker.

1 Like

Made the folllowing:

internal_speaker_volume:
name: Interne Speaker Volume
initial: 100
min: 0
max: 100
step: 10
icon: mdi:volume-high

Automation:

  • alias: “Internal Speaker - Set Volume”
    trigger:
    platform: state
    entity_id: input_number.internal_speaker_volume
    action:
    • service: shell_command.run_sudo
      data:
      cmd: “amixer set PCM – ‘{{ states.input_number.internal_speaker_volume.state | int}}’%”

Getting error:
Unable to find service shell_command/run_sudo

Got it working:

shell_command:
set_internal_speaker_volume: “amixer set PCM – ‘{{ states.input_number.internal_speaker_volume.state | int}}’%”

input_number:
internal_speaker_volume:
name: Interne Speaker Volume
initial: 100
min: 0
max: 100
step: 10
icon: mdi:volume-high

automation:

  • alias: “Internal Speaker - Set Volume”
    initial_state: on
    trigger:
    platform: state
    entity_id: input_number.internal_speaker_volume
    action:
    service: shell_command.set_internal_speaker_volume

I have this in my HA. I will post it this evening.

Awesome :sunglasses: will try this week.

I have put this in package. It will not show up. you need to put the group.pi_volume shows in this package in the tab view you want.
pi_volume

#Raspberry Pi Volume Control

##################################################
## Extra volume control for Raspberry Pi 3
##################################################

shell_command:
     pi_volume_0: amixer cset numid=1 -- -10238
     pi_volume_10: amixer cset numid=1 -- -5675
     pi_volume_20: amixer cset numid=1 -- -3820
     pi_volume_30: amixer cset numid=1 -- -2740
     pi_volume_40: amixer cset numid=1 -- -1976
     pi_volume_50: amixer cset numid=1 -- -1383
     pi_volume_60: amixer cset numid=1 -- -942
     pi_volume_70: amixer cset numid=1 -- -525
     pi_volume_80: amixer cset numid=1 -- -195
     pi_volume_90: amixer cset numid=1 -- 118
     pi_volume_100: amixer cset numid=1 -- 400

input_number:
     pi_volume:
       icon: mdi:volume-high
       name: Volume 
       initial: 70
       min: 0
       max: 100
       step: 10

automation:
    - action:
      - service_template: shell_command.pi_volume_{{ trigger.to_state.state | int }}
      alias: Pi Volume
      condition: []
      id: 'pi_volume'
      trigger:
      - entity_id: input_number.pi_volume
        platform: state

script:       
     mute_pi_script:
       alias: Mute Pi
       sequence:
       - data:
           entity_id: input_number.pi_volume
           value: 0
         service: input_number.select_value            

group:
     pi_volume:
       icon: mdi:timer
       entities:
       - input_number.pi_volume
       - script.mute_pi_script
       name: Raspberry Pi Volume
       view: false
1 Like

I think my scripting is a lot easier, See my post above

1 Like

So would this work for my tv using my Harmony Hub?

can shellcommand: work in hassio?

Yes it can.

has anybody got this working in Hassio, both examples above return errors

i moved commands around to get a check config “good” but it still hasn’t worked.

I use it with hassbian and raspbian connect to 3.5mm jack to the speaker. I have no experience with hassio, so I’m not sure if this would works with hassio.

thanks Sunonline

ill eventually figure all of this stuff out.

including the Alexa tts and Janet Tts

I tried using the code mentioned above withouth success; is anyone using HassIO ?

I know there are several answers already but this works oob for me, I’m using the package method, so this is te content of the file raspberry_pi_volume_central.yaml
I have issues copying pasting the code from above as the symbols screwed everything up. Code tags should be used for posting :+1:

input_number:
  pi_volume:
    icon: mdi:volume-high
    name: Volume 
    initial: 70
    min: 0
    max: 100
    step: 10

shell_command:
  set_internal_speaker_volume: amixer set PCM - '{{ states.input_number.pi_volume.state | int}}'% -M

automation:
  - alias: Pi Volume
    id: 'pi_volume'
    trigger:
      - entity_id: input_number.pi_volume
        platform: state
    action:
      - service: shell_command.set_internal_speaker_volume

Trying to execute the shell command mentioned here returns FileNotFoundError: [Errno 2] No such file or directory: ‘amixer’, not sure why, any help is appreciated.

I also am getting the same error. Has any solution for this been found?

Hello,

In Hass.io/Home Assistant OS, alsamixer and amixer are not available in the base system, they are part of a docker container called hassio_audio, you can access from the CLI by running the login command to enter the shell, then run docker exec -it hassio_audio /bin/bash, with that you enter the shell of the container that handles the audio and from there you can run alsamixer or amixer.

Regards

English only please.

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#zero-language-3

sorry, hi all, has anyone come up with a solution/guide? Thanks again

1 Like