Play radio stream on the push of a button?

I’m fairly new to Home Assistant but I have it up and running with all my components. I’m switching to Lovelace now. I’m using a Fire HD tablet on the wall for lights, curtains, weather, etc. It all works great.

Now, I’d love to include a simple button with a logo -say NPR- so it plays the live http audio stream when pushed and stops playing when pushed again.

Does anybody think it can be done with HA/Lovelace?

Thanks!

It certainly can be done! The only challenge is choosing the right way to do this for you.

You could create a script that uses the media_player.select_source service and then plays the media. If you added that script to your front end or a lovelace entities card (or entity button, or glance, etc.) you would just have to click on it to turn on the stream.

Also, the media player on the front end includes a source list. The source list for my Sonos speakers is automatically populated by my Sonos favorites so I can easily select those from a drop down.

Ok, that’s a start! Thanks for for pointing me in that direction!

what media/speakers have you got?

I actually want the stream to be played on the Fire HD tablet I have set up as HA frontend on the wall. That might be the tricky part for me…

Ok, if you’re using lovelace you can configure the tablet as a media player with this component

Once you do that you can configure your radio stations

on second thought you can set up this component as well and the tablet will appear as an Alexa media player.

2 Likes

They are both great ideas! Thanks Juan, time to work on it now!

Tady je script pro spuštění a vypnutí radia a do tlačítka vložte stisknutím spustit tento script.

Here is the script to start and turn off the radio and put in the button press to start this script.

alias: Spustit radio v kuchyni
sequence:

  • if:
    • condition: state
      entity_id: media_player.kitchen
      state: playing
      then:
    • service: media_player.turn_off
      metadata: {}
      data: {}
      target:
      entity_id: media_player.kitchen
      enabled: true
      else:
    • service: media_player.play_media
      data:
      media_content_type: music
      media_content_id: https://icecast5.play.cz/impuls128.mp3
      target:
      entity_id: media_player.kitchen
      icon: mdi:radio
      mode: single