So now when we have blueprints, does anyone have one for the old automation cookbook example to dim lights using scenes when playing media?
1 Like
I’ve just converted my automation to a blueprint: https://gist.github.com/MatteoNardi/cf5ea37171a899a5e5915a3ff871fa5b
It’s not exactly as the example though:
- It uses the on/off states (it’s what I have on the webos integration)
- I’ve added an extra step on startup and shutdown (I like to keep lights that way for some seconds to get used to the brightness change)
- I don’t use user-defined scenes (you set brightness in the blueprint settings)
blueprint:
name: Dim lights when playing media
description: 'Change the brightness of a given light when a media player is turned on.
It works on a two step-transition, both on startup and shutdown.'
domain: automation
input:
player_entity:
name: Media player
description: 'The monitored media player'
selector:
entity:
domain: media_player
light_entity:
name: Light controlled
description: 'The light associated to the media player'
selector:
entity:
domain: light
on_brightness:
name: Light brightness when TV is on
default: 0
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: slider
off_brightness:
name: Light brightness when TV is off
default: 100
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: slider
startup_brightness:
name: Brightness used on startup
description: 'On startup we use this brightness for some seconds.'
default: 60
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: slider
shutdown_brightness:
name: Brightness used on shutdown
description: 'On shutdown we use this brightness for some seconds.'
default: 10
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: slider
two_step_delay:
name: Two step delay
description: 'How long we should stay in the temporary states.'
default: 5
selector:
number:
min: 0
max: 1000
unit_of_measurement: "seconds"
source_url: https://gist.github.com/MatteoNardi/cf5ea37171a899a5e5915a3ff871fa5b
trigger:
- platform: state
entity_id: !input 'player_entity'
condition: []
mode: restart
action:
- choose:
- conditions:
- condition: state
entity_id: !input 'player_entity'
state: 'on'
sequence:
- service: scene.apply
data:
transition: 2
entities:
light.salotto:
state: 'on'
brightness_pct: !input startup_brightness
- delay: !input two_step_delay
- service: scene.apply
data:
transition: 2
entities:
light.salotto:
state: 'on'
brightness_pct: !input on_brightness
- conditions:
- condition: state
entity_id: !input 'player_entity'
state: 'off'
sequence:
- service: scene.apply
data:
transition: 2
entities:
light.salotto:
state: 'on'
brightness_pct: !input shutdown_brightness
- delay: !input two_step_delay
- service: scene.apply
data:
transition: 2
entities:
light.salotto:
state: 'on'
brightness_pct: !input off_brightness
default: []
1 Like
Thanks, I’ll try it out at once!
Thanks for sharing your blueprint. Unfortunenately it doesn‘t set up the chosen light source (it keeps light.salotto)
1 Like
Thank you @sirhc! I didn’t notice.
I should have fixed it now: Dim lights when playing media · GitHub
I tried your forked gist, but I think HomeAssistant didn’t like the
entities:
!input 'light_entity':
I found no way to make scene.apply
work with a user specified target, so I replaced it with light.turn_on