Time
The Time condition checks whether the current time is in a time window, or whether today is one of the days of the week that you select. Use it when an automation should only continue at certain times. For example, the automation only turns on a light at full brightness during the day, or only sends a reminder on weekdays.
The time can be a fixed time, or the value of a date and time helper, a time entityAn 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], or a timestamp sensor. With a helper that you create yourself, you can change the time later without editing the automation.
Using this condition from the user interface
If you prefer building automations visually, Home Assistant walks you through this condition step by step. You pick what to check, tweak a few options, and save. No YAML knowledge required.
To use this condition in an automation:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the And if section, select Add condition.
- From the search box, search for and select Time.
- Set at least one of the following:
- For the start of the time window, under After, select Fixed time or Value of a date/time helper or timestamp-class sensor. Then enter the time, or select the entity.
- For the end of the time window, do the same under Before.
- To only pass on some days, select them under Days of the week.
- Select Save.
Options in the UI
The time when the time window starts. Use a Fixed time, or the Value of a date/time helper or timestamp-class sensor. Default is Fixed time.
The time when the time window ends. The window ends just before this time. Use a Fixed time, or the Value of a date/time helper or timestamp-class sensor. Default is Fixed time.
Using this condition 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, use condition: time. A basic example looks like this:
condition: time
after: "08:00:00"
before: "20:00:00"
This passes from 08:00 until just before 20:00.
Options in YAML
The options in YAML are the same as in the UI.
The start of the time window, in HH:MM:SS format. Instead of a time, you can use the entity ID of an input_datetime helper, a time entity, or a sensor entity with the timestamp device class. You must set after, before, weekday, or a combination of them.
The end of the time window, in HH:MM:SS format. Instead of a time, you can use the same entities as for after. You must set after, before, weekday, or a combination of them.
The following example uses two date and time helpers that you create yourself, for quiet hours that you can change on a dashboard:
condition: time
after: input_datetime.quiet_hours_start
before: input_datetime.quiet_hours_end
Good to know
- The time window starts exactly at After, and ends just before Before. For example, with After set to 15:00 and Before set to 02:00, the condition passes at 15:00:00, but not at 02:00:00.
- If you only set After, the condition passes from that time until midnight. If you only set Before, it passes from midnight until that time.
- If Before is earlier than After, the time window goes past midnight. For example, with After set to 22:00 and Before set to 06:00, the condition passes during the night.
- Days of the week checks the current day. In a time window that goes past midnight, the hours after midnight belong to the next day. For example, at 01:00 on a Saturday, the condition only passes if Saturday is selected.
- If you use an entity, only its time counts. The date is ignored. If a time entity or a timestamp sensor is unavailable (
unavailable) or unknown (unknown), the condition doesn’t pass. - To check for working days, including public holidays, use the Workday integration. It creates a sensor that you can check with a State condition.
- For time windows that change from day to day, a schedule helper can be easier to set up. You can check it with Schedule is on.
- The condition uses the time zone of Home Assistant. You can find it in Settings > System > Home information.
- This condition checks the time right now. To start an automation at a certain time, use the Time trigger.
Try it yourself
Ready to test this? Go to Settings > Automations & scenes, open an automation, and add this condition. Trigger the automation with and without the condition met, and watch whether it continues or stops.
More examples
Real scenarios where this condition gates an automation. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example or paste the YAML code.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual 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: dim the hallway light at night
When motion is detected in the hallway at night, this automation turns on the hallway light at a low brightness. The time window goes past midnight, from 22:00 until 06:00.
-
Trigger: State changed
-
Entity: Hallway motion (
binary_sensor.hallway_motion) - To: Detected
-
Entity: Hallway motion (
-
Condition: Time
- After: 22:00:00
- Before: 06:00:00
-
Action: Turn on light
-
Target: Hallway light (
light.hallway) - Brightness: 10%
-
Target: Hallway light (
YAML example for dimming the hallway light at night
alias: "Dim hallway light at night"
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions:
- condition: time
after: "22:00:00"
before: "06:00:00"
actions:
- action: light.turn_on
target:
entity_id: light.hallway
data:
brightness_pct: 10
Automation: open the bedroom blinds after the wake-up time on weekdays
When motion is detected in the bedroom on a weekday, this automation opens the blinds, but only after the wake-up time. The wake-up time comes from a date and time helper with only a time, which you create yourself. In this example, the helper is called Wake-up time (input_datetime.wake_up_time).
-
Trigger: State changed
-
Entity: Bedroom motion (
binary_sensor.bedroom_motion) - To: Detected
-
Entity: Bedroom motion (
-
Condition: Time
-
After: Value of a date/time helper or timestamp-class sensor
- Wake-up time (
input_datetime.wake_up_time)
- Wake-up time (
- Days of the week: Monday, Tuesday, Wednesday, Thursday, Friday
-
After: Value of a date/time helper or timestamp-class sensor
-
Action: Open cover
-
Target: Bedroom blinds (
cover.bedroom_blinds)
-
Target: Bedroom blinds (
YAML example for opening the bedroom blinds on weekdays
alias: "Open bedroom blinds after wake-up time"
triggers:
- trigger: state
entity_id: binary_sensor.bedroom_motion
to: "on"
conditions:
- condition: time
after: input_datetime.wake_up_time
weekday:
- mon
- tue
- wed
- thu
- fri
actions:
- action: cover.open_cover
target:
entity_id: cover.bedroom_blinds
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the condition you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain conditions or suggest the right one when you describe what you want in plain language.
Related conditions
Explore related conditions:
-
Schedule is on: Tests if one or more schedule blocks are currently active.
-
Calendar event is active: Tests if one or more calendars have an active event.