Solved: Condition "time" doesn't work

I’m using this automation to switch on my lights. At the evening after sunset the lights are dimmed if someone walked in front of the motion sensor. Now I want to add a new condition time. Only after sunset and after 8pm the lights should be triggered. But it doesnt work. If I remove the time condition it works. Tested at 22:00 local time. My code:

- id: Bewegung FlurOG Nachts EIN
  alias: Bewegung FlurOG Nachts EIN
  trigger:
  - entity_id: binary_sensor.flurog_sensorog_move
    platform: state
    to: 'on'
  - entity_id: binary_sensor.flurog_sensoreg_move
    platform: state
    to: 'on'
  condition:
  - condition: time
    after: '20:00:00'
    before: '23:00:00'
  - condition: sun
    after: sunset
    after_offset: -01:00:00
  - condition: sun
    before: sunrise
    before_offset: +01:00:00
  action:
  - data:
      brightness_pct: '10'
      color_name: white
      entity_id: light.flurog
    service: light.turn_on

It can’t be both after sunset and before sunrise (unless with the offsets they overlap.) Before sunrise is the period of time between midnight and sunrise. After sunset is the period between sunset and midnight. Hence, it can’t be both between midnight and sunrise AND between sunset and midnight.

You should change this:

  - condition: sun
    after: sunset
    after_offset: -01:00:00
  - condition: sun
    before: sunrise
    before_offset: +01:00:00

to:

  - condition: or
    conditions:
    - condition: sun
      after: sunset
      after_offset: -01:00:00
    - condition: sun
      before: sunrise
      before_offset: +01:00:00

Ok thanks. The evening/night automation seems to work. But my day automation for the same bulb and motion sensor doesnt work. Should only switch on the light during the day (07:00:00 - 20:00:00) but it triggers at night, too.

Night:

- id: Bewegung FlurOG Nachts EIN
  alias: Bewegung FlurOG Nachts EIN
  trigger:
  - entity_id: binary_sensor.flurog_sensorog_move
    platform: state
    to: 'on'
  - entity_id: binary_sensor.flurog_sensoreg_move
    platform: state
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: or
      conditions:
      - after: sunset
        after_offset: -01:00:00
        condition: sun
      - before: sunrise
        before_offset: +01:00:00
        condition: sun
    - after: '20:00:00'
      before: '07:00:00'
      condition: time
  action:
  - data:
      brightness_pct: '10'
      color_name: white
      entity_id: light.flurog
    service: light.turn_on

During Day:

- id: Bewegung FlurOG Tag EIN
  alias: Bewegung FlurOG Tag EIN
  trigger:
  - entity_id: binary_sensor.flurog_sensorog_move
    platform: state
    to: 'on'
  - entity_id: binary_sensor.flurog_sensoreg_move
    platform: state
    to: 'on'
  condition:
  - condition: and
    conditions:
    - condition: or
      conditions:
      - after: '07:00:00'
        before: '20:00:00'
        condition: time
      - before: sunset
        before_offset: -01:00:00
        condition: sun
      - after: sunrise
        after_offset: +01:00:00
        condition: sun
    - condition: or
      conditions:
      - below: '6'
        condition: numeric_state
        entity_id: sensor.flurog_sensoreg_light
      - below: '6'
        condition: numeric_state
        entity_id: sensor.flurog_sensoreg_light
  action:
  - data:
      brightness_pct: '70'
      color_name: white
      entity_id: light.flurog
    service: light.turn_on

Well, you set it up to run if it’s after 07:00:00 and before 20:00:00, or after midnight and before an hour before sunset, or after an hour after sunrise and before midnight. I’d say that pretty much covers the whole day.

Yep thanks, that was the mistake. Last night I had a mental block.