Help with automation: condition state and time

Hello,

I hope you can help me. Actually a very simple task but I’m just desperate for it.

The light should automatically approach by means of a movement. But only if a sensor tells me that it is dark and it is between a certain time.

When I remove the time condition it works.

#########BEWEGUNG
  - alias: Badezimmerlicht einschalten tagsueber
    trigger:
      platform: state
      entity_id: sensor.motion_badezimmersensor
      to: 'on'
    condition:
     condition: and
     conditions:
      - condition: state
        entity_id: sensor.badezimmer_dunkel
        state: 'True'
      - condition: time
        after: '05:29:59'
        before: '00:29:59'
    action:
      service: light.turn_on
      entity_id:
        - light.badezimmerdeckenleuchte
        - light.badezimmerspiegel
      data_template:
        brightness: 250

You need to split your time condition, the way it’s written now it can never turn true because there is no time during the day that is after 05:30 and before 00:30 - midnight counts as kind of a cut-off.

And while you’re at it, conditions are always evaluated as AND by default, so you can modify that part as well.

You probably want to try something like this:

    condition:
      - condition: state
        entity_id: sensor.badezimmer_dunkel
        state: 'True'
      - condition: or
          conditions:
            - condition: time
              after: '05:29:59'
            - condition: time
              before: '00:30:01'
1 Like

Thank you. This works fine for me…

Thanks!