home-assistant-configuration/config/packages/audio.yaml

109 lines
4.1 KiB
YAML
Executable File

###############################################################################
# @author : Jeffrey Stone
# @date : 04/11/2020
# @package : Audio
# @description : Audio related configuration.
# @notes : This package assumes you are running version .115.0 or greater.
#
###############################################################################
################################
# Media Player section for any media players you want to define. Most of these are setup via the integrations flow in the UI,
# but if not you may need to modify the following section.
# For more info on Media Palyers visit https://www.home-assistant.io/integrations/media_player/
# MODIFY this section as needed or comment it out completely if not needed.
media_player:
- platform: yamaha
host: 192.168.7.152
################################
# Media extractor is used for playing youtube audio. For more info ->https://www.home-assistant.io/integrations/media_extractor/
#
# If you have this enabled in another package or in your configuration.yaml comment out the line below
media_extractor:
################################
# Scripts to handle audio
script:
################################
# local_audio is meant to be used to play audio in your media folder. (https://www.home-assistant.io/integrations/media_source/)
#
# Before using make sure you update as needed.
#
# To call this using in the action section of your automation:
#
# - service: script.local_audio
# data:
# volume: .5
# media: /media/local_audio.mp3
#
local_audio:
sequence:
# Ensure that audible notifications are allowed. Comment out if not needed.
- condition: state
entity_id: input_boolean.audible_notifications
state: 'on'
# Ensure the family is home. If you are using a group to track the family, or a person just update as needed. Comment out if not needed.
- condition: state
entity_id: sensor.family_status
state: Home
# Update the media player with the one you want to use
- service: media_player.turn_on
entity_id: media_player.ha_speaker
# This sets the voume via a parameter when the script is called, and should be a value between .1 and 1.0
- service: media_player.volume_set
data:
entity_id: media_player.ha_speaker
volume_level: >
{{ volume }}
# This tells it to play the media and is set when the script is called.
- service: media_player.play_media
entity_id: media_player.ha_speaker
data:
media_content_type: "music"
media_content_id: >
{{ media }}
################################
# youtube_audio is meant to be used to play audio from well youtube.
# This scrtip requires the media_extractor integration.
#
# Before using make sure you update as needed.
#
# To call this using in the action section of your automation:
#
# - service: script.youtube_audio
# data:
# volume: .5
# media: https://www.youtube.com/watch?v=pVeX4C9B1Lk
#
youtube_audio:
sequence:
# Ensure that audible notifications are allowed. Comment out if not needed.
- condition: state
entity_id: input_boolean.audible_notifications
state: 'on'
# Ensure the family is home. If you are using a group to track the family, or a person just update as needed. Comment out if not needed.
- condition: state
entity_id: sensor.family_status
state: Home
# Update the media player with the one you want to use
- service: media_player.turn_on
entity_id: media_player.ha_speaker
# This sets the voume via a parameter when the script is called, and should be a value between .1 and 1.0
- service: media_player.volume_set
data_template:
entity_id: media_player.ha_speaker
volume_level: >
{{ volume }}
# This tells it to play the media and is set when the script is called.
- service: media_extractor.play_media
entity_id: media_player.ha_speaker
data_template:
media_content_type: video/youtube
media_content_id: >
{{ media }}