Media Player to play local mp3 files from automations, HA running as VM on Linux Mint

Hi,

I’m working on a home alarm system. I have Home Assistant running in a VirtualBox VM on a Linux Mint host. I’m doing OK, but this is my first time using Home Assistant, and every step is a bit of a challenge. I am an embedded system software developer by profession.

I have the system set up to arm with a delay. I would like to play an mp3 file while the delay is running. Eventually I plan to control the system using a wall-mounted tablet, probably running Android. There are plenty of examples of doing this, but they assume there is a media player available and previously integrated with Home Assistant. I don’t happen to have a media player device anywhere in the house that Home Assistant has simply “discovered”. I do have an Amazon Echo Dot, which it seems could be used with the installation of some community supported software and possibly a third party cloud account.

So I’m trying to get some perspective. What I would like to do is play an mp3 file that the operator can hear once the system is commanded to arm. I think I need a “media player” device that Home Assistant can control. What hardware, integrations, devices, etc. can I use to do this? Is there a way to play it through an app on the tablet, or an application already on the linux host computer?

Thanks!
Jim

yes
just need a cast or dlna receiver or soft
throught android or linux
u have to choose the way u ll take because there is lot of solutions to achieve this.
hardware:
rasperpi
sonos
google stuff
alexa
…blablabla
software:
vlc
mpd
squeezbox
logitech media server
volumio
…blablabla
on android
i use the compagnon app but i think u can find lot of way to achieve this
Integrations - Home Assistant (home-assistant.io)

i use a nest mini and a tablette for home notifications

currently trying mpd. I installed mpd on the linux host, but I have no idea how to tell if it is working. Here is my configuration.yaml entry:

# MPD media player on Eagle-III
media_player:
  - platform: mpd
    host: 192.168.1.3
    - service: persistent_notification.create
      data:
        message: "The front door has been opened."
        title: "Should be playing delay_10.mp3 now."
    - service: media_player.play_media
      data:
        entity_id: media_player.mpd
        #media_content_id: https://192.168.1.14:8123/local/config/www/delay_10.mp3 
        media_content_id: https://192.168.1.14:8123/local/delay_10.mp3 
        media_content_type: 'music'

so far, no sound. I may not have mpd installed and configured correctly.

I am making some progress. I now have sound coming from my linux mint desktop where the VM runs as well as a Samsung tablet that is running the Home Assistant app connected to the VM. I am using the browser_mod media player to play the mp3 file. The steps were:

  1. Install Home Assistant Community Store integration.
  2. Install the browser_mod integration. HACS was supposed to help with this, and I created a GitHub login and linked it with HACS, but I ended up with an error and had to download the browser mod files and place them in the correct folders manually, so I probably did not need HACS.
  3. browser_mod created media player entities for my desktop and an android tablet. I gave it a prefix, which it used. I should have been able to switch the unique identifiers to names I entered for each device, but so far this has not worked. There is some messing around with clearing the browser cache, but I’m not sure why I continue to need to use the generated numbers, I’ll look at this again and see if I can improve it.

So, bottom line, the browser_mod integration can definitely be used to play an mp3 file on a particular device that is running the dashboard.

– Jim

The entity names assigned initially by browser_mod have random numbers in them, with the prefix if provided in the configuration.yaml. The alias names did not automatically update any entity names on my system, perhaps this is as expected, but I was able to rename the entities with a better name, and it may be necessary to include the alias in the config as well. Now I have:

browser_mod:
  prefix: "browser_mod_"
  devices:
    9ffdce5e-bb14458a:
      name: galaxy_tab_s2
    eae23ccb-f243e5f3:
      name: eagle
    cd1c49aa-027cea1d:
      name: pegasus
- alias: 'Notify when Front Door Opened'
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.front_door
      #entity_id: group.any_doors_or_windows_open
      #entity_id: browbinary_sensor.any_doors_or_windows_open
      to: "on"
  action:
    #- service: notify.notify
    #  data:
    #    message: "ALARM! The alarm has been triggered"
    - service: persistent_notification.create
      data:
        message: "The front door has been opened."
        title: "Alarm Notification"
    - service: persistent_notification.create
      data:
        message: "The front door has been opened."
        title: "Should be playing exit_10.mp3 now."
    - service: media_player.play_media
      data:
        entity_id: media_player.eagle
        #media_content_id: /local/exit_10.mp3
        media_content_id: http://192.168.1.14:8123/local/exit_10.mp3
        media_content_type: "music"
    - service: media_player.play_media
      data:
        entity_id: media_player.galaxy_tab_s2
        #media_content_id: /local/exit_10.mp3
        media_content_id: http://192.168.1.14:8123/local/exit_10.mp3
        media_content_type: "music"
    - service: media_player.play_media
      data:
        #entity_id: media_player.browser_mod_cd1c49aa_027cea1d  #works
        entity_id: media_player.pegasus
        media_content_id: http://192.168.1.14:8123/local/exit_10.mp3
        media_content_type: "music"

and I manually renamed the actual entities to match the entries in the automation

I hope this is helpful – Jim

1 Like

Does anyone know of a way to specify the media_player entity_id in the automation service such that the media player on the current device is used?

I think I have it sorted out. I installed a Google Nest Mini and am using that to play my mp3 sound files for the alarm. I think part of my issue is that getting the media player set up is so basic it’s hard to find help on how to do it. Here is the process:

  1. Install the Google Home App on a phone. It would not run on my tablet, which is Android 7, but it was ok on my phone which looks to be 12! I’m not sure how my tablet got so far behind!
  2. Connect the Google Nest Mini to my network.
  3. Add it as a new device in the Google Home App. The name given to it is going to be the name used in Home Assistant. I called mine “Hallway speaker”.
  4. Put it on my home network via the WIFI. This is part of the configuration in the Google Home App. It will need the WIFI password.
  5. I immediately made it a static IP on my router to ensure Home Assistant could continue to find it.
  6. My running instance of Home Assistant, which happens to be in a VM on a Linux PC, showed a notification of new devices found, one of which was listed as Google Cast. Note that this is on the Integrations page, not the device page.
  7. Select Configure on the Google Cast integration. The only thing I needed to give it was a location, I entered “Hallway”. The name of the entity ended up being “Hallway speaker”. The entity id ended up as media_player.hallway_speaker.
  8. I edited my Automations.yaml file and used this entity id and, like magic, the Google Nest Mini became the sounder for my alarm system.