Aqara FP2 light sensor lux reading not triggering automation

Hello all,

I set up an automation where when the Aqara FP2’s light sensor detects that the brightness of my living room drops below 30 lux, it will turn on a set of lights around the house. I also set it so that the automation only works in a certain time range of the day.

I set this up late last afternoon, and it worked just fine yesterday. However, for some reason, the automation won’t work today. The lux level has dropped under 30 lux, and yet none of the lights are on. I don’t even think that the automation is triggered. If I go into the automation,right click on it and hit run, then all the lights in the automation lights up, but when I check the traces, it just shows that I manually ran it.

Any idea what might be preventing it from triggering? I’m new to HA and I still have a lot to learn so please be patient with me :slight_smile: I’ll try to provide as much info as possible, but if I’m missing anything or should share things by default when posting a new topic, please do let me know.

Here is the YAML of the automation

> alias: Auto - Lights on when dark
> description: ""
> trigger:
>   - type: illuminance
>     platform: device
>     device_id: 67ca66d15ceb99981adc5d57a709fbc0
>     entity_id: 2e9a13c9d9a63c6a902e5cb323b3971b
>     domain: sensor
>     below: 30
> condition:
>   - condition: time
>     after: "15:00:00"
>     before: "21:00:00"
>     weekday:
>       - sun
>       - mon
>       - tue
>       - wed
>       - thu
>       - sat
>       - fri
> action:
>   - service: light.turn_on
>     data: {}
>     target:
>       entity_id: light.sky_light
>   - service: switch.turn_on
>     data: {}
>     target:
>       entity_id:
>         - switch.accent_light
>         - switch.corner_light
>         - switch.dining_light_switch_1
> mode: single

Screenshot of the automation -

Screenshot of the lux reading (this is accurate to what I’m seeing in the Aqara app as well in case anyone’s wondering) -

and lastly, screenshot of the traces after I run the automation myself-

Use numeric state as the trigger. Not device.

1 Like

If it drops before 30 lux before 15:00, the action won’t run.

Set up two triggers: numeric state for below 30 lux; and time at 15:00.

Then set up two matching conditions.

That way it’ll trigger at 3pm if it’s already dark, or when it goes dark if later.

Hi Rich, thank you for the suggestion, I will try this and update here whether it works or not.

Hi Troon,

this was all after 3pm my time, sorry I realized none of my screenshots clearly shows that. And I don’t actually need it to trigger before 3pm, even if it gets dark since that will most likely be temporary due to cloud coverage.

My suggestion wasn’t to trigger before 3pm, but at 3pm.

The numeric state trigger fires when the value crosses the threshold. If it gets dark before 3pm and stays dark, your automation won’t run. Here’s a potential sequence:

  • 14:55 - light level drops below 30lx. Automation triggers on light level but is blocked by the time condition.

That’s all that happens!

With my suggestion:

  • 14:55 - light level drops below 30lx. Automation triggers on light level but is blocked by the time condition.
  • 15:00 - Automation triggers on time and passes through both conditions.

On a lighter day:

  • 15:00 - Automation triggers on time but is blocked by the light level condition as it’s still bright.
  • 16:30 - light level drops below 30lx. Automation triggers on light level and passes through both conditions.

It triggers on either thing but requires both. In effect it runs when the second of the two conditions becomes true.

2 Likes

Hi Troon,

Ah, I see what you mean. So should I set up something like this?

1 Like

You should use Trigger ID’s. That way you can set up conditions for each trigger seperately.

That’s not necessary here — we always want both conditions to be true before proceeding.

1 Like

Hi Troon,

Just wanted to inform you that your suggestion works! The lights are now triggered by when its dark and after 3pm. Thanks a lot for your help! And thanks to you as well Rich! :slight_smile:

1 Like

Hi,
I have been trying the get my automation working based also on lux value, but I’m unable to succeed.

Please see below yaml code:

and screen shot of automation:

Would you be able to help me? Thanks.

Post code as correctly-formatted text not screenshots on a third-party service that shows me ads.

What isn’t working? What is the lux level at 07:00? If it’s below 500 nothing will happen as the trigger only fires at the instant that the lux level drops from above to below 500. Add a time trigger at 07:00.

Indentation is wrong on the code screenshot but I guess that’s a copy-paste error otherwise you wouldn’t have the UI version.

Hi Troon,

Thanks for the reply, and sorry about the screenshots. I’m new to the community, and this is my first post/question, so I wasn’t allowed to share images in the form.

The problem is that the lights don’t turn on when the lx value is below 500. I don’t need the time trigger, so I can remove it to simplify things.

Please code below:

alias: FP2
  description: ''
  trigger:
  - platform: numeric_state
    entity_id:
    - sensor.aqara_fp2_light_sensor_light_level
    below: 500
  condition:
  - condition: time
    after: 07:00:00
    before: '23:55:00'
  - condition: numeric_state
    entity_id: sensor.aqara_fp2_light_sensor_light_level
    below: 500
  action:
  - service: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.voorkamer
  mode: single

Again, it will only trigger when the value crosses from above to below 500. Please share a 24 hour screenshot of the history of your lux sensor.

Pls see screenshot below:

It’s never above 500, so the trigger will never fire. That’s why you also need a time trigger and perhaps a trigger to fire on restart / reload:

alias: FP2
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.aqara_fp2_light_sensor_light_level
    below: 500
  - platform: time
    at: "07:00"
  - platform: homeassistant
    event: start
  - platform: event
    event_type: automation_reloaded
condition:
  - condition: time
    after: "06:59"
    before: "23:55"
  - condition: numeric_state
    entity_id: sensor.aqara_fp2_light_sensor_light_level
    below: 500
action:
  - service: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.voorkamer
  mode: single

I’ll say it for a third time: A numeric state trigger set to below: 500 will only trigger when the value changes from above 500 to below 500. If the value is already below 500, nothing will happen.

1 Like

Hi Troon,

It works! Thank you for your help; it’s much appreciated. I will now try to optimize the logic to ensure it also turns off the lights when the lux value is high.

Best regards,
Dennis