#Help with Aqara P1
1 messages · Page 1 of 1 (latest)
Hello, could you post the yaml of the automation? In the editor, top right corner, 3 dots menu, edit in yaml mode, then paste it all here between two pairs of three backticks (`).
alias: New automation
description: ""
triggers:
- type: occupied
device_id: 4b226a1a298654f3028b6d7fdb97b746
entity_id: 7106db74c4018274e09094b69c6511e5
domain: binary_sensor
trigger: device
conditions: - type: is_illuminance
condition: device
device_id: 4b226a1a298654f3028b6d7fdb97b746
entity_id: c2fb2c26878c62d3cc4bed99d46d4aae
domain: sensor
below: 50
enabled: true - condition: sun
after: sunset
enabled: true
actions: - action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.vorzimmer_spot_switch_1 - wait_for_trigger:
- trigger: state
entity_id:- binary_sensor.0x54ef441000daf068_occupancy
to: "off"
from: "on"
for:
hours: 0
minutes: 0
seconds: 20
timeout:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- binary_sensor.0x54ef441000daf068_occupancy
- trigger: state
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.vorzimmer_spot_switch_1 - if:
- condition: state
entity_id: binary_sensor.0x54ef441000daf068_occupancy
state: "off"
for:
hours: 0
minutes: 0
seconds: 20
then: - action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.vorzimmer_spot_switch_1
enabled: true
mode: restart
- condition: state
thank you for the quick respons
I see that you're combining the turning on and turning off in one automation. For starters, it will be easier to understand the logic if you set up one automation to turn on the light when presence is detected, and a second one to turn off the light when no presence is detected for 30s.
A friend of mine set up the automation for me. He is familiar with Home Assistant, but despite many attempts, he unfortunately couldn't get it to work.
You can use a choose path and triggers, but for a beginner I really wouldn't recommend this. It makes things harder to read, the only real benefit is that it condenses the amount of automations you have, which really isn't much of an issue
I would use something like this:
alias: Motion light
description: ""
mode: restart
triggers:
- trigger: state
entity_id: binary_sensor.occupancy
to: "on"
id: turn_on
- trigger: state
entity_id: binary_sensor.occupancy
to: "off"
for:
seconds: 30
id: turn_off
conditions: []
actions:
- choose:
- conditions:
- condition: sun
before: sunrise
after: sunset
- condition: numeric_state
entity_id: sensor.illuminance
below: 50
- condition: trigger
id: turn_on
sequence:
- action: switch.turn_on
target:
entity_id: switch.vorzimmer
- conditions:
- condition: trigger
id: turn_off
sequence:
- action: switch.turn_off
target:
entity_id: switch.vorzimmer