#Help with Aqara P1

1 messages · Page 1 of 1 (latest)

clever hazel
#

Hello, can someone help me out? I'm new to HA. I tried setting up an automation for my Aqara P1. It should stay on as long as it's active and turn off 10–30 seconds after it becomes inactive. Additionally, it should only turn on when the sun isn't shining.

brave surge
#

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 (`).

clever hazel
# brave surge

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
  • 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
clever hazel
brave surge
#

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.

clever hazel
lime palm
tribal jacinth
#

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