When creating automations, especialy for light management in particular situations, I run into some dependency issues that are hard to solve.
For instance:
I have a light automation that automaticaly switches on the light in my livingroom, depending on wether my input_boolean.overrule is not ON. My outdoor hue motion sensor registeres the number of lux, and if that is below 850 my lights switch on.
the input_boolean.overrule is turned on when we go to bed and it is switched off 6 hours after sunset.
So far so good.
Now if I want to watch a movie during the day I want to dim the lights when I press Play on my Google TV chromecast ultra in the Netflix or Videoland or Ziggo app.
Because I do not know what the state of my lights is (as it is dependend from the lux sensor) I take a snapshot with scene.create woonkamerlichtstaat. And dim the lights with with scene.beamer_scene.
Now here is the deal:
When I press pause (someone needs to go to the bathroom or so) it should restore the state of the lights with activate scene.woonkamerlichtstaat. But if I am too soon with pressing play again it takes a new snapshot with the wrong (dimmed) settings!
And how is HA managaing lights that are in transition when I use a transistion of (lets say) 45 seconds and in the mean time I take a snapshot?
Can anyone help me out?
This is my current automation yaml:
alias: Beamer_Automation
description: ""
trigger:
- platform: state
entity_id:
- media_player.android_tv_192_168_68_112
id: Off2On
from: "off"
- platform: state
entity_id:
- media_player.android_tv_192_168_68_112
to: playing
id: Any2Playing
- platform: state
entity_id:
- media_player.android_tv_192_168_68_112
to: paused
id: Playing2Paused
- platform: state
entity_id:
- media_player.android_tv_192_168_68_112
to: "off"
id: Any2Off
condition:
- condition: template
value_template: >-
{{ now() - as_datetime(states('sensor.uptime')) >
timedelta(days=0,hours=0,minutes=15) }}
enabled: false
- condition: not
conditions:
- condition: or
conditions:
- condition: state
entity_id: media_player.android_tv_192_168_68_112
state: unavailable
- condition: state
entity_id: media_player.android_tv_192_168_68_112
state: unknown
action:
- choose:
- conditions:
- condition: trigger
id:
- Off2On
sequence:
- service: scene.create
metadata: {}
data:
scene_id: woonkamerlichtstaat
snapshot_entities:
- light.woonkamer_koof_1
- light.woonkamer_koof_2
- light.woonkamer_koof_3
- light.woonkamer_koof_4
- light.woonkamer_koof_5
- light.woonkamer_koof_6
- light.woonkamer_koof_7
- light.woonkamer_koof_8
- light.woonkamer_hoek_lamp
- light.woonkamer_servieskast_lamp
- light.woonkamer_staande_lamp
- conditions:
- condition: trigger
id:
- Any2Playing
sequence:
- service: scene.turn_on
data: {}
target:
entity_id: scene.beamer_scene
- service: notify.mdb055
metadata: {}
data:
message: >-
Playing: {{
state_attr('media_player.android_tv_192_168_68_112', 'app_name')
}} now!
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.overrule
- conditions:
- condition: trigger
id:
- Playing2Paused
sequence:
- service: notify.mdb055
metadata: {}
data:
message: >-
Pausing: {{
state_attr('media_player.android_tv_192_168_68_112', 'app_name')
}} now!
- service: scene.turn_on
metadata: {}
target:
entity_id: scene.woonkamerlichtstaat
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.overrule
data: {}
- conditions:
- condition: trigger
id:
- Any2Off
sequence:
- service: scene.turn_on
data: {}
target:
entity_id: scene.woonkamerlichtstaat
mode: single