currently i have the lights on 100% brightness whenever motion is detected.
when the tablet is playing music for the baby’s nap time, HA knows the tablet’s state as media_session= playing
so how do i make the lights on at 20% when motion is detected AND tablet is playing all in 1 automation?
It’s simply a matter of using a template to set brightness
based on the media_player
's state.
Post your automation and I’ll show you how to enhance it with a template.
currently, i do this by having 2 automations. they are same thing. the only difference is the condition of the tablet playing or not:
first
alias: auto turn on living room lights door open or motion timer
description: ""
trigger:
- platform: state
entity_id: binary_sensor.door_living_room_contact
to: "on"
from: "off"
- platform: state
entity_id:
- binary_sensor.besense_home_security_motion_detection
to: "on"
condition:
- condition: time
before: "18:59:00"
after: "07:00:10"
- condition: and
conditions:
- condition: state
entity_id: sensor.tablet_white_media_session
state: unknown
action:
- service: light.turn_on
target:
entity_id: light.light_living_room
data: {}
- service: timer.start
data:
duration: "0"
target:
entity_id: timer.living
mode: single
second
alias: auto turn on living room lights door open or motion timer nap time
description: ""
trigger:
- platform: state
entity_id: binary_sensor.door_living_room_contact
to: "on"
from: "off"
- platform: state
entity_id:
- binary_sensor.besense_home_security_motion_detection
to: "on"
condition:
- condition: time
before: "18:59:00"
after: "07:00:10"
- condition: and
conditions:
- condition: state
entity_id: sensor.tablet_white_media_session
state: unknown
action:
- service: light.turn_on
target:
entity_id: light.light_living_room
data:
brightness_pct: 7
- service: timer.start
data:
duration: "0"
target:
entity_id: timer.living
mode: single
Not exactly the same but very similar use case here.