Skip to content

Instantly share code, notes, and snippets.

@NeskireDK
Created January 26, 2025 14:56
Show Gist options
  • Save NeskireDK/233b166c4916d3b7756de511a78792a4 to your computer and use it in GitHub Desktop.
Save NeskireDK/233b166c4916d3b7756de511a78792a4 to your computer and use it in GitHub Desktop.
Media player controlling lights
blueprint:
name: Media Player Light Automation
description: >
Automatically turn lights on or off based on media player state, power
state, and sun position.
domain: automation
input:
media_player:
name: Media Player
description: The media player to monitor.
selector:
entity:
domain: media_player
condition_bool:
name: Condition (Boolean)
description: Enable or disable sun position condition.
default: false
selector:
boolean:
lights:
name: Lights
description: Lights to control.
selector:
target:
entity:
domain: light
trigger:
- platform: state
entity_id: !input media_player
id: "on"
from:
- "off"
- "standby"
to:
- "idle"
- "paused"
- platform: state
entity_id: !input media_player
id: "off"
from:
- "playing"
- "idle"
- "paused"
to: "standby"
for:
seconds: 1
condition:
- condition: template
value_template: >
{{ not (is_state('sun.sun', 'below_horizon') and not is_state('input_boolean.condition_bool', 'true')) }}
action:
- choose:
- conditions:
- condition: trigger
id: "on"
sequence:
- service: light.turn_on
target: !input lights
- conditions:
- condition: trigger
id: "off"
sequence:
- service: light.turn_off
target: !input lights
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment