Help with automation with motion and sun

Hi all,

I want to create a simple automation that switch on lights in my hallway only when:

  • List item
    It’s between 06.30 and 08.00
    From 10 min before sunset till 21.30

This is my attempt:

automation:
  - alias: Accendi Luce Corridoio se rilevato movimento
    initial_state: 'on'
    trigger:
    - platform: state
      entity_id: binary_sensor.motion_sensor_158d00015adc7c
      to: 'on'
    - platform: state
      entity_id: binary_sensor.motion_sensor_158d0002b439f9
      to: 'on'
    condition:
    - condition: state
      entity_id: light.corridoio
      state: 'off'
    - condition: and
      conditions:
      - condition: sun
        after: sunset
        after_offset: "-00:10:00"
      - condition: time
        after: '06:29:59'
        before: '07:59:59'
      - condition: time
        before: '22:29:59'

But the automation doesn’t work at all.

If I remove the second condition (06.29 - 07.59) it works.

Can someone please help me?

Thank you in advance

That looks to me that your second condition could never be met as it falls after sunrise not sunset try using 24hr time.

It’s already in 24h format. Can you be more specific? Sorry but I’m a bit noob and I don’t understand your suggestion.

This works for me

- alias: 'Living Room Lamp - Sunset inside'
  trigger:
    - platform: sun
      event: sunset
      offset: "+0:55:00"
    - platform: state
      entity_id:
      - group.home_or_not
      to: 'home'
    - platform: state
      entity_id:
      - group.lt_home_or_not
      to: 'home'
    - platform: state
      entity_id:
      - group.lt_home_or_not
      - group.cg_home_or_not
      to: 'home'
  condition:
    - condition: state
      entity_id: group.home_or_not
      state: 'home'
    - condition: state
      entity_id: input_boolean.dusk_inside
      state: 'on'
    - condition: sun 
      after: sunset 
      after_offset: "+0:55:00"
    - condition: state
      entity_id: switch.party
      state: 'off'
    - condition: time
      after: '14:00'
      before: '21:45'
  action:
  - service: script.turn_on
    entity_id: 
      - script.dusk_inside

Maybe if you try

- condition: state
  entity_id: light.corridoio
  state: 'off'
- condition: sun
  after: sunset
  after_offset: "-00:10:00"
- condition: time
  after: '06:29'
  before: '07:59'
- condition: time
  before: '22:29:59'

I think you need:

    condition:
    - condition: state
      entity_id: light.corridoio
      state: 'off'
    - condition: or
      conditions:
      - condition: time
        after: '06:30:00'
        before: '08:00:00'
      - condition: and
        conditions:
        - condition: sun
          after: sunset
          after_offset: '-00:10:00'
        - condition: time
          before: '21:30:00'