Turning on lights HUE motion sensor 0.97.2

Hi There
I’m a bit in dark here as my automation dosen’t quite do what it’s supposed to.
It works the first time it’s triggered (and if it hasen’t been triggered for a while) but, the triggering after the lights has gone out is that the lights turn on for half a second or so and then switches off. Could some one please tell me what’s wrong?
Thank you

- alias: Tænd lys i Bryggers ved bevægelse
  - platform: state
    entity_id: binary_sensor.norma_sensor_motion
    to: 'on'
  - condition: state
    entity_id: light.2_bryggers_88923
    state: 'off'
  - condition: numeric_state
    entity_id: sensor.norma_sensor_light_level
    below: '70'
  - service: homeassistant.turn_on
    entity_id: light.2_bryggers_88923
  - delay:
      seconds: '65'
  - service: homeassistant.turn_off
    entity_id: light.2_bryggers_88923

Hi @emeskay first off please can you format your code correctly it makes it incredibly difficult for anyone to help without this.

On to your issue:
I would guess your quick flash is as simple as a state change of the motion sensor is sent every 60 seconds , which is the same as your delay. This will be just as the automation sends the light off command allowing both conditions to be true before the off command has made it to the device.

I see the automation will turn the light on when motion is detected and it’s dark enough but past that I’m a little unsure. Do you want the light to go off 60 seconds after it comes on? or 60 seconds after there is no motion?

Hi @PeteCondliffe
Thanks for the swift response. I’ve now formatted the code correctly now.
What I want to do is to turn the lights off after ‘xx’ seconds. I’ve tried changing this to 65 seconds (and more) with the same results: It works the first time but, the second time it just flashes!!

This may explain whats happning

Could explain why its doing what its doing.

If you add from in your trigger so its does not triggering multiple times whilst there’s motion.

  - platform: state
    entity_id: binary_sensor.norma_sensor_motion
    from: 'off'
    to: 'on'

Hmmm… I still do not think it answers the question. The trigger is the motion sensor to ‘on’ and the condition is if the lights are off and lightlevel under a certain level… So it shouldn’r run twice as the lights will be on!! ?

@emeskay you need to make another automation that turns the light off after X amount of time has elapsed

I’m on mobile so can’t copy my code, but here’s how I’ve done it