Hi, I’m using home assistant to play sound on my powered speakers connected directly to 3.5mm audio output. I want to be able to turn them on/off when needed, so I connected them through a smart plug.
Now the challenge is to determine whether any sound is coming out of the computer to trigger on/off automation.
I found this PulseAudio
command which gives me output IDLE
or RUNNING
:
pactl list | grep State
It works great, but I’m struggling to get it working in HA.
My plan is to run automation every 5 seconds which will check for IDLE
/RUNNING
status and control the smart plug accordingly.
I created shell command for that, but whenever I run it, it returns an error:
shell_command:
check_audio_output: /bin/bash -c "pactl list | grep State"
output:
stdout: ""
stderr: "/bin/bash: line 1: pactl: command not found"
returncode: 1
Same command works when I run it in terminal.
Anyone has any ideas why does it fail or maybe there is a better way to check for sound playing?