I’m bit strugling to make one of my automations work.
I have LED light that switches on if my Aqara motion sensor senses movement and it dark enough. This part works perfectly.
But second part is switching it off. Idea is to switch LED off if there is no motion in the room OR brighnes is above certain treshold. I’ve done it using Conditions but doesn’t seems to work.
Does anyone have any ideas whats wrong?
alias: Livingroom LED light togle on motion and presence
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.motion_sensor_2_occupancy
to: "on"
conditions:
- condition: numeric_state
entity_id: sensor.motion_sensor_2_illuminance
below: 35
actions:
- action: light.turn_on
metadata: {}
data:
kelvin: 4141
brightness_pct: 100
target:
entity_id: light.h6076
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.everything_presence_lite_8fc9d4_occupancy
state: "off"
for:
hours: 0
minutes: 0
seconds: 10
sequence:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.h6076
- conditions: []
sequence:
- wait_for_trigger:
- trigger: numeric_state
entity_id:
- sensor.motion_sensor_2_illuminance
above: 60
continue_on_timeout: false
- action: tts.edge_tts_say
data:
cache: true
entity_id: media_player.tab1
message: >-
It seems that it's bright enough in the living room. Let me
switch lights off for you.
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.h6076
mode: single
I’d suggest to first think of it as two automations. Code it as such, you have the turn on automation, create a shut off light automation as you want it.
Then look into Trigger IDs.
You can have two different Triggers in one automation. User gives a name (trigger ID) to each trigger.
In the Actions (Then Do) section, add a Building Block CHOOSE. Each Choose option will operate like it’s own automation.
I found a walk through of the process, but it’s ad-laden. See if it helps to make sense of it:
I think Bob is giving good advice. I used to try to do things in these Uber-Automations and mostly just gave myself a headache. Once I separated things more it really helped. Sure, it’s a longer list of automations, but I think it’s easier to understand and troubleshoot. Here are my on and off automations for my dining room. On if the room becomes occupied and it’s dark enough. Off if the room becomes unoccupied or it gets bright enough you don’t need it.
One other thing. Don’t use device actions like I did. That was early me learning stuff, and now I know what a pain it is to update everything if you change out a device. Use the actual switch or light as the target. That way if you swap the device you can make sure the actual switch/light has the same name and won’t have to update the automations. I’m working through all my automations to fix that.
The ON one also has some logic so the dining room won’t come on in the middle of the night. The cats triggered it periodically otherwise, and the dining room light shined right into the bedroom.
If you’re just starting out, I second @pkscout 's suggestion.
Once you’re a little more comfortable with things - and you want to cut back on the sheer number of automations - you can combine automations like these by assigning a ‘Trigger ID’.
Then you pick up the ‘Trigger ID’ again for choosing which action to take, incl. potential additional conditions.
This single automation turns two different air purifiers on and off depending on the air quality their sensors report, i.e. four automations in one.