I’m finding bits and pieces (yes, I used chatGPT 4) to try to get this to work, but, I’m missing it. I just want a sound to play when I walk into the room via a Google Home device. I can announce other things via voice on the Google Home, but, I can’t get sounds to play. I have HA running inside of VirtualBox on a Mac Mini. Zigbee motion sensors work perfectly for my other 59 automations. Just cannot figure out how/where to put sounds. Explain it like I’m 5. Thank you.
If I’m not mistaken, the file you want to play needs to be publicly accessible (for Google to access it) so put it in you ‘www’ folder somewhere, then made a service call such as:
- service: media_player.play_media
data:
entity_id: media_player.broadcast_group
media_content_id:: "https://redacted.ui.nabu.casa/local/sounds/doorbell_ring_chime.mp3"
media_content_type: 'audio/mp3'
‘/local’ is the same as ‘/www’
Make sure you put your “sound” into “My Media” then something like this should work, I tried it here and worked first time.
description: ""
mode: single
trigger:
- type: motion
platform: device
device_id: 38ea012c124ab77b5d1421ed9e096d70
entity_id: 7afdb2570308d95b72ebe71c915df82f
domain: binary_sensor
condition: []
action:
- service: media_player.play_media
target:
entity_id: media_player.dining_room_display
data:
media_content_id: media-source://media_source/local/Early-morning-sounds-in-a-village.mp3
media_content_type: audio/mpeg
metadata:
title: Early-morning-sounds-in-a-village.mp3
thumbnail: null
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://media_source
1 Like
Perfect–works flawlessly! The piece I wasn’t understanding was where to put the media. Somehow, I got to the Media area and simply uploaded my sound and your code pointed right to it.