Local browser as media target

CONTEXT:
I’m on a recent version (2022.09.x) using docker container on a local server.

The media dashboard shows media sources (camera, local media, radio browser and tts) as tiles.
The bottom of the screen shows a media player control.
On the right side of this control I can select the target for the playing of the music.
This lists: browser, apple tv and kitchen.
Apple TV and kitchen are in fact media targets for which devices exist in the apple tv and the sonos integrations.

Playing to the local browser works fine.

QUESTION:
I wish to play sound to the browser using the service media_player.media_play
this requires: target: .
I can find nowhere how to identify the local browser as target.
Or another way to render media to the local browser instead of to a media player in the network.

DISCLAIMER:
I’ve been searching my head off for the last two days, can’t find another clue than using VLC or installing mod_browser, which seems overly complicated, because the media control obviously knows how to do this.

1 Like

I have been trying to figure out the same thing. I want to make automations that reads out TTS messages on my tablet through the companion app. In Media sources I can play TTS in the browser just fine but I can’t figure out how to automate since I only can choose my Apple TV a source.

Same thing I I go to developer tools - services and try to call the TTS service I can only choose my Apple TV as media player source.

I have the same problem. Spent hours - no solution.
I have 20+ inactive (greyed out) instances of browsers, but obviously they don’t help. They come from the hass-browser_mod/README.md at master · thomasloven/hass-browser_mod · GitHub

I thought about using my smartphone, since it is a different device known to HA. Not solution either.

I have the same question/problem!

How to define/identify the local browser as target?

Add me to the list. I can play all uploaded media manually through the browser in the “media” section but cannot figure out how to get an automation to play sound to the local browser.

Do you guys found a solution for this?

Not sure what you mean by this … are you wanting to play a TTS message on the local browser? If so, I use the following (from Developer Tools \ Services):

service: tts.google_translate_say
data:
  cache: false
  entity_id: media_player.chrome_home_office
  message: This is a test message

In my browser mod configuration, I have a Browser ID configured as chrome_home_office, which creates a media_player.google_chrome_office entity that is a media player. You then reference that media_player to play the media you want.

Example:

I simply want to create a button which can play a specific Radiostation in a random local browser.
Like I already can do by using the “Radio Browser” directly.

1 Like

Here’s a test automation (no triggers, no conditions) that I put together with actions to play a TTS message on both Chrome and Edge browser instances running on my home office desktop PC.

alias: TEST Browser TTS Messages to Multiple Browsers
description: TEST Browser TTS Messages to Multiple Browsers
trigger: []
condition: []
action:
  - service: tts.google_translate_say
    data:
      cache: false
      entity_id: media_player.edge_home_office
      message: This is a test message to the Microsoft Edge browser.
    alias: Say TTS Message on Microsoft Edge Browser
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: tts.google_translate_say
    data:
      cache: false
      entity_id: media_player.chrome_home_office
      message: This is a test message to the Google Chrome browser.
    alias: Say TTS Message on Google Chrome Browser
mode: single

For it to work, you must have the Browser Mod custom integration installed in HA.

Use the following to define a media player for a browser:

  • start the browser of choice (e.g. Microsoft Edge).
  • browse to the HA url (e.g. http://homeassistant.local:8123/).
  • click on Browser Mod in the HA left-side menu.
  • register the browser using the This Browser settings (see Figure 1 below).
  • set a browser id (e.g. edge_home_office) - must be unique for the browser and device.

Repeat the above settings for each browser that you want to access on each device that you are accessing from. In my case, I just defined the Chrome and Edge browsers on my home office desktop.

Also ensure you allow (unblock) “PopUps”, “Intrusive Ads”, and “Insecure Content” in your browser’s site settings for your Home Assistant domain (e.g. http://homeassistant.local:8123, or whatever URL you use to access HA) for each browser type. Do not enable these settings for ALL domains, as that would be a security risk!

Figure 1 - Microsoft Edge Browser / HA Browser Mod Settings
image

Hope it helps!

@Syon @pduffin @Thonglor @Greek @Alex_Slaets
Here’s a better example, that plays a Radio Station instead of a TTS message.

The automation and service call is easy; the hard part is figuring out the radio station url to play, as the Radio browser integration does not supply this information. You have to go to the Radio Browser Search page to find the station information - use the “Search” box in the upper right on that link and search for the name (e.g. 96.1). It’s not very user-friendly, but it will get you the information you need for the service call.

Once you find the radio station of choice, click it to view the details - it should look something like this:

The key piece of info you are looking for is the url value; in the case of this example, the radio station name is 96.1 The River and it’s url is https://stream.revma.ihrhls.com/zc1001. You might also want to note the favicon url, as it contains an icon image that can be used in a button list of favorites. Also note the UUID value (e.g. 62083e65-51f6-4428-acf7-37b3bfcf2bcb) that is displayed in the page url (e.g. https://www.radio-browser.info/history/62083e65-51f6-4428-acf7-37b3bfcf2bcb)

Once you have the url value, use it in an automation service call to play the station on the media player of your choice:

alias: TEST Browser Play Radio Station Media by URL
trigger: []
condition: []
action:
  - service: media_player.play_media
    alias: Play Radio Station on Home Office Google Chrome Browser
    data:
      media_content_id: https://stream.revma.ihrhls.com/zc1001
      media_content_type: audio/aac
    target:
      entity_id: media_player.chrome_home_office
mode: single

You can also play by using the radio station UUID value. This value is displayed in the search web-site url. You have to use the media-source://radio_browser/<UUID> format. This will instruct HA media browser to do a lookup of the UUID to get the url value like we used in the above service call. I prefer the URL method, as it saves the resources used by the HA media browser performing a lookup of the UUID to get the URL value.

alias: TEST Browser Play Radio Station Media UUID
trigger: []
condition: []
action:
  - service: media_player.play_media
    alias: Play Radio Station on Home Office Google Chrome Browser
    data:
      media_content_id: media-source://radio_browser/62083e65-51f6-4428-acf7-37b3bfcf2bcb
      media_content_type: audio/aac
    target:
      entity_id: media_player.chrome_home_office
mode: single

UPDATE - a note about the media_content_type. You may need to adjust to one of the following values, if the audio/aac value does not work for you. Most streaming radio stations transmit using the AAC codec, but some could use other formats. The formats are:

  • MP3 - audio/mpeg
  • AAC - audio/aac
  • AAC+ - audio/aac
  • OGG - application/ogg

The code used is displayed in the search web-site station details:

Hope it helps!

That works… THX a lot.
I can work with that.
I’m wondering why you have to choose the entity to play on when you can choose a station in the radio browser and just enable it on the spot and on the browser you are using right now.

1 Like

@Syon
Not sure how that works; it appears that “BROWSER” is a built-in media_source choice, though I am not sure where it’s coming from or how it resolves to a media player.

Anyway you gave me a soloution. I`m happy with that. :kissing_heart:

1 Like