2020-04-14 02:13:04 +00:00
|
|
|
###############################################################################
|
|
|
|
# @author : Jeffrey Stone
|
|
|
|
# @date : 04/11/2020
|
|
|
|
# @package : Audio
|
|
|
|
# @description : Audio related configuration.
|
2020-09-26 14:26:34 +00:00
|
|
|
# @notes : This package assumes you are running version .115.0 or greater.
|
2020-04-14 02:13:04 +00:00
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2020-09-26 14:26:34 +00:00
|
|
|
|
|
|
|
################################
|
|
|
|
# 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.
|
2020-09-29 19:12:07 +00:00
|
|
|
# For more info on Media Players visit https://www.home-assistant.io/integrations/media_player/
|
2020-09-26 14:26:34 +00:00
|
|
|
# MODIFY this section as needed or comment it out completely if not needed.
|
2020-11-07 16:20:26 +00:00
|
|
|
# media_player:
|
|
|
|
# - platform: yamaha
|
|
|
|
# host: 192.168.7.152
|
2020-06-12 20:02:42 +00:00
|
|
|
|
2020-09-26 14:26:34 +00:00
|
|
|
################################
|
|
|
|
# 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
|
2020-06-12 20:02:42 +00:00
|
|
|
media_extractor:
|
2020-05-28 18:58:38 +00:00
|
|
|
|
2020-09-26 14:26:34 +00:00
|
|
|
################################
|
|
|
|
# Scripts to handle audio
|
2020-04-14 02:13:04 +00:00
|
|
|
script:
|
|
|
|
|
2020-09-26 14:26:34 +00:00
|
|
|
################################
|
|
|
|
# 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
|
|
|
|
#
|
2020-09-23 15:00:00 +00:00
|
|
|
local_audio:
|
|
|
|
sequence:
|
2020-09-26 14:26:34 +00:00
|
|
|
# Ensure that audible notifications are allowed. Comment out if not needed.
|
2020-09-23 15:00:00 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.audible_notifications
|
|
|
|
state: 'on'
|
2020-09-26 14:26:34 +00:00
|
|
|
# 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.
|
2020-09-23 15:00:00 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: sensor.family_status
|
|
|
|
state: Home
|
2020-09-26 14:26:34 +00:00
|
|
|
# Update the media player with the one you want to use
|
2020-09-23 15:00:00 +00:00
|
|
|
- service: media_player.turn_on
|
|
|
|
entity_id: media_player.ha_speaker
|
2020-09-26 14:26:34 +00:00
|
|
|
# This sets the voume via a parameter when the script is called, and should be a value between .1 and 1.0
|
2020-09-23 15:00:00 +00:00
|
|
|
- service: media_player.volume_set
|
2020-09-26 14:26:34 +00:00
|
|
|
data:
|
2020-09-23 15:00:00 +00:00
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
volume_level: >
|
|
|
|
{{ volume }}
|
2020-09-26 14:26:34 +00:00
|
|
|
# This tells it to play the media and is set when the script is called.
|
2020-09-23 15:00:00 +00:00
|
|
|
- service: media_player.play_media
|
|
|
|
entity_id: media_player.ha_speaker
|
2020-09-26 14:26:34 +00:00
|
|
|
data:
|
2020-09-23 15:00:00 +00:00
|
|
|
media_content_type: "music"
|
|
|
|
media_content_id: >
|
|
|
|
{{ media }}
|
2020-09-26 14:26:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################
|
|
|
|
# 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
|
|
|
|
#
|
2020-04-14 02:13:04 +00:00
|
|
|
youtube_audio:
|
|
|
|
sequence:
|
2020-09-26 14:26:34 +00:00
|
|
|
# Ensure that audible notifications are allowed. Comment out if not needed.
|
2020-04-14 02:13:04 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.audible_notifications
|
|
|
|
state: 'on'
|
2020-09-26 14:26:34 +00:00
|
|
|
# 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.
|
2020-04-14 02:13:04 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: sensor.family_status
|
|
|
|
state: Home
|
2020-09-26 14:26:34 +00:00
|
|
|
# Update the media player with the one you want to use
|
2020-04-14 02:13:04 +00:00
|
|
|
- service: media_player.turn_on
|
|
|
|
entity_id: media_player.ha_speaker
|
2020-09-26 14:26:34 +00:00
|
|
|
# This sets the voume via a parameter when the script is called, and should be a value between .1 and 1.0
|
2020-04-14 02:13:04 +00:00
|
|
|
- service: media_player.volume_set
|
|
|
|
data_template:
|
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
volume_level: >
|
|
|
|
{{ volume }}
|
2020-09-26 14:26:34 +00:00
|
|
|
# This tells it to play the media and is set when the script is called.
|
2020-04-14 02:13:04 +00:00
|
|
|
- service: media_extractor.play_media
|
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
data_template:
|
|
|
|
media_content_type: video/youtube
|
|
|
|
media_content_id: >
|
|
|
|
{{ media }}
|
2020-12-03 03:55:11 +00:00
|
|
|
|
|
|
|
sensor:
|
|
|
|
- platform: template
|
|
|
|
sensors:
|
|
|
|
room_audio:
|
|
|
|
friendly_name: "Room Audio"
|
|
|
|
value_template: >-
|
2020-12-13 01:50:38 +00:00
|
|
|
{%- if is_state('media_player.theater_tv', 'on') %}
|
|
|
|
theater
|
2020-12-04 17:55:04 +00:00
|
|
|
{% else %}
|
2020-12-13 01:50:38 +00:00
|
|
|
{% set sensor_count = expand('group.occupancy') | selectattr('state', 'eq', 'on') | list | count %}
|
|
|
|
{% if sensor_count >= 1 %}
|
|
|
|
{% for sensor in expand('group.occupancy') %}
|
|
|
|
{% if as_timestamp(sensor.last_changed) == as_timestamp(expand('group.occupancy') | selectattr('state', 'eq', 'on') | map(attribute='last_changed') | max) %}
|
|
|
|
{% if is_state('input_boolean.audible_notifications', 'on') %}
|
|
|
|
{% if sensor.name == 'Kitchen Motion Occupancy' %}
|
|
|
|
kitchen
|
|
|
|
{% elif sensor.name == 'Master Bedroom Occupancy' %}
|
|
|
|
master_bedroom
|
|
|
|
{% else %}
|
|
|
|
main
|
|
|
|
{%- endif %}
|
|
|
|
{% else %}
|
|
|
|
{% if sensor.name == 'Croft Occupancy' %}
|
|
|
|
croft
|
|
|
|
{% else %}
|
|
|
|
kitchen
|
|
|
|
{%- endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-12-04 17:55:04 +00:00
|
|
|
{% endif %}
|
2020-12-04 06:01:28 +00:00
|
|
|
alexa_audio:
|
|
|
|
friendly_name: "Alexa Audio"
|
|
|
|
value_template: >-
|
|
|
|
{%- if is_state('sensor.last_alexa', 'media_player.living_room') %}
|
|
|
|
main
|
|
|
|
{% elif is_state('sensor.last_alexa', 'media_player.kitchen') %}
|
|
|
|
kitchen
|
|
|
|
{% else %}
|
|
|
|
main
|
|
|
|
{%- endif %}
|
2020-12-03 03:55:11 +00:00
|
|
|
last_alexa:
|
|
|
|
value_template: >
|
|
|
|
{{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}
|