Illuminance criteria not working in an automation

I have a Philips motion detector and a Zigbee controlled light. And I have an Automation (shown below) to turn on that light when motion is detected AND it’s dark.

Dark is defined by me as below 50 lux.

Frequently, the script will turn on the light even when it’s not dark. Just now, it was 71 lux (according to the history) and the light turned on anyway.

Reading the trace for the most recent event it says

Triggered by the state of binary_sensor.philips_basement_door_motion_detector at February 28, 2026 at 5:43:25 PM
Test Current Philips Basement Door motion detector Illuminance illuminance
Stopped because a condition failed at February 28, 2026 at 5:43:25 PM (runtime: 0.00 seconds)

or for more detail

Current Philips Basement Door motion detector Illuminance illuminance
Iteration 1
Executed: February 28, 2026 at 5:43:25 PM
Result:
result: false
Current Philips Basement Door motion detector Illuminance illuminance
Iteration 2
Executed: February 28, 2026 at 5:43:25 PM
Result:
result: false
entity_id/0
Executed: February 28, 2026 at 5:43:25 PM
Result:
result: false
state: 71
wanted_state_below: 50
entity: fd1fc2b32d2f4bff665f50306c0635b0

It sure looks like it read the value, said “Nope, not dark enough” and then did it anyway.

Am I missing something ?

alias: Motion - Philips basement door
description: ""
triggers:
  - type: occupied
    device_id: ae5dd4a2bebbda56f4efa9de5fa0d1df
    entity_id: 16474642d8fad8cf5567a13c80f906ce
    domain: binary_sensor
    trigger: device
conditions:
  - type: is_illuminance
    condition: device
    device_id: ae5dd4a2bebbda56f4efa9de5fa0d1df
    entity_id: fd1fc2b32d2f4bff665f50306c0635b0
    domain: sensor
    below: 50
actions:
  - type: turn_on
    device_id: d054336bbe15d287b325be09de9f0b89
    entity_id: 5987e34133d11493648ad989900d80c2
    domain: light
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: d054336bbe15d287b325be09de9f0b89
    entity_id: 5987e34133d11493648ad989900d80c2
    domain: light
mode: single

According to that, it didn’t turn on the light. Are you sure you don’t have another automation that did it? If you look at the log for the light, it should tell you why it turned on and what automation was responsible.

Thanks for the reply, and the hint.

However, it looks like the script did indeed turn it on.

turned on triggered by automation Motion - Philips basement door triggered by state of Philips Basement Door motion detector
5:42:40 PM - 44 minutes ago

The definitive record of the steps performed by the automation are in its trace, specifically its trace file. Its contents are in JSON format and contain more details than what is displayed graphically.

Download and post the automation’s trace file.

If you need instructions for downloading the trace file, refer to this post.

