2020-04-14 02:13:04 +00:00
|
|
|
###############################################################################
|
|
|
|
# @author : Jeffrey Stone
|
|
|
|
# @date : 04/11/2020
|
|
|
|
# @package : Audio
|
|
|
|
# @description : Audio related configuration.
|
|
|
|
#
|
|
|
|
# In order to use this package you will need a couple of things.
|
|
|
|
#
|
|
|
|
# Add to your configuration.yaml:
|
|
|
|
# media_extractor:
|
|
|
|
#
|
|
|
|
# If you are running Hassio or Home Assistant as it is called now you will need a server that hosts local audio files if you want to leverage those
|
|
|
|
###############################################################################
|
|
|
|
|
2020-06-12 20:02:42 +00:00
|
|
|
media_player:
|
|
|
|
- platform: yamaha
|
|
|
|
host: 192.168.7.152
|
|
|
|
|
|
|
|
media_extractor:
|
2020-05-28 18:58:38 +00:00
|
|
|
|
|
|
|
input_datetime:
|
|
|
|
audible_notification_on:
|
|
|
|
name: Audible Notifications On
|
|
|
|
has_date: false
|
|
|
|
has_time: true
|
|
|
|
audible_notification_off:
|
|
|
|
name: Audible Notifications Off
|
|
|
|
has_date: false
|
|
|
|
has_time: true
|
|
|
|
|
|
|
|
|
2020-08-22 03:45:11 +00:00
|
|
|
|
2020-05-28 18:58:38 +00:00
|
|
|
automation:
|
|
|
|
- id: turn_off_audible_notifications
|
|
|
|
alias: Turn Off Audible Notifications
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: template
|
|
|
|
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.audible_notification_off', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
|
|
|
|
action:
|
|
|
|
- service: input_boolean.turn_off
|
|
|
|
entity_id: input_boolean.audible_notifications
|
2020-06-12 20:02:42 +00:00
|
|
|
|
2020-05-28 18:58:38 +00:00
|
|
|
|
|
|
|
# - id: turn_off_audible_notifications_guests
|
|
|
|
# alias: Turn Off Audible Notifications at 7pm
|
|
|
|
# initial_state: true
|
|
|
|
# trigger:
|
|
|
|
# - platform: time
|
|
|
|
# at: '19:30:00'
|
|
|
|
# condition:
|
|
|
|
# - condition: state
|
|
|
|
# entity_id: input_boolean.guest_mode
|
|
|
|
# state: 'on'
|
|
|
|
# action:
|
|
|
|
# - service: input_boolean.turn_off
|
|
|
|
# entity_id: input_boolean.audible_notifications
|
|
|
|
|
|
|
|
- id: turn_on_audible_notifications
|
|
|
|
alias: Turn On Audible Notifications at 7am
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: template
|
|
|
|
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.audible_notification_on', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
|
|
|
|
action:
|
|
|
|
- service: script.turn_on_ha_speaker
|
|
|
|
|
2020-06-12 20:02:42 +00:00
|
|
|
- id: turn_on_ha_receiver
|
|
|
|
alias: Turn on HA Receiver
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: time
|
|
|
|
at: '06:45:00'
|
|
|
|
action:
|
|
|
|
- service: media_player.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: media_player.tsr_6750_a3ed2f
|
|
|
|
- service: media_player.volume_set
|
|
|
|
data_template:
|
|
|
|
entity_id: media_player.tsr_6750_a3ed2f
|
|
|
|
volume_level: .80
|
|
|
|
|
|
|
|
- id: turn_off_ha_receiver
|
|
|
|
alias: Turn off HA Receiver
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: time
|
|
|
|
at: '23:30:00'
|
|
|
|
action:
|
|
|
|
- service: media_player.turn_off
|
|
|
|
data:
|
|
|
|
entity_id: media_player.tsr_6750_a3ed2f
|
|
|
|
|
|
|
|
|
2020-05-28 18:58:38 +00:00
|
|
|
- id: set_audible_time_off_guest
|
|
|
|
alias: set audible time off guest
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: input_boolean.guest_mode
|
|
|
|
to: 'on'
|
|
|
|
action:
|
|
|
|
- service: input_datetime.set_datetime
|
|
|
|
entity_id: input_datetime.audible_notification_off
|
|
|
|
data_template:
|
|
|
|
time: >
|
|
|
|
{% if states.binary_sensor.school_tomorrow.state == 'on' %}
|
|
|
|
19:30
|
|
|
|
{% else %}
|
|
|
|
20:30
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
- id: set_audible_time_off_normal
|
|
|
|
alias: set audible time off normal
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: input_boolean.guest_mode
|
|
|
|
to: 'off'
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.school_tomorrow
|
|
|
|
action:
|
|
|
|
- service: input_datetime.set_datetime
|
|
|
|
entity_id: input_datetime.audible_notification_off
|
|
|
|
data_template:
|
|
|
|
time: >
|
|
|
|
{% if states.binary_sensor.school_tomorrow.state == 'on' %}
|
|
|
|
19:30
|
|
|
|
{% else %}
|
|
|
|
20:45
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
2020-04-14 02:13:04 +00:00
|
|
|
# # Turn off Input Booleans when audio stops - Based on ha_speaker state.
|
|
|
|
# - id: reset_ib_when_stopped
|
|
|
|
# alias: Reset Input Booleans When Stopped
|
|
|
|
# initial_state: true
|
|
|
|
# trigger:
|
|
|
|
# - platform: state
|
|
|
|
# entity_id: media_player.ha_speaker
|
|
|
|
# to: "off"
|
|
|
|
# action:
|
|
|
|
# - service: homeassistant.turn_off
|
|
|
|
# entity_id: group.disney_audio
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
|
|
|
youtube_audio:
|
|
|
|
sequence:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.audible_notifications
|
|
|
|
state: 'on'
|
|
|
|
- condition: state
|
|
|
|
entity_id: sensor.family_status
|
|
|
|
state: Home
|
|
|
|
- service: media_player.turn_on
|
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
- service: media_player.volume_set
|
|
|
|
data_template:
|
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
volume_level: >
|
|
|
|
{{ volume }}
|
|
|
|
- service: media_extractor.play_media
|
|
|
|
entity_id: media_player.ha_speaker
|
|
|
|
data_template:
|
|
|
|
media_content_type: video/youtube
|
|
|
|
media_content_id: >
|
|
|
|
{{ media }}
|