Trigger numeric state not working

I am trying to turn on a light when a sensor is above an x number using numeric_state, but I cannot get it to trigger. What am I doing wrong?

sensor.front_illuminance

sensor range: 0.12 (full light source) - 1 (no light source)

For the below automation, I want the light to turn on if above 0.19.

automation:

- alias: 'livingroom lights on when dark'
  trigger:
    - platform: numeric_state
      entity_id: sensor.front_illuminance
      above: 0.19
  action:
    - service: light.turn_on
      data:
        entity_id: light.computer_room

A numeric_state trigger only triggers on the transition to the target state (i.e., the test changes from false to true), not simply if the test is satisfied. If you manually set the value of that sensor to less than 0.19 and then to greater than 0.19, it should trigger.

If you want to execute the action whenever the value reported by the sensor is above 0.19, then you’d need something like the following:

- alias: 'livingroom lights on when dark'
  trigger:
    - platform: state
      entity_id: sensor.front_illuminance
  condition:
    - condition: numeric_state
      entity_id: sensor.front_illuminance
      above: 0.19
  action:
    - service: light.turn_on
      data:
        entity_id: light.computer_room

But based on your automation, I suspect that you’re just not transitioning from below 0.19 to above it when you’re testing.

6 Likes

Well, I feel stupid. :blush:
Your sample code gave me more reason to poke around my setup when it still didn’t trigger. What happened was, I had turned off the automation a few days ago during my setup/testing and totally forgot it was off since.

My original code above works; the automation was turned off was why it didn’t triggered. Now it is coming back to me. I remembered it worked a few days ago and I was scratching my head why it isn’t working now.

Thanks @rccoleman. I was trying to do that but couldn’t figure out how to do :grinning: