Can I do an automation between sunset and 10:00pm?

I want my time triggered automations to run after a restart on HASS but as they only trigger on a specific time they don’t do.

So can I set up an automation like between sunset and 10:00pm?
If so, please show an example or if there are smarter ways I’m all ears :slight_smile:

You should be able to use multiple conditions. One that tests for sunset and the other that tests for before 10pm.

I don’t have the code in front of me but here is a starting point:

- alias: 'Upstairs Light Turn on'
  trigger:
    - platform: event
      event_type: upstairs_light_on
  
  condition:
      condition: state
      entity_id: sun.sun
      state: 'below_horizon'

  action:
    service: light.turn_on
    entity_id: group.upstairs

To build on that.

- alias: 'Upstairs Light Turn on'
  trigger:
    - platform: event
      event_type: upstairs_light_on
  
  condition:
      condition: state
      entity_id: sun.sun
      state: 'below_horizon'
      condition: time
      before: '20:00:00'

  action:
    service: light.turn_on
    entity_id: group.upstairs

Based on information from here

…and this is my version:

automation:
- alias: 01 kitchen area switch on sunset
  trigger:
    platform: sun
    event: sunset
    offset: "-00:15:00"
  action:
    service: switch.turn_on
    entity_id:
     - switch.everspring_an157_plugin_appliance_module_switch_2
     - switch.everspring_an157_plugin_appliance_module_switch_3
     - switch.everspring_an157_plugin_appliance_module_switch_4
     - switch.everspring_an157_plugin_appliance_module_switch_5
     - switch.everspring_an157_plugin_appliance_module_switch_6
    
- alias: 02 kitchen area switch off 1030pm
  trigger:
    platform: time
    after: '22:30:00'
  action:
    service: switch.turn_off
    entity_id:
     - switch.everspring_an157_plugin_appliance_module_switch_2
     - switch.everspring_an157_plugin_appliance_module_switch_3
     - switch.everspring_an157_plugin_appliance_module_switch_4
     - switch.everspring_an157_plugin_appliance_module_switch_5
     - switch.everspring_an157_plugin_appliance_module_switch_6

@mark.carline That’s how I have it setup today and it won’t work if you restart HASS.

@CCOSTAN @rabittn What are you guys doing in the trigger? platform: event and then what?
I haven’t used that type of config, could you please explain how it works?

Also could I add an offset to the sunset and not just go by below horizon?

I think we gave you two different answers based on different requirements.

What is your end goal?

- alias: 'Bedroom Evening'
  trigger:
    - platform: sun
      event: sunset
      offset: "+00:15:00"
#  condition:
#    - condition: state
#      entity_id: device_tracker.pi_reine
#      state: 'home'
  action:
    - service: shell_command.phue_bedroom_evening
```
I would like to add a "before: 10:00pm" so when HASS restarts this rule will trigger.