Need help with timer automation and light senor

Hi
I need some help with the following.
I created an automation wich turns on my stair lights during the day when it’s to dark in the stairwell.

The automation is motion activated based on and has a condition that is day and the level of light.

The light turns off after a timer helper is finisched. All works fine here but…

As soon as the light turns on the level of the light turns above the set treshhold and the light does not turn off.

Now I could create different automations but i was wondering if I could do this in one just to keep things simple

My automation looks like this

alias: beweging_overloop_dag
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.bewegingsmelder_overloop_zb_occupancy
    to: "on"
    from: "off"
    id: timerstart
  - platform: state
    entity_id:
      - timer.overloopverlichting_dag
    to: idle
    id: timerklaar
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.bewegingsmelder_overloop_zb_illuminance_lux
        below: 8
        enabled: false
      - condition: state
        entity_id: input_boolean.isdark
        state: "off"
action:
  - choose:
      - conditions:
          - condition: trigger
            id: timerstart
        sequence:
          - service: timer.start
            data: {}
            target:
              entity_id:
                - timer.overloopverlichting_dag
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.lamp_overloop_trap_zb
      - conditions:
          - condition: trigger
            id: timerklaar
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id:
                - light.lamp_overloop_trap_zb
mode: single

  1. Remove the Numeric State Condition.
  2. Replace the first State Trigger with a Template Trigger that checks if the binary_sensor is on and the sensor value is below 8.

Ok that seems a solution.

Anyone who could give me a hand with that… I’m not that into Yaml

Kind regards
Vincent

alias: beweging_overloop_dag
description: ""
trigger:
  - platform: template 
    value_template: >
      {{ is_state('binary_sensor.bewegingsmelder_overloop_zb_occupancy', 'on') and 
        states('sensor.bewegingsmelder_overloop_zb_illuminance_lux') | float(99) < 8 }}
    id: timerstart
  - platform: state
    entity_id:
      - timer.overloopverlichting_dag
    to: idle
    id: timerklaar
condition:
  - condition: state
    entity_id: input_boolean.isdark
    state: "off"
action:
  - choose:
      - conditions:
          - condition: trigger
            id: timerstart
        sequence:
          - service: timer.start
            data: {}
            target:
              entity_id:
                - timer.overloopverlichting_dag
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.lamp_overloop_trap_zb
      - conditions:
          - condition: trigger
            id: timerklaar
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id:
                - light.lamp_overloop_trap_zb
mode: single

Unfortunately this is not the trick as well.!

Altough it fixes the issue of not turning the light off is will prevent the timer from starting again as long as there is someone in the stairwell or the hallway. Again because of the lightsensor that tells the automation not to fire as soon as the lux value is above the determined value.

Still looking for a solution :grinning:

Good; that was the goal.

As long as the light sensor is in view of the light source, you will continue to have problems controlling the light (with a combination of light level and movement).

The way I do this is by locating my light sensor in a place that is not in direct view of any light source (only indirect lighting).


EDIT

Try this version and adjust it to your needs (it doesn’t use a timer entity and relies on a State Trigger’s for option).

  • For turning on the light, it monitors movement and light level.
  • For turning on the light, it only monitors the lack of movement (for 2 minutes).
alias: beweging_overloop_dag
description: ""
trigger:
  - platform: template 
    value_template: >
      {{ is_state('binary_sensor.bewegingsmelder_overloop_zb_occupancy', 'on') and 
        states('sensor.bewegingsmelder_overloop_zb_illuminance_lux') | float(99) < 8 }}
    id: 'on' 
  - platform: state
    entity_id: binary_sensor.bewegingsmelder_overloop_zb_occupancy
      - timer.overloopverlichting_dag
    to: 'off'
    from: 'on'
    for:
      minutes: 2
    id: 'off' 
condition:
  - condition: state
    entity_id: input_boolean.isdark
    state: "off"
action:
  - service: 'light.turn_{{ trigger.id }}'
    data: {}
    target:
      entity_id:
        - light.lamp_overloop_trap_zb
mode: single

The solution was to use another light sensor and forget the aqara p1 build in one.

Not ideal sins i rely on mostly the build in ones. If I have more time I think another solution maybe to change the light report interval or ignore value changes under a certain level ( my Z wave motion sensors do have that option.) But my garage is so well lit that that would be impossible there.

Thanks for your support!!