🧯 Script Blueprint to play media player files (NOT an Automation Blueprint)

This is a SCRIPT Blueprint. This provides a way to play canned media files with the big long list of YAML entries but keep the main script or automation clean.

:bookmark_tabs: Changelog

  • 2022-04-11: Add multiple to Speaker Selection and changed minimum HA to 2022.4.0
  • 2021-12-28: First blueprint version :tada:

:envelope_with_arrow: Get Started

I decided I wanted to clean up a bunch of my automations by removing the several lines of YAML every time I wanted to play an mp3 file. In addition to that, playing specific sound files and other things becomes a simple call to a script file, so really a function. The actual meat and potatoes of the function is exactly the same for all the sounders and if a change needs to be made, it only has to be made in 1 place in a multiple re-use scenario.

Option 1: My Home Assistant

Click the badge to import this Blueprint

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Please Click the :orange_heart: at the end of the Post if you find this Useful

Option 2: Direct Link

Copy this link if you want to import the blueprint in your installation.
https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml

:open_book: Description

First, let’s go over Blueprints and what they are. Blueprints are a way to share scripts (in this case) and is built into Home Assistant. Simple as that. You can import my template code and a copy of it will reside in your configuration. Once there, you can can edit it (if you need changes only) or you can call up that Blueprint to build a script. It will collect the information needed based on your entities and your personal adjustments, and provide a working script. You will have to have or add the required hardware and entities that the Blueprint needs to function.

:gear: Usage

:hammer_and_wrench: Installation

  • Open Home Assistant with administrator privileges and on a Lovelace screen, click anywhere in the main entity area and type the letter ‘c’. A selection box should pop up. Type blue and select the button to navigate to blueprints. You can also find blueprints by selecting configuration from the left menu and then blueprints from the center menu.
  • Once there, click on the ‘Import Blueprint’ button in the lower right side of the main screen.
  • In the ‘URL of the blueprint’ line type or paste in the URL of my Blueprint. I have the blueprint stored on my Public REPO on GitHub:

:dna: To make the blueprint work it will need:

1 or more functioning media_players
Media file(s) that are accessible to Home Assistant such that they can be played / displayed thru media_player.

:bulb: Extended Information

This implementation is exactly the implementation in the Home Assistant Docs.
For further information, reference the links below.

(https://www.home-assistant.io/more-info/local-media/add-media/)
(https://www.home-assistant.io/more-info/local-media/setup-media/)
(https://www.home-assistant.io/integrations/media_source/)
(https://www.home-assistant.io/integrations/cast/)
(https://developers.google.com/cast/docs/media/)

Once you have the entities created or decided upon you can build the Automation.
To build the script:

Open your Home Assistant instance and show your blueprints.

  1. Click on ‘Create Script’ Open your Home Assistant instance and show your scripts. and ‘Use Blueprint’
  2. Add a Description so you can tell what this one is for
  3. Use the Drop-downs to select the Entities for the listed purposes
  4. The media_player field will pull from a pick list but you can extend that with multiple media_players or groups as needed by typing them in. Use the links above to help get your system able to play media files.
  5. The media type is where you match how the content is encoded with how the player will play it. Trial and error here can be your friend unless you are much better at figuring this stuff out than me. I generally only use ‘audio/mp3’ and occasionally ‘image/jpg’. More detailed information available in the Google Developers link above.

:globe_with_meridians: All My Blueprints

Link to ALL my Blueprints

Here is a list of each of my blueprints, a quick description and jump links to the Blueprints Exchange post…

:cyclone: Scripts

:fire_extinguisher:Broadlink on Script Blueprint

This is a SCRIPT Blueprint that uses my Broadlink RM3 to turn my TV on and get it into the correct mode, Pushes remote buttons in sequence.

:fire_extinguisher:Tasmota EZ Button Blueprint

This Script Blueprint generates 3 Buttons to help you manage your Tasmota installed base. Restart All, Update a few, and Update all.

:fire_extinguisher:Play Media File Script Blueprint Blueprint

This is a SCRIPT Blueprint. This provides a way to play canned media files with the big long list of YAML entries but keep the main script or automation clean.

:fire_extinguisher:TTS All Message Blueprint

This script can use any of the 11 integrated TTS Platforms in Home Assistant to send a message to a media player.

:arrows_clockwise: Automations

:fire_extinguisher:Auto Fan Control Blueprint

This Blueprint is for controlling a 3 speed fan based on a temperature sensor. Both fan% control & MQTT fan control versions.

:fire_extinguisher:Door Open TTS Cloud-Say Message Blueprint

This Blueprint is a TTS.cloud-say version of another Door Announcer I found in the HA Blueprint Exchange.

:fire_extinguisher:Keypad Lock or puzzle Box Tool Blueprint

This Blueprint accepts 5 actions & when done in the right order, flips an input_boolean.

:fire_extinguisher:Zigbee2MQTT - Xiaomi Cube Controller Blueprint

This Blueprint uses a Zigbee2MQTT built sensor to sort out the multitude of commands from the Xiaomi Magic Cube Remote.

:fire_extinguisher:Zigbee2MQTT - ZemiSmart ZM-RM02 Controller Blueprint

This Blueprint uses the Z2M (Zigbee2MQTT) imported Action sensor to sort out the 18 commands from the ZemiSmart ZM-RM02 Controller.

:man_juggling:t5: Contact Links or see my other work

What are we Fixing Today Homepage / Website: https://www.WhatAreWeFixing.Today/

Channel Link URL: (WhatAreWeFixingToday) https://bit.ly/WhatAreWeFixingTodaysYT

What are we Fixing Today Facebook page (Sir GoodEnough): WhatAreWeFixingToday

What are we Fixing Today Twitter Account (Sir GoodEnough): https://bit.ly/WhatAreWeFixingTodayTW

Discord Guild: (Sir_Goodenough#9683) WhatAreWeFixingToday?

:cheese: If you want to support me

Buy me Coffee: Sir GoodEnough

PayPal one-off donation link: PayPal.Me

#WhatAreWeFixingToday

#SirGoodEnough