Automation based on state of sound output Raspberry Pi

I’ve installed on my Raspberry Pi 3b+ and installed the Spotify Connect add-on and linked a smart plug that is connected to my amplifier. Next challenge is to automate: I want the switch of the amplifier to turn on if the Raspberry Pi is playing audio (e.g. via Spotify Connect). Is there a state I can check to see if / the Raspberry Pi is playing audio via it’s own audio output?

This should do it:

    - platform: state
      entity_id: media_player.your_media_player
      to: 'playing'

EDIT: just realised this is an add-on running in a docker container and not a media player. So the above wont work.

I think, you would need to add the Spotify component, and test if that is playing through the raspi source (see the bottom of the linked document under “Sources”). Not really sure.

The Spotify component seems to do something different than the Spotify Connect add-on. I want to use the raspberry pi running as mediaplayer. The Spotify component allows me to control spotify played on other machines (e.g. my laptop or other media players).

Is it possible to use the spotify component to output on the raspberry pi?

Yep totally. The addon is a streaming player completely seperate from Hassio. The component is a way to control and monitor what is streaming on your Spotify players. You can not tell what the addon is doing in Hassio without the component.

No. only the addon can do that. However you can control and monitor the addon with the component.

So if you want to test if the Hassio streaming player addon is playing out the audio jack you will need the component.

At least I think that’s how it works. I dont have Spotify so I’m just going on what I read in the documents.

Is there no “system level” state of the host that checks the audio output on the Raspberry Pi?

Not that I know of.

1 Like