Light automation on based on lux trigger - not working

I have a weather station integration with Tempest into HA. One of the sensors is lux. Based on sunlight/lux I want to trigger an automation to turn on a light. Currently it works when the value drops below the value in the automation, but not when it’s already in the range. Example: lux set to 15,000 or less. It works if lux drops from 16,000 to below 15,000. It doesn’t work if say the lux is already 15,000 or less. I’ve tried both a numeric and device trigger with neither working. I feel like I’m missing something here. Any advice is appreciated. Below is a YAML output of the current automation. Yes I’ve validated the lux sensor is updating correctly in HA.

alias: Lights - Tempest Lux On
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.wstation_tempest_sensors_illuminance
    below: 1500
condition:
  - condition: time
    after: "08:18:00"
    before: "19:00:00"
action:
  - type: turn_on
    device_id: e9f1b5fb28f6bda1f02c6ea54d1563bb
    entity_id: e8682277248efc3ce7d96edea184d7be
    domain: light
mode: single

Here is the YAML output of the device trigger vs numeric.

alias: Lights - Tempest Lux On
description: ""
trigger:
  - type: illuminance
    platform: device
    device_id: b435229b33517ed666177917ba29eb8f
    entity_id: b18a8ecd80cbc03237dc52c340e8c540
    domain: sensor
    below: 1500
condition:
  - condition: time
    after: "08:18:00"
    before: "19:00:00"
action:
  - type: turn_on
    device_id: e9f1b5fb28f6bda1f02c6ea54d1563bb
    entity_id: e8682277248efc3ce7d96edea184d7be
    domain: light
mode: single```

for me i dont use “numeric_state” but this : YAML style : in condition place of the automation :

type: is_illuminance
condition: device
device_id: d5cf3251b5a3438aafe092014b9b4b06
entity_id: sensor.pir_wc_bas_illumination
domain: sensor
below: 100

and it works great

so your trigger is null?

Do it like this instead:

alias: Lights - Tempest Lux On
description: ""
trigger:
  - platform: state
    entity_id: sensor.wstation_tempest_sensors_illuminance
    to: # null to triggers on all state changes, ignores attribute changes.
condition:
  - condition: time
    after: "08:18:00"
    before: "19:00:00"
  - condition: numeric_state
    entity_id: sensor.wstation_tempest_sensors_illuminance
    below: 1500
1 Like

no lol,

its a motion sensor :

type: motion
platform: device
device_id: 96867ca8496642fb60e60073b72f5f8a
entity_id: binary_sensor.pir_wc_bas
domain: binary_sensor
id: "on"
for:
  hours: 0
  minutes: 0
  seconds: 1

You should really avoid device ids. See: Why and how to avoid device_ids in automations and scripts

1 Like

@tom_l I made the change and waited for the id to update, but the light didn’t trigger. any ideas on my code below? Maybe I’m missing something? If I run the automation manually, the light does turn on.

alias: Lights - Tempest Lux On
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.butler_tempest_sensors_illuminance
    to: null
condition:
  - condition: time
    after: "08:18:00"
    before: "19:00:00"
  - condition: numeric_state
    entity_id: sensor.butler_tempest_sensors_illuminance
    below: 1500
action:
  - type: turn_on
    device_id: e9f1b5fb28f6bda1f02c6ea54d1563bb
    entity_id: e8682277248efc3ce7d96edea184d7be
    domain: light
mode: single

newer to HA. Will look at this as well. Loving HA overall though. So powerfull, just a learning curve somewhat coming from Smartthings.

Try replacing:

to: null

With

to: ~

Also is the current time in your specified range?

Yes. I’m in America/Chicago timezone. When I replace the null with ‘~’ via YAML editor, it replaces it with null again upon refresh.

found an issue, retesting. Wanted lux below 15,000 not 1500

Solved! Thank you so much for the help folks.

1 Like

thanks @tom_l

it as made it automaticaly.

your link is interesting