Template Help...I think?

- alias: Lights on at Darkness
  trigger:
    platform: numeric_state
    entity_id: sensor.inovelli_lzw60_4_in_1_sensor_luminance
    below: 5
    above: 0
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: group.family_devices
        state: 'home'
      - condition: time
        after: '17:00:00'
  action:
    service: homeassistant.turn_on
    entity_id: group.home_lights

This states that if luminance goes below 5, turn on the lights if someone is home and it is after 5pm. My wife works from home and we don’t want the lights on in the afternoon if it is cloudy/storming - this poses the problem below. The above 0 is there to make sure this automation doesn’t fire when the goodnight script turns the lights off.

Problem: If the luminance drops below 5 before 5pm and stays below until sunset, this automation never fires. I think I need a template to combine some data into a true/false situation but having trouble figuring what kind of template and how I get that into an automation. Can anyone assist?

- alias: Lights on at Darkness
  trigger:
    - platform: time
      at: "17:00:00"
    - platform: numeric_state
      entity_id: sensor.inovelli_lzw60_4_in_1_sensor_luminance
      below: 5
      above: 0
  condition:
    conditions:
      - condition: numeric_state
        entity_id: sensor.inovelli_lzw60_4_in_1_sensor_luminance
        below: 5
      - condition: state
        entity_id: group.family_devices
        state: 'home'
      - condition: time
        after: '17:00:00'
  action:
    service: homeassistant.turn_on
    entity_id: group.home_lights

If I understood you correctly, here’s a quick solution:

  • Use 5pm time as trigger
  • Use numeric state of the luminance sensor as condition.

Multiple triggers…I missed that at the bottom of the docs (sigh) and now I feel like this will work.

I attempted this at one point and it has the opposite affect - if its sunny after 5pm, the lights come on too early.

It wouldn’t (come on early) if you had the right conditions in.
Generally to double the conditions you need to double the triggers.
It doesn’t always apply but it gives you pause to think what are the triggers and what are the conditions before I allow ‘this’ to happen.

Maybe you’d want to trigger on someone coming home at 17:05 instead of already being home at 17:00 ?

You gave a well stated problem that made it much easier to answer.
:+1: