Automating white noise with Home Assistant

                                                       

So I have a 12 hour white noise clip I pulled from somewhere some long time ago that I have loaded into my Plex media server. I usually open Plex on my phone and cast it to my Bedtime google group every night but that gets tedious and tiresome after a while. Why not automate it to auto load at 8PM every night? 

If you already have Home Assistant already configured and setup then cool! If not refer to here: Installation Guide. I installed on a Pi 3B+ with 32 gig SD card.


First off, upload the mp3 file to your google drive and make it shareable to all. Follow the steps to get a  an API key and generate a direct google drive link. You will need this if you audio file is large than 100MB as google natively pops up with a display that says too large to scan and thus you cant stream it.
Follow the guide here for more info to get the direct link: https://www.wonderplugin.com/online-tools/google-drive-direct-link-generator/

Once you have this URL go to your Home Assistant portal. Scroll to Configuration --> Automations.

Create a new automation and hit the skip at the bottom as we will be configuring everything manually.
Enter a name, set your trigger to be Time and then input your time in the format of H:MM so 8 PM would be 8:00. I am not doing any conditions at this time so I skipped conditions.

On Actions you select the type to be Call Service. On the second drop down for service select media_player.play_media and then the third drop down to be your smart device you want to cast to. I selected my cast group named media_player.bedtime. Under service data there is an area to input some code Copy the following replacing YOUR URL HERE with the URL to your direct G drive or other hosted linked file. Mind you, you must include the indentation before the URL.


entity_id: media_player.bedtime
media_content_id: >-
 YOU URL HERE
media_content_type: audio/mp4

Hit the save button and to test it, scroll up and hit execute. Feel free to drop a comment below or jump on the forums at Home Assistant if you need more help.

For more info on the media.player Service look here: Media_Player


Comments

Popular posts from this blog

Uninstalling Old Office and Lync in one swoop

Old Bike Pics from the first wreck.

How to add proxyaddresses to multiple Active Directory users with Powershell