How to Change Timer Duration from the UI

Timer UI
Welcome, smart home enthusiasts! If you’re diving into the world of Home Assistant, you’ve likely discovered the magic of timers—those handy little helpers that let you automate tasks like turning off lights, managing your heating, or even watering your garden. But what happens when you want to adjust the duration of a timer directly from the Home Assistant user interface (UI)? Maybe you need the bathroom fan to run for 20 minutes instead of 15, or you want to tweak the heating schedule on the fly. Today, I’ll walk you through the process of setting and changing a timer duration from the Home Assistant UI, ensuring your smart home runs exactly as you envision.
Table of Contents
    Add a header to begin generating the table of contents

    Why Use Timers in Home Assistant?

    Before we get into the how-to, let’s talk about why timers are so useful. Unlike a simple delay in an automation (which can fail if Home Assistant restarts), timers are robust and persistent. They survive restarts, meaning your garden sprinkler won’t run indefinitely if the system reboots. Plus, timers can be controlled dynamically, making them perfect for scenarios where you need flexibility—like adjusting how long your heating stays on based on the day’s weather.

    Step 1: Set Up a Timer Helper

    First things first, you need a timer in Home Assistant. If you haven’t set one up yet, here’s how to do it via the UI:

    • Navigate to Settings: Go to Settings > Devices & Services > Helpers.
    • Create a Timer: Click the “+” button to add a new helper, then select the “Timer” option.
    • Configure the Timer: Give it a name (e.g., test_timer) and set an initial duration, like 00:15:00 (15 minutes). You can also enable the “Restore” option to ensure the timer resumes its state after a restart.
    • Add an icon (e.g., mdi:av-timer) for your timer to improve visibility in your list of helpers. 
    Timer Helper
    • Click “Create” to finish.

    Your timer is now ready to use! But the initial duration you set here is just a starting point—we’ll adjust it dynamically next.

    Step 2: Create an Input Number Helper for Dynamic Duration

    To change the timer duration from the UI, you’ll need a way to input a new duration value. This is where an Input Number helper comes in—it lets you create a slider or number field in the UI to set the desired duration.

    • Go to Helpers Again: Back in Settings > Devices & Services > Helpers, click the “+” button.
    • Add an Input Number: Select the “Number” option.
    • Configure the Input Number: test_timer_duration for example.
    • Set the minimum value to 0, maximum to 60 (for 60 minutes, or 1 hour), and step to 1 (for 1-minute increments), or whatever parameters your need.
    • Click “Advanced Settings” and choose “Input field” mode for a more precise duration, especially on a mobile phone.
    • To improve visibility in your list of helpers, you can add an icon to your number entity — for example, use mdi:av-timer. It makes it easier to identify the entity at a glance, especially when managing multiple similar ones.
    Number Helper
    • Click “Create”.

    Now you have a helper for your UI that lets you select a duration between 0 and 60 minutes.

    Step 3: Write a script start and stop your timer with a defined duration

    Start the Timer

    To conveniently start or stop your timer, whether from an automation or manually through the UI, you’ll need to create a script.

    • Go to Automations: Navigate to Settings > Automations & Scenes > Scripts tab, then click “Create Script”.

    I prefer using a single script that both starts and stops the timer, to keep all logic in one place. We’ll do this by using a “Choose” action that checks the timer’s state.

    Under Option 1, we’ll define the logic to start the timer:

    1. Click “+ Add Condition” and choose “State.”

    2. In the Entity field, enter your timer’s entity ID, for example: timer.test_timer.

    3. In the State field, type idle (this is the state when the timer is not running).

    Now add the action to start the timer:

    1. Click “+ Add Action.”

    2. Choose “Timer: Start” as the action type.

    3. Under Target, click “Choose Entity” and select your timer.

    Enable the Duration field and add this template:

    {{(states('input_number.test_timer_duration') | int) * 60 }}

    As a result your “Option 1” should look like illustrated on the picture below:

    Start Timer Script

    📌 Explanation: 

    Replace input_number.timer_duration with the entity ID of your actual number helper.

    The multiplier of 60 is used because the timer duration must be defined in seconds, while using minutes is generally more convenient in the UI and for number helpers. So, converting minutes to seconds ensures the timer works correctly while keeping the interface user-friendly.

    Stop the Timer

    Now that Option 1 starts the timer when it’s idle, let’s add Option 2 to stop the timer when it’s running or paused.

    1. Click “+ Add Option” to create a second option.

    2. Under “Conditions,” click “+ Add Condition” and select “State.”

    3. In the Entity field, enter your timer’s entity ID (e.g., timer.test_timer).

    4. In the State field, enter active .

    5. Now, under “Actions,” click “+ Add Action”

    6. Choose “Timer: Cancel” as the action.

    7. Under Target, click “Choose Entity” and select your timer.

    As a result your “Option 2” should look like illustrated on the picture below:

    Sopt Timer Script

    And that’s it! Now your script can start the timer if it’s idle, or stop it if it’s running or paused, all within a single, clean automation.

    📌 Important: 

    Don’t forget to save your script and name it e.g. Test_timer_script

    The yamp code of the script is illustrated below:

    sequence:
      - choose:
          - conditions:
              - condition: state
                entity_id: timer.test_timer
                state: idle
            sequence:
              - action: timer.start
                metadata: {}
                data:
                  duration: "{{(states('input_number.test_timer_duration') | int) * 60 }}"
                target:
                  entity_id: timer.test_timer
          - conditions:
              - condition: state
                entity_id: timer.test_timer
                state: active
            sequence:
              - action: timer.cancel
                metadata: {}
                data: {}
                target:
                  entity_id: timer.test_timer
    alias: Test_timer_script
    description: ""

    Step 4: Add UI cards to set timer duration ans start/stop it.

    I recommend you install the custom timer-bar-card to create cards with an ongoing status of yourtimer as displayed in the picture below.

    Timer progress card
    Install the Timer Bar Card
    1. Navigate to HACS (Home Assistant Community Store)Frontend.
    2. Search for timer-bar-card and click Install.
    3. Once installed, you may need to restart Home Assistant.
    Add the Timer Bar Card to Your Dashboard

    Now that the card is installed, you can add it to your Timer Card.

    1. Go to your Dashboard → Edit DashboardAdd Card.
    2. Select Manual Card and add the following YAML configuration to show your irrigation timer:
    type: custom:timer-bar-card
    entities:
      - entity: timer.test_timer
        name: Test
        icon: mdi:water-circle
        show_icon: true
        state_color: true
        tap_action:
          action: call-service
          service: script.test_timer_script

    📌 Explanation: 

    • entity: timer.test_timer – your timer name
    • name: Test – your card name
    • icon: mdi:water-circle – choose an icon
    • tap_action:
      action: call-service – use “call-service” function when card is tapped
      service: script.test_timer_script – your script name
    Install the Mushroom cards set
    1. Navigate to HACS (Home Assistant Community Store)Frontend.
    2. Search for Mushroom and click Install.
    3. Once installed, you may need to restart Home Assistant.
    Add the Timer Duration Card to Your Dashboard

    Now that the card is installed, you can add it to your Timer Card.

    1. Go to your Dashboard → Edit DashboardAdd Card.
    2. Select Mushrum Number Card.
    3. Select your Number Helper for Timer duration.
    4. Adjust any other setting according to your preferences e. g. you can choose “Buttons” or “Slider” Display mode.

     As a result your Number Helper Card should look like illustrated on the picture below:

    Number Helper card config
    Both Timer and Duration setting cards

    📌 Final Thoughts

    Changing a timer duration from the Home Assistant UI is a game-changer for smart home automation. Whether you’re managing your heating, lights, or irrigation, this setup gives you the flexibility to adapt on the fly. By combining a timer, an Input Number helper, and a few automations, you can create a seamless, user-friendly experience that keeps your home running smoothly. So, go ahead—set up that timer, tweak it from your dashboard, and take control of your smart home like never before!
    What’s your favorite way to use timers in Home Assistant? Share your ideas in the comments—I’d love to hear how you’re making your home smarter! Until next time, happy automating!