Outdoor lights with motion and timebased

Hi there

I have a set of outdoor light i’d like to turn on when:

Dark / night

  • it’s dark outside and there is motion detected
  •  Then turn off after 300 secs unless other motion is detected
    

General
in the evening turn lights on when lux outside is less than 200 and turn them off again at 23:30
In the morning turn them on at 05:30 and turn off again when lux reaches 600

So far, so good, they work fine when not combined.
If I just have the script running and there is motion while it’s running, lights go off after 300 secs.
If I just have the motion for dark / night running it works but I can’t have the time / lux based automation running. I’m running in circles here :slight_smile:

My “Motion” script is based on YAMA V10:

alias: Aussenbeleuchtung Motion
description: ""
use_blueprint:
  path: networkingcat/yet_another_motion_automation.yaml
  input:
    motion_entity: binary_sensor.bewegung_aussen
    light_target:
      entity_id:
        - light.ab_alle
    no_motion_wait: 300
    automation_blocker: binary_sensor.draussen_dunkel
    automation_blocker_boolean: true
    no_motion_blocker_boolean: false

and my time / lux based script:

alias: Aussenbeleuchtung Zeit / Lux
description: ""
triggers:
  - trigger: time
    at: "05:30:00"
    id: ABZeitAn
  - trigger: time
    at: "23:30:00"
    id: ABZeitAus
  - trigger: numeric_state
    entity_id:
      - sensor.gw2000a_solar_lux
    id: ABLuxAn
    below: 200
  - trigger: numeric_state
    entity_id:
      - sensor.gw2000a_solar_lux
    id: ABLuxAus
    above: 600
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - ABZeitAn
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.ab_alle
            data: {}
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.aussenbel_uber_zeit_strg_an
      - conditions:
          - condition: trigger
            id:
              - ABLuxAn
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.ab_alle
            data: {}
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.aussenbel_uber_zeit_strg_an
      - conditions:
          - condition: trigger
            id:
              - ABZeitAus
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.ab_alle
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.aussenbel_uber_zeit_strg_an
      - conditions:
          - condition: trigger
            id:
              - ABLuxAus
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.ab_alle
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.aussenbel_uber_zeit_strg_an
mode: single

I also created a binary sensor template in configuration YAML, I read somewhere I need this to combine “on” and “true” into something I can use.

binary_sensor:
  - platform: template
    sensors:
      aussenbeleuchtung_aktiv:
        friendly_name: "Außenbeleuchtung aktiv"
        value_template: >-
          {{ is_state('input_boolean.aussenbel_uber_zeit_strg_an', 'true') and
             is_state('binary_sensor.draussen_dunkel', 'on') }}

So, as said, right now, I’m running in circles and have no clue anymore where to start changing my script logic.
Any help is highly appreciated.

thanks