Files
N22/include/automations/lightshow.yaml
T

270 lines
9.0 KiB
YAML

# SpotifyPlus + Hue lysshow pr. værelse.
# Baseret på thlucas1's "SpotifyPlus Hue Lightshow"-blueprint:
# https://github.com/thlucas1/homeassistant_blueprints/blob/master/spotifyplus/spotifyplus_hue_lightshow.md
#
# OBS: Kræver at SpotifyPlus-integrationen er sat op (Spotify Premium + OAuth).
# Ret media_player.spotifyplus til den faktiske entity efter opsætning.
- id: lightshow_andreas
alias: "Lysshow: Andreas"
description: Synkroniserer Hue-lys med Spotify-albumcover (SpotifyPlus)
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: input_boolean.lightshow_andreas
to: "on"
- trigger: state
entity_id: media_player.spotifyplus
attribute: media_content_id
- trigger: state
entity_id: media_player.spotifyplus
to: playing
conditions:
- condition: state
entity_id: input_boolean.lightshow_andreas
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
actions:
- variables:
media_player_entity: media_player.spotifyplus
lights:
- light.andreas_lysstrip
- light.andreas_stol
spotify_image_url: "{{ state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
- action: spotifyplus.get_image_palette_colors
data:
entity_id: media_player.spotifyplus
image_source: "{{ spotify_image_url }}"
color_count: 10
color_quality: 1
brightness_filter_low: 100
brightness_filter_high: 600
hue_distance_filter: 10
response_variable: palette_response
- variables:
colors_rgb: "{{ palette_response['result']['items'][:6] | map(attribute='rgb') | list }}"
- repeat:
while:
- condition: state
entity_id: input_boolean.lightshow_andreas
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
- condition: template
value_template: "{{ spotify_image_url == state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
sequence:
- repeat:
count: "{{ colors_rgb | count }}"
sequence:
- action: light.turn_on
target:
entity_id: "{{ lights }}"
data:
rgb_color: "{{ colors_rgb[repeat.index - 1] }}"
brightness_pct: 100
transition: 2
- delay: "00:00:02"
- id: lightshow_daniel
alias: "Lysshow: Daniel"
description: Synkroniserer Hue-lys med Spotify-albumcover (SpotifyPlus)
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: input_boolean.lightshow_daniel
to: "on"
- trigger: state
entity_id: media_player.spotifyplus
attribute: media_content_id
- trigger: state
entity_id: media_player.spotifyplus
to: playing
conditions:
- condition: state
entity_id: input_boolean.lightshow_daniel
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
actions:
- variables:
media_player_entity: media_player.spotifyplus
lights:
- light.daniel_lysstrip
- light.bamse
spotify_image_url: "{{ state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
- action: spotifyplus.get_image_palette_colors
data:
entity_id: media_player.spotifyplus
image_source: "{{ spotify_image_url }}"
color_count: 10
color_quality: 1
brightness_filter_low: 100
brightness_filter_high: 600
hue_distance_filter: 10
response_variable: palette_response
- variables:
colors_rgb: "{{ palette_response['result']['items'][:6] | map(attribute='rgb') | list }}"
- repeat:
while:
- condition: state
entity_id: input_boolean.lightshow_daniel
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
- condition: template
value_template: "{{ spotify_image_url == state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
sequence:
- repeat:
count: "{{ colors_rgb | count }}"
sequence:
- action: light.turn_on
target:
entity_id: "{{ lights }}"
data:
rgb_color: "{{ colors_rgb[repeat.index - 1] }}"
brightness_pct: 100
transition: 2
- delay: "00:00:02"
- id: lightshow_sovevaerelse
alias: "Lysshow: Soveværelse"
description: Synkroniserer Hue-lys med Spotify-albumcover (SpotifyPlus)
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: input_boolean.lightshow_sovevaerelse
to: "on"
- trigger: state
entity_id: media_player.spotifyplus
attribute: media_content_id
- trigger: state
entity_id: media_player.spotifyplus
to: playing
conditions:
- condition: state
entity_id: input_boolean.lightshow_sovevaerelse
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
actions:
- variables:
media_player_entity: media_player.spotifyplus
lights:
- light.sov_midt
- light.sov_vindue
- light.sov_dor
- light.anne
- light.claus
spotify_image_url: "{{ state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
- action: spotifyplus.get_image_palette_colors
data:
entity_id: media_player.spotifyplus
image_source: "{{ spotify_image_url }}"
color_count: 10
color_quality: 1
brightness_filter_low: 100
brightness_filter_high: 600
hue_distance_filter: 10
response_variable: palette_response
- variables:
colors_rgb: "{{ palette_response['result']['items'][:6] | map(attribute='rgb') | list }}"
- repeat:
while:
- condition: state
entity_id: input_boolean.lightshow_sovevaerelse
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
- condition: template
value_template: "{{ spotify_image_url == state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
sequence:
- repeat:
count: "{{ colors_rgb | count }}"
sequence:
- action: light.turn_on
target:
entity_id: "{{ lights }}"
data:
rgb_color: "{{ colors_rgb[repeat.index - 1] }}"
brightness_pct: 100
transition: 2
- delay: "00:00:02"
- id: lightshow_stue
alias: "Lysshow: Stue"
description: Synkroniserer Hue-lys med Spotify-albumcover (SpotifyPlus)
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: input_boolean.lightshow_stue
to: "on"
- trigger: state
entity_id: media_player.spotifyplus
attribute: media_content_id
- trigger: state
entity_id: media_player.spotifyplus
to: playing
conditions:
- condition: state
entity_id: input_boolean.lightshow_stue
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
actions:
- variables:
media_player_entity: media_player.spotifyplus
lights:
- light.pendle1
- light.pendle2
- light.syd
- light.raket
- light.spisebord
- light.panton
spotify_image_url: "{{ state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
- action: spotifyplus.get_image_palette_colors
data:
entity_id: media_player.spotifyplus
image_source: "{{ spotify_image_url }}"
color_count: 10
color_quality: 1
brightness_filter_low: 100
brightness_filter_high: 600
hue_distance_filter: 10
response_variable: palette_response
- variables:
colors_rgb: "{{ palette_response['result']['items'][:6] | map(attribute='rgb') | list }}"
- repeat:
while:
- condition: state
entity_id: input_boolean.lightshow_stue
state: "on"
- condition: state
entity_id: media_player.spotifyplus
state: playing
- condition: template
value_template: "{{ spotify_image_url == state_attr(media_player_entity, 'sp_nowplaying_image_url') }}"
sequence:
- repeat:
count: "{{ colors_rgb | count }}"
sequence:
- action: light.turn_on
target:
entity_id: "{{ lights }}"
data:
rgb_color: "{{ colors_rgb[repeat.index - 1] }}"
brightness_pct: 100
transition: 2
- delay: "00:00:02"