Time-Triggered Automation: Using ESPHome to Schedule Actions Without Home Assistant

by Pete
Published: Updated: 5 minutes read

In the realm of home automation, precision and timing are paramount. Often, you need to trigger actions at specific intervals without relying on external platforms like Home Assistant. With ESPHome, you can accomplish just that. This guide delves into the world of time-triggered automation using ESPHome, offering you the ability to schedule actions precisely without needing the assistance of Home Assistant.

Why Time-Triggered Automation Matters

Time-triggered automation eliminates dependency on external platforms. It ensures that your smart devices perform predefined tasks at exact moments, optimizing efficiency and convenience. By using ESPHome’s native capabilities, you can design intricate schedules tailored to your needs.

Setting the Stage

Before diving into the details, make sure you have ESPHome up and running on your device. This involves installing the necessary firmware and configuring your device’s connectivity settings.

Creating Time-Triggered Actions

ESPHome’s configuration YAML is your canvas for time-triggered automation. By adding the “on_time” trigger to a component, you can schedule actions with precision.

Consider the example of an Arlec PC89HA powerboard. Here’s how you can configure it to turn off relays A and B between 9 PM and 5 AM:

# Basic Config
  device_name: "arlec_PB89HA_1"
  name: "ARLEC PB89HA"
  name: ${device_name}
  comment: ${name}
  platform: ESP8266
  board: esp01_1m
  ssid: "ssid"
  password: "password"
  # Important! The status LED and button are on the Pins used by UART0,
  # so if you want to use the serial port, you can set it to UART1.
  hardware_uart: UART1
    key: !secret api_encryption_key
  password: "ota_password"
    number: GPIO1
    inverted: True
  - platform: homeassistant
    id: time_trigger
      - seconds: 0
        minutes: 0
        hours: 21   # 9 PM
      - seconds: 0
        minutes: 0
        hours: 5    # 5 AM
      - switch.turn_off: relay_a
      - switch.turn_off: relay_b
  - platform: uptime
    name: ${name} Uptime
  - platform: wifi_signal
    name: ${name} Signal
    update_interval: 300s
  - platform: gpio
      number: GPIO3
      inverted: True
    name: ${name} button
  - platform: gpio
    pin: GPIO05
    name: "${name} - A"
    id: relay_a
    restore_mode: always off
    icon: mdi:power-socket-au
  - platform: gpio
    pin: GPIO04
    name: "${name} - B"
    id: relay_b
    restore_mode: always off
    icon: mdi:power-socket-au
  - platform: gpio
    pin: GPIO13
    name: "${name} - C"
    id: relay_c
    restore_mode: always off
    icon: mdi:power-socket-au
  - platform: gpio
    pin: GPIO12
    name: "${name} - D"
    id: relay_d
    restore_mode: always off
    icon: mdi:power-socket-au

In this example, relay A of the powerboard will be turned off at 9 PM and back on at 5 AM.

  1. time:: This section indicates the start of the time-based automation configuration.
  2. - platform: homeassistant: This specifies the platform used for the time-based automation. In this case, it’s the Home Assistant platform.
  3. id: time_trigger: This gives a unique ID to this time-triggered automation.
  4. on_time:: This is where you define the specific times when the automation should trigger. It accepts a list of time entries, each with the following properties:
    • seconds: The seconds value at which the automation should trigger (0 in this case).
    • minutes: The minutes value at which the automation should trigger (0 in this case).
    • hours: The hours value at which the automation should trigger (21 for 9 PM and 5 for 5 AM).
  5. then:: This is the action that will be executed when the time trigger is reached. It accepts a list of actions to perform.
    • switch.turn_off: relay_a: This action turns off the relay named “relay_a”.
    • switch.turn_off: relay_b: This action turns off the relay named “relay_b”.

Advantages of Direct Scheduling

Using ESPHome’s time-triggered automation offers several benefits:

  • Independence: Actions are performed locally on the device, eliminating reliance on external services.
  • Precision: Tasks occur exactly as scheduled, ensuring timely actions.
  • Efficiency: Direct scheduling reduces the need for continuous communication with external platforms.


Time-triggered automation with ESPHome empowers you to take control of your smart devices’ scheduling without relying on Home Assistant. By utilizing ESPHome’s native features, you can create tailored schedules that optimize your smart home’s efficiency and convenience.

Whether you’re turning off power outlets, adjusting lighting, or managing other devices, ESPHome’s time-triggered automation opens the door to a new realm of customized control. Embrace the freedom and flexibility of local scheduling, and unleash the full potential of your smart home setup.