#How do I change my Automation from sunset to midnight to come on when it gets too dark

1 messages · Page 1 of 1 (latest)

fierce zealot
#

I know how to do the first bit but not sure how I can easily change it to bring the lights on when it get too dark .sometime. I have added a condition to turn them on from motion sensor with sunrise to sunset, but I added have to them go off later when going to bed. Not sure how the Aqara Motion Sensor P1(Upgraded Version) It has a Illuminance sensor on it but no clue what to pick or how to tell the darkness from it.

median craterBOT
#

Sadly we're not mind readers (any more anyway, not after the last time we tried). Please share the YAML and any errors so we can see what you've done.

fierce zealot
#

Its done in Lx and it was saying 16k is when its fully dark but not sure yet until tomorrow or when it gets darker sooner due to clouds to turn it on!

median craterBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

fierce zealot
#
alias: Kitchen Lights on and off
description: ""
triggers:
  - type: motion
    device_id: 793e3dc77bef44799b9062402e29cc0d
    entity_id: dce87703903b0acb64ae44ec328322e4
    domain: binary_sensor
    id: Lights-on
    trigger: device
  - type: no_motion
    device_id: 793e3dc77bef44799b9062402e29cc0d
    entity_id: dce87703903b0acb64ae44ec328322e4
    domain: binary_sensor
    id: Lights-off
    for:
      hours: 0
      minutes: 3
      seconds: 0
    trigger: device
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Lights-on
          - condition: sun
            after: sunset
            before: sunrise
        sequence:
          - data: {}
            action: light.turn_on
            target:
              entity_id:
                - light.kitchen_led_1
                - light.dig_quad_v3_main
                - light.dig_quad_v3
      - conditions:
          - condition: trigger
            id:
              - Lights-off
        sequence:
          - data: {}
            action: light.turn_off
            target:
              entity_id:
                - light.kitchen_led_1
                - light.dig_quad_v3_main
                - light.dig_quad_v3
mode: parallel
max: 10

ashen rapids
#

From my experience, the P1 has pretty slow update intervals on illuminance unless motion is detected, so that could be why you're seeing a 16k illuminance when it's dark. I'm not 100% certain what that interval is. But I do believe that the illuminance will update immediately when motion is detected. Have you tried checking what that value shows after having triggered motion? I do have an automation based off of a P1 sensor that will turn the lights on when motion is triggered AND only when the reported light level is below a certain threshold. I'll share it here if that helps. A final note on the actual values to use, I've found it best to take that on a room by room basis. I just look at the reported light level when the room is at what I would be considered the point I would consider too dark to rely on ambient light. Then I use that value in my automations.

alias: Master Bath Toilet Light Turn On When Motion Detected
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.master_bath_toilet_motion_sensor_occupancy
    to: "on"
conditions:
  - condition: numeric_state
    entity_id: sensor.master_bath_toilet_motion_sensor_illuminance
    below: 30
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.master_bath_toilet_light_5
mode: single
fierce zealot
#

Thanks! At the moment its 76LX I'm not sure how you are doing your automation to use Motion sensor then turn on with reported light level. Would this be a added condition to they way I have mine setup instead of a trigger has I'm not using a numeric_state so I have added it where I had sunset sun rise. But not sure if correct how I done it. Do I also add 3mins for it to come on?

#
alias: Kitchen Lights on and off illuminance
description: ""
triggers:
  - type: motion
    device_id: 793e3dc77bef44799b9062402e29cc0d
    entity_id: dce87703903b0acb64ae44ec328322e4
    domain: binary_sensor
    id: Lights-on
    trigger: device
  - type: no_motion
    device_id: 793e3dc77bef44799b9062402e29cc0d
    entity_id: dce87703903b0acb64ae44ec328322e4
    domain: binary_sensor
    id: Lights-off
    for:
      hours: 0
      minutes: 3
      seconds: 0
    trigger: device
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Lights-on
          - condition: sun
            after: sunset
            before: sunrise
            after_offset: "-00:015:00"
          - condition: state
            entity_id: sensor.lumi_lumi_motion_kitchen_ac02_illuminance_4
            state: "30"
        sequence:
          - data: {}
            action: light.turn_on
            target:
              entity_id:
                - light.kitchen_led_1
                - light.dig_quad_v3_main
                - light.dig_quad_v3
      - conditions:
          - condition: trigger
            id:
              - Lights-off
        sequence:
          - data: {}
            action: light.turn_off
            target:
              entity_id:
                - light.kitchen_led_1
                - light.dig_quad_v3_main
                - light.dig_quad_v3
mode: parallel
max: 10
ashen rapids
#

I'm not using a choose action like you are. I've just got the single automation to turn the lights on. I use a separate automation for turning them off with no motion. I could probably combine them using trigger IDs, but I actually like having them separated into distinct automations. But if you want to see what it looks like from the visual editor perspective for this single automation, here's some screenshots of how I have it. Having the illuminance check in the "And if" section seems to work fine for me. I think the illuminance reading happens fast enough on motion detection that the automation is able to pick up the new value instead of being fed the old stale value. As for the question on using a delay to turn it on, I never use a delay to turn ON the lights with motion, but I do use a delay when turning them OFF with no motion detected.

ashen rapids
#

One problem I see in your YAML is that you have the condition that the light level must be exactly 30 in order to turn the light on. You probably want that to be BELOW 30. Very rarely will the illuminance be exactly 30 when you trigger motion.

Edit: Actually looking at that again it looks you chose to use "State" instead of "Numeric state" when using the light level in your condition. For numbers (like illuminance) you want to use "Numeric state".

So instead of

- condition: state
  entity_id: sensor.lumi_lumi_motion_kitchen_ac02_illuminance_4
  state: "30"

You need:

- condition: numeric_state
  entity_id: sensor.lumi_lumi_motion_kitchen_ac02_illuminance_4
  below: 30
fierce zealot