{
  "trace": {
    "last_step": "condition/0/entity_id/0",
    "run_id": "e64535051262d5592d67e63b02b354b0",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2026-03-01T01:43:25.720660+00:00",
      "finish": "2026-03-01T01:43:25.720931+00:00"
    },
    "domain": "automation",
    "item_id": "1764645340564",
    "trigger": "state of binary_sensor.philips_basement_door_motion_detector",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2026-03-01T01:43:25.720786+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.motion_philips_basement_door",
              "state": "on",
              "attributes": {
                "id": "1764645340564",
                "last_triggered": "2026-03-01T01:42:40.849261+00:00",
                "mode": "single",
                "current": 1,
                "friendly_name": "Motion - Philips basement door"
              },
              "last_changed": "2026-02-26T17:54:16.460069+00:00",
              "last_reported": "2026-03-01T01:42:41.593343+00:00",
              "last_updated": "2026-03-01T01:42:40.849308+00:00",
              "context": {
                "id": "01KJKGZQEGTJKZY4RA0ES4JB22",
                "parent_id": "01KJKGZQEGXPXKZZNTTDYXHPDB",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "device",
              "entity_id": "binary_sensor.philips_basement_door_motion_detector",
              "from_state": {
                "entity_id": "binary_sensor.philips_basement_door_motion_detector",
                "state": "off",
                "attributes": {
                  "device_class": "occupancy",
                  "friendly_name": "Philips Basement Door motion detector"
                },
                "last_changed": "2026-03-01T01:43:00.497739+00:00",
                "last_reported": "2026-03-01T01:43:00.497739+00:00",
                "last_updated": "2026-03-01T01:43:00.497739+00:00",
                "context": {
                  "id": "01KJKH0AMH179PRB5BAAMM2KNZ",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.philips_basement_door_motion_detector",
                "state": "on",
                "attributes": {
                  "device_class": "occupancy",
                  "friendly_name": "Philips Basement Door motion detector"
                },
                "last_changed": "2026-03-01T01:43:25.719948+00:00",
                "last_reported": "2026-03-01T01:43:25.719948+00:00",
                "last_updated": "2026-03-01T01:43:25.719948+00:00",
                "context": {
                  "id": "01KJKH138QHGMFYYTPR2NAA4GV",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.philips_basement_door_motion_detector"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2026-03-01T01:43:25.720826+00:00",
          "result": {
            "result": false
          }
        },
        {
          "path": "condition/0",
          "timestamp": "2026-03-01T01:43:25.720849+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/entity_id/0": [
        {
          "path": "condition/0/entity_id/0",
          "timestamp": "2026-03-01T01:43:25.720871+00:00",
          "result": {
            "result": false,
            "state": 71,
            "wanted_state_below": 50
          }
        }
      ]
    },
    "config": {
      "id": "1764645340564",
      "alias": "Motion - Philips basement door",
      "description": "",
      "triggers": [
        {
          "type": "occupied",
          "device_id": "ae5dd4a2bebbda56f4efa9de5fa0d1df",
          "entity_id": "16474642d8fad8cf5567a13c80f906ce",
          "domain": "binary_sensor",
          "trigger": "device"
        }
      ],
      "conditions": [
        {
          "type": "is_illuminance",
          "condition": "device",
          "device_id": "ae5dd4a2bebbda56f4efa9de5fa0d1df",
          "entity_id": "fd1fc2b32d2f4bff665f50306c0635b0",
          "domain": "sensor",
          "below": 50
        }
      ],
      "actions": [
        {
          "type": "turn_on",
          "device_id": "d054336bbe15d287b325be09de9f0b89",
          "entity_id": "5987e34133d11493648ad989900d80c2",
          "domain": "light"
        },
        {
          "delay": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0,
            "milliseconds": 0
          }
        },
        {
          "type": "turn_off",
          "device_id": "d054336bbe15d287b325be09de9f0b89",
          "entity_id": "5987e34133d11493648ad989900d80c2",
          "domain": "light"
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01KJKH138RHDT7V81TM334WYBN",
      "parent_id": "01KJKH138QHGMFYYTPR2NAA4GV",
      "user_id": null
    }
  },
  "logbookEntries": []
}

The trace you posted indicates the automation did not turn on the light.

It did not execute any of its actions because its Numeric Device Condition did not meet the desired criteria (illuminance was not below 50).

"condition/0/entity_id/0": [
  { "path": "condition/0/entity_id/0",
     "timestamp": "2026-03-01T01:43:25.720871+00:00",
     "result": {
        "result": false,
        "state": 71,
        "wanted_state_below": 50 }

But the light came on! And the only way to turn that light on is a button on my screen or an automation. (It’s not controlled by a physical switch.)

And it happened again, this morning, 7:19, sun well up, as I walked past it to take my dogs for a walk. So no tablet or phone, meaning I know I didn’t inadvertently tap my screen.

And exactly as last night, the trace from the automation says “I didn’t turn it on, it was too bright out” and the history from the light says “Yes, you turned it on”.

Automation trace says no.
Device history says yes.

I see only two options, HA logging has a defect or HA automations have a defect. I believe it’s the latter because the light came on.

Maybe I’m missing something obvious, but I can’t see it.

I haven’t experienced anything recently, or in the past, that would lead me to conclude HA automations have a defect.

I have several automations that control lights based on motion detection. They have worked properly for years, including with the latest version of Home Assistant (2026.2.3).

I suggest you review all recent traces for this automation. Find one that reports it turned on the light and take note of the trace’s timestamp.


NOTE

The reason why I asked you to check all recent traces is because the timestamp of the one you posted was for 43 minutes and 25 seconds after the hour. That’s just nearly a minute later than the time reported here:

turned on triggered by automation 
Motion - Philips basement door 
triggered by state of 
Philips Basement Door motion detector
5:42:40 PM - 44 minutes ago
  ^^^^^

The implication is that there is an earlier trace for when the automation did turn on the light.

When the light was turned on, illuminance would increase and the next triggering of the automation (less than a minute later) would produce the kind of trace posted above.

1 Like

Then it’s unlikely it’s being triggered by an that specific automation.

Check your Activity logs for 7:19. If it was indeed triggered by that specific automation, it will say which automation triggered it.

1 Like

Yes, I’ve got quite a number of automations for motion sensors and all have worked fine.

But I’ve just added a couple of Philips outdoor sensors (spectacular devices, if you ask me) to replace conventional, old fashioned (crappy) motion detectors with integral light fixtures … the kind we’ve been buying for 40 years.

Since I see no need to turn on these ridiculously expensive lights needlessly during the daytime, I initially added a sunset/sunrise condition. Then one DARK STORMY day, I wished the lights would come on … it was DARK … but they didn’t, because it was before sunset.

Then I saw the Lux value in the Philips object and went hmmm …

Good.

Please check for a trace with a timestamp that’s about 1 minute earlier than the one you posted above.

Because the time in the activity log:

5:42:40 PM - 44 minutes ago
  ^^^^^

is about a minute earlier than the trace’s timestamp.

"timestamp": {
  "start": "2026-03-01T01:43:25.720660+00:00",
                          ^^^^^

There’s no other traces within hours of the ones we’re talking about, yesterday afternoon or this morning.

And I repeat the point that for both these two anomalies (that I noticed, there might be many more I haven’t noticed), the Automation trace said “No” and the light’s history said “Yes”.

Home Assistant’s system clock operates with microsecond precision. The difference between the timestamps of the trace and light’s activity is 45 seconds which is enormous.

One of my automations controls interior lights based on illuminance. Yesterday, when it turn on lights, the trace’s timestamp was 17:45:03. I checked the activity log of several of the lights controlled by the automation and their timestamps ranged from 17:45:03 to 17:45:05. So within 2 seconds of the automation’s triggering.

In your latest screenshot, the light’s activity log indicates it was turned on at 7:17:03 AM. Please post the corresponding trace file. If it also indicates a 45 second difference, I suggest you submit an Issue to Home Assistant’s Github Core repository.

I’m guessing this may be the result of your home haunting. Check what automation you have added to incorporate this and if it is incorrectly triggering the other lights with inadvertent logic overlap.
The other option is rosary beads. You may need to memorize some chants too…

Also keep in mind that only 5 traces are stored per automation by default. Not seeing a trace doesn’t mean it want triggered, if it triggered 5 more times after that. If that’s the case, increase rhe number of traces stored to debug this.

1 Like

Unfortunately, that trace file is long gone … lots of things walk past the sensor every day, big and small.

I’m just going to remove “Lux” from any automations and not use it again, perhaps going back to sunrise/sunset.

I’ll also try to remove some automations. I actually have almost fifty. Most all are pretty simple … “if this switch pressed, turn on that light” … but maybe 50 is too many. Frankly, this automation with two conditions, motion detected and lux above X, is probably my most complicated.

Or maybe I need a second instance of HA running on some more powerful hardware, and split the devices between them. Currently I have an Odroid N2, which seems like enough … CPU is never above idle and memory is pretty steady at 40% … but maybe it’s not.

For now though, I think I’ll just live with it, and reduce the number of devices and the number of automations. After all, I CAN turn a light off by myself and I CAN turn the heat down at night and up in the morning by myself. Or I can buy some programmable thermostats (which would stink, given that I’ve spent almost a grand on the ones I have now, Sinope Zigbee models.) I can toss the motion sensors and add some old fashioned light fixtures with integral sensors. If I reduce the number of devices and automations, maybe everything remaining will work a bit better.

Yeah, possibly haunted, but I favour a more deterministic explanation, as in, a bug in the code.

Frankly, I’ve always viewed HA as spectacularly good beta software, and a truly amazing toy for genuine geeks (which I was in my youth and am no longer).

But is it a tool? No, not to my mind. “Tool” to my mind implies 100% reliability and HA isn’t there, for any number of reasons, some outside of HA code, some within.

50 definitely isn’t too many, nor is that a complicated automation.

Have you looked at the history of your lux sensor? It might be a bit noisy.

I understand why you might feel that way. I don’t share your opinion because Home Assistant has proven to be very reliable for me since I started using it in 2018.

I suggest you do one of the following:

Find another product that meets your 100% reliability criteria.

OR

Submit the problem as an Issue in Home Assistant’s Github Core repository. Let the development team investigate it. Ensure you are running the latest version of Home Assistant and include a trace file with a corresponding activity log.

The quantity of automations has no bearing on the type of problem you have reported.

1 Like