Here is a tested and working sample:
[code]- alias: ‘HA_Start’
trigger:
platform: event
event_type: homeassistant_start
condition:
- platform: sun
after: sunset
after_offset: “-01:30:00” - platform: time
before: ‘23:30:00’
action:
service: homeassistant.turn_on
entity_id: switch.SW1[/code]
This code could be included into the configuration.yaml file, at automation section. Of course you may change or erase the conditions and the parameters.