Combine 2 automations into 1

So I created an automation to turn the aquarium light on when the sun goes down, and another automation to turn it off when the sun comes back up again.

- id: '1583341679296'
  alias: Aquarium Light On
  description: ''
  trigger:
  - event: sunset
    platform: sun
  condition: []
  action:
  - data: {}
    entity_id: switch.outlet_hallway
    service: switch.turn_on
- id: '1583342090455'
  alias: Aquarium Light Off
  description: ''
  trigger:
  - event: sunrise
    platform: sun
  condition: []
  action:
  - data: {}
    entity_id: switch.outlet_hallway
    service: switch.turn_off

Instead of creating 2 separate automations, is there a way to combine this?

Thanks

Try this:

- id: 'abc123'
  alias: 'Aquarium Light On/Off'
  description: ''
  trigger:
  - event: sunset
    platform: sun
  - event: sunrise
    platform: sun
  condition: []
  action:
  - data: {}
    entity_id: switch.outlet_hallway
    service_template: "switch.turn_{{'on' if trigger.event = 'sunset' else 'off'}}"

The automation can be triggered by either sunrise or sunset. The service_template uses trigger.event to determine what triggered the automation (sunrise or sunset) and then sets the service to turn_on (for sunset) or turn_off.