Dusk

The Dusk trigger fires at dusk, the moment the evening twilight ends and the last daylight fades after the sun has set. You choose how dark “dusk” is with the twilight type: civil, nautical, or astronomical. Home Assistant calculates the exact time for every day from your home location.

Use it to close blinds for the night, switch to evening lighting, or arm a routine once it is genuinely dark outside rather than at a fixed clock time.

Using this trigger from the user interface

If you prefer building automations visually, Home Assistant walks you through this trigger step by step. You pick what to watch, tweak a few options, and save. No YAML knowledge required.

To use this trigger in an automation:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the When section, select Add trigger.
  4. From the search box, search for and select Sun: Dusk.
  5. Under Twilight type, select Civil, Nautical, or Astronomical to choose how dark the end of dusk is.
  6. Select Save.

Options in the UI

Twilight type

The phase of twilight that marks the end of dusk:

  • Civil: the sun is 6° below the horizon. The brightest twilight, with enough light for most outdoor activities. This is the default.
  • Nautical: the sun is 12° below the horizon. The horizon is still faintly visible at sea.
  • Astronomical: the sun is 18° below the horizon. The sky is, for most purposes, fully dark.

Using this trigger in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, refer to this trigger as sun.dusk. A basic example looks like this:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
trigger: sun.dusk

This fires at civil dusk every day. To pick a different twilight phase, add the type option:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
trigger: sun.dusk
options:
  type: astronomical

Options in YAML

type string

The phase of twilight that marks the end of dusk. Accepts civil (sun 6° below the horizon), nautical (12° below), or astronomical (18° below).

Good to know

  • This trigger does not use a target. It applies to the sun at your configured home location.
  • Dusk always happens after sunset. Sunset comes first, then civil dusk, then nautical, then astronomical dusk last.
  • The length of twilight changes through the year and with your latitude. Near the poles, a twilight phase can fail to occur on some days. When that happens, the trigger does not fire for that day.
  • For the matching moment in the morning, use Dawn.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, then change the state of the targeted entity to watch the trigger fire on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].

For this trigger, there is no target entity to change. To test it, wait for the next dusk, or temporarily switch to a trigger you can control while you build the rest of the automation.

More examples

Real scenarios where this trigger fires in automations and scripts. Copy any example and adapt it to your setup.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: close the blinds at dusk

When civil dusk falls, close the blinds throughout the house for the evening.

  • Trigger: Dusk
    • Twilight type: Civil
  • Action: Close cover
    • Target: All blinds (label)
YAML example for closing blinds at dusk
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Close blinds at dusk"
triggers:
  - trigger: sun.dusk
actions:
  - action: cover.close_cover
    target:
      label_id: blinds

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the trigger you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain triggers or suggest the right one when you describe what you want in plain language.

Related triggers

These triggers work well alongside this one:

  • Dawn: Triggers at dawn, when civil, nautical, or astronomical twilight begins.

  • Sunset: Triggers when the sun sets.

  • Sun elevation crossed threshold: Triggers when the sun’s elevation crosses a threshold you set.