Skip to content

Master Home Assistant Device Runtime Tracking in 2026 (The Definitive Guide)

18/04/2026

Last updated on April 18, 2026

Knowing exactly how long a device in your home has been running is a game-changer. It’s not just for satisfying your curiosity; it’s critical data for making informed decisions about energy consumption, appliance efficiency, and even predictive maintenance. In 2026, the tools within Home Assistant make this kind of tracking more powerful and accessible than ever. In this definitive tutorial, we’ll dive into the most robust method to track runtime in Home Assistant, upgrading past techniques and taking them to the next level.

While older methods might have used a simple toggle helper (input_boolean), today we’re deploying a far more versatile combination: a Dropdown helper (input_select) paired with the powerful History Stats sensor.

Step 1: Create a Helper to Track the Device’s State

Our first move in this Home Assistant setup is to create an entity that represents the state of the device we want to monitor. An input_select helper is perfect for this job, as it lets us define custom states. For our example, we’ll be tracking the runtime of a bathroom exhaust fan, which has two clear states: “Running” and “Off”.

Here’s how to create it from the Home Assistant UI:

  1. Navigate to Settings > Devices & Services.
  2. Select the Helpers tab.
  3. Click + Create Helper and choose Dropdown.
  4. Configure it with the following options:
    • Name: Bathroom Fan Status
    • Icon: mdi:fan
    • Options:
      • Off
      • Running
  5. Click Create. This will generate a new entity, most likely input_select.bathroom_fan_status.

Step 2: Build Automations to Keep the Helper in Sync

Now, we need our new helper to actually mirror the fan’s real-world status. To do this, we’ll create a couple of simple Home Assistant automations. These will trigger whenever the fan’s power consumption—measured by a smart plug or relay like a Shelly—crosses a specific threshold.

In my setup, the fan draws over 20W when it’s active. I’ll use that value as my trigger point.

Automation: Fan ON

This automation will switch the input_select to “Running” when power consumption jumps above 20W.

- id: '1626856817645'
  alias: 'Bathroom Fan ON - Update Status'
  description: 'Sets the input_select to Running on high power draw'
  trigger:
  - platform: numeric_state
    entity_id: sensor.shellyswitch25_40f520003677_channel_2_power
    above: 20
  condition: []
  action:
  - service: input_select.select_option
    target:
      entity_id: input_select.bathroom_fan_status
    data:
      option: Running
  mode: single

Automation: Fan OFF

And this one does the opposite, setting the state to “Off” when the power draw drops below 20W.

- id: '1626856889645'
  alias: 'Bathroom Fan OFF - Update Status'
  description: 'Sets the input_select to Off on low power draw'
  trigger:
  - platform: numeric_state
    entity_id: sensor.shellyswitch25_40f520003677_channel_2_power
    below: 20
  condition: []
  action:
  - service: input_select.select_option
    target:
      entity_id: input_select.bathroom_fan_status
    data:
      option: Off
  mode: single

With these two automations in place, our input_select.bathroom_fan_status is now a perfect digital twin of the actual device.

Step 3: The Magic Bullet—The `history_stats` Sensor

This is where the real power comes in. We’ll use the native History Stats integration to create sensors that measure how long our input_select has been in the “Running” state. The history stats sensor is one of the most underrated native tools in Home Assistant for this exact purpose.

Add the following code to your configuration.yaml file (or a separate sensor file if you use packages). This snippet will create three distinct runtime sensors: today, this week, and the last 30 days.

sensor:
  - platform: history_stats
    name: Bathroom Fan Runtime Today
    entity_id: input_select.bathroom_fan_status
    state: "Running"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

  - platform: history_stats
    name: Bathroom Fan Runtime This Week
    entity_id: input_select.bathroom_fan_status
    state: "Running"
    type: time
    start: "{{ as_timestamp(now().replace(hour=0, minute=0, second=0)) - now().weekday() * 86400 }}"
    end: "{{ now() }}"

  - platform: history_stats
    name: Bathroom Fan Runtime Last 30 Days
    entity_id: input_select.bathroom_fan_status
    state: "Running"
    type: time
    end: "{{ now() }}"
    duration:
      days: 30

After a quick Home Assistant restart, you’ll have three new entities (sensor.bathroom_fan_runtime_today, etc.) whose state is the total runtime in hours for that period. You’re all set!

Step 4: Visualize Your Data on a Dashboard

Having the data is only half the battle; displaying it effectively is key. You can add these new sensors to your dashboard in several ways:

  • Entities Card: The simplest method. It shows the sensor name and its state (the runtime in hours).
  • Gauge Card: Perfect for an at-a-glance view. You can set a maximum value to visualize daily usage as a percentage. For example, a max of 2 hours.
  • History Graph Card: Ideal for analyzing how runtime trends change over a longer period.

For more advanced dashboards, I highly recommend exploring custom cards available via HACS, like the mini-graph-card or apexcharts-card, which allow you to create stunning and information-dense visualizations.

Bonus Round: Calculating the Actual Energy Cost

Let’s take this one step further. If we know the runtime and the device’s average power draw, we can calculate its electricity cost. For this, you’ll need:

  1. The sensor.bathroom_fan_runtime_today we just created.
  2. The device’s average power draw in Watts (W). In my case, it’s 50W.
  3. A sensor that holds your electricity price ($/kWh). You can get this from a utility integration or simply use an input_number helper if you have a fixed rate.

With this data, we can create a Home Assistant template sensor to calculate the cost. As of 2026, it’s crucial to use the modern template sensor format for better performance and future compatibility.

Add this to your configuration.yaml:

template:
  - sensor:
      - name: "Bathroom Fan Daily Cost"
        unique_id: bathroom_fan_daily_cost
        unit_of_measurement: "$"
        icon: mdi:currency-usd
        state: >
          {% set runtime_h = states('sensor.bathroom_fan_runtime_today') | float(0) %}
          {% set power_w = 50 %}
          {% set power_kw = power_w / 1000 %}
          {# Replace 'sensor.electricity_price' with your own energy price sensor #}
          {% set price_kwh = states('sensor.electricity_price') | float(0.15) %}
          {{ (runtime_h * power_kw * price_kwh) | round(2) }}

You’ll now have a sensor.bathroom_fan_daily_cost that tells you exactly how much money you’ve spent running that fan today.

The Pro Method: Using a Template `binary_sensor`

While the input_select method is very visual and easy to grasp, the most technically elegant solution is to use a Template binary_sensor. This sensor is directly tied to the power consumption, switching to `on` or `off` based on the threshold. This approach eliminates the need for an intermediate helper and two separate automations.

The configuration is much cleaner. Just add this to your configuration.yaml:

template:
  - binary_sensor:
      - name: "Bathroom Fan Running"
        unique_id: bathroom_fan_running_bs
        device_class: running
        state: >
          {{ states('sensor.shellyswitch25_40f520003677_channel_2_power') | float(0) > 20 }}

Then, you would simply point your history_stats sensors to this new entity (binary_sensor.bathroom_fan_running) and have them track the `’on’` state. It’s a more direct, efficient, and robust solution, especially for more complex smart home setups.

With these techniques, you have total control to measure, visualize, and analyze the usage time of any device in your home. Whether it’s to save money on your power bill, optimize your automations, or just for the sheer joy of data, Home Assistant provides the ultimate toolkit to get it done in 2026.