Add Media Player Package

This commit is contained in:
2022-05-16 13:19:27 -07:00
parent 3dd1220839
commit 7c93c968f2
3 changed files with 155 additions and 3 deletions

View File

@@ -1,8 +1,53 @@
# Lighting Package
# -----------------------------------------------------------------------------
# Automations for Bedroom Nightstand Lamps
# Lighting State Helpers
input_select:
ht_lighting_mode:
name: Home Theater Lighting Mode
options:
- Normal # Lights Dim on Playing/Pause, Low on Stopped
- Theater # Lights Off on Playing, Dim on Pause, No Change on Stopped
- Disabled # No Lighting Control
initial: Normal
input_button:
ht_reload_lights:
name: 'Reload Home Theater Lights'
icon: mdi:lightbulb-on-outline
# -----------------------------------------------------------------------------
# Home Theater Lighting Scenes
scene:
- name: Home Theater Normal
entities:
light.living_room_light:
state: "on"
brightness: 100
- name: Home Theater Low
entities:
light.living_room_light:
state: "on"
brightness: 50
- name: Home Theater Dim
entities:
light.living_room_light:
state: "on"
brightness: 30
- name: Home Theater Off
entities:
light.living_room_light: "off"
# -----------------------------------------------------------------------------
# Lighting Automations
automation:
# Automations for Home Theater
# Automations for Bedroom Nightstand Lamps
- alias: Jen Nightstand Lamp
mode: single
trigger:
@@ -33,6 +78,7 @@ automation:
entity_id: light.jp_nightstand_light
domain: light
# Automations for Presence Changes
- alias: Turn On Porch Light after Chorale
trigger:
- platform: zone
@@ -44,9 +90,8 @@ automation:
zone: zone.chorale_rehearsal
event: leave
condition:
- condition:
- condition: state
alias: "Sun down"
condition: state
entity_id: sun.sun
state: "below_horizon"
mode: queued

8
packages/media/README.md Normal file
View File

@@ -0,0 +1,8 @@
# Media Package
This package contains configuration information for media players. The following integrations should be set up via the UI:
| Integration | Device Name |
| --- | --- |
| Roku | `media_player.living_room_roku` |
| Denon AVR | `media_player.living_room_receiver` |
| Jellyfin | `media-source://jellyfin` |

99
packages/media/media.yaml Normal file
View File

@@ -0,0 +1,99 @@
# Media Player Package
# -----------------------------------------------------------------------------
# Media Player State Helpers
input_select:
ht_player_state:
name: Home Theater Player State
options:
- Idle
- Playing
- Paused
- Stopped
- System
- Offline
initial: Idle
# -----------------------------------------------------------------------------
# Media Player Scripts
script:
# Update the Player State when an input device changes state. The state of
# the overall player is taken from the state of the currently active input
# device to the receiver.
ht_player_state_update:
name: Home Theater Player State Update
mode: restart
sequence:
- choose:
# Receiver Off (prevents error with source attribute not available
# when receiver is off; normally this is set directly by the Turn-Off
# to Idle automation)
- conditions:
- condition: state
entity_id: media_player.living_room_receiver
state: 'off'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ht_player_state
data:
option: Idle
# Roku Input
- conditions: "{{ state_attr('media_player.living_room_receiver', 'source') == 'Roku Ultra' }}"
sequence:
- choose:
- conditions: "{{ is_state('media_player.living_room_roku', 'playing' }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ht_player_state
data:
option: Playing
- conditions: "{{ is_state('media_player.living_room_roku', 'paused' }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ht_player_state
data:
option: Paused
- condition:
condition: or
conditions:
- "{{ is_state('media_player.living_room_roku', 'stopped' }}"
- "{{ is_state('media_player.living_room_roku', 'idle' }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.ht_player_state
data:
option: Stopped
# -----------------------------------------------------------------------------
# Media Player Automations
automation:
- alias: Home Theater Idle Timeout
trigger:
- platform: state
entity_id: input_select.ht_player_state
to: Stopped
for:
minutes: 10
actions:
- service: input_select.select_option
target:
entity_id: "{{ trigger.entity_id }}"
data:
option: Idle
- alias: Home Theater Receiver Turn-On/Off
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: media_player.living_room_receiver
actions:
- service: script.ht_player_state_update