Is there a way to get the power usage between a time range (hours)?

I am trying to get the info about my usage from certain time ranges to make some decisions including the amount of my firsts Solar Panels, batteries, etc.

For this, I would like to get the Usage between a range of time but in the Energy dashboard there is no way to set this up, I can only see it from 0 to 23:59 hours.

I am trying to accumulate values of the usage between from 6 to 18, and 18 to 6 again. So I can know which is my “day” usage and my “night” usage.

I already have some sensor from the main power meter:

  • sensor.esp_energy_monitor_technickraum_bezug_tarif_1 which reports the current total usage

  • sensor.esp_energy_monitor_technickraum_wirkleistung_gesamt which reports the current usage

I would like to be able to get and store the usage from a week or so without, is this possible “out of the box”?

Thanks!

Maybe you can check the helper “Utility Meter”?

1 Like

I have seen and tried to do it but I do not understand how to make it from 6 to 18 for example.

The minimum cycle it has is daily :frowning:

Ultimate Guide: Track Time-Based Energy Usage in Home Assistant (Day vs. Night)

Using MeasureIt (UI-Only) or Utility Meter (Built-In)

This guide will help you split energy usage into custom time windows (e.g., 6 AM–6 PM for “day” and 6 PM–6 AM for “night”) and store long-term data.


Option 1: MeasureIt (Flexible, UI-Only)

Step 1: Install MeasureIt

  1. Install via HACS:

    • Go to HACS → Integrations → Search “MeasureIt” → Install.
    • Restart Home Assistant.
  2. Add Integration:

    • Navigate to Settings → Devices & Services → Add Integration → Search “MeasureIt”.

Step 2: Create Day/Night Energy Meters

Daytime Energy (6:00–18:00)

  1. Add a new meter:

    • Go to MeasureIt → Add Meter.
    • Name: Daytime Energy Usage
    • Source Entity: Your energy sensor (e.g., sensor.esp_energy_monitor_technickraum_bezug_tarif_1).
  2. Configure Meter:

    • Meter Type: Sum (accumulates kWh).
    • Reset Condition: Time-based → Set to 06:00:00 (resets daily at 6 AM).
  3. Set Measurement Condition:

    {{ now().hour >= 6 and now().hour < 18 }}
    

    (Only measures between 6 AM–6 PM.)

Nighttime Energy (18:00–6:00)

  1. Add another meter:

    • Name: Nighttime Energy Usage
    • Same Source Entity as above.
  2. Configure Meter:

    • Meter Type: Sum.
    • Reset Condition: Time-based → Set to 18:00:00 (resets daily at 6 PM).
  3. Set Measurement Condition:

    {{ now().hour >= 18 or now().hour < 6 }}
    

    (Only measures between 6 PM–6 AM.)


Step 3: Visualize Data

  • Add to Dashboard:

    • Use a Statistics Graph card to show trends.
    • Or display totals with Sensor Cards.
  • Long-Term Storage:

    • Ensure Recorder is enabled (Settings → System → Storage).
    • To keep data longer, adjust:
      recorder:
        include:
          entities:
            - measureit.daytime_energy_usage
            - measureit.nighttime_energy_usage
      

Option 2: Utility Meter (Built-In, Simpler)

Step 1: Create a Utility Meter Helper

  1. Go to Settings → Devices & Services → Helpers → Create Helper → Utility Meter.
  2. Configure:
    • Name: Day/Night Energy
    • Meter Type: Daily
    • Tariffs: Add day and night.

Step 2: Automate Tariff Switching

Create two automations to switch between tariffs at 6 AM and 6 PM:

1. Switch to “Day” at 6 AM

  • Trigger: Time → 06:00:00
  • Action:
    service: utility_meter.select_tariff
    target:
      entity_id: utility_meter.day_night_energy
    data:
      tariff: day
    

2. Switch to “Night” at 6 PM

  • Trigger: Time → 18:00:00
  • Action:
    service: utility_meter.select_tariff
    target:
      entity_id: utility_meter.day_night_energy
    data:
      tariff: night
    

Step 3: View Data

  • The Utility Meter will now track day and night usage separately.
  • Add to dashboard via Energy Dashboard or Sensor Cards.

Which Method Should You Use?

Feature MeasureIt Utility Meter
No Automations :white_check_mark: Yes :x: Requires automations
Custom Conditions :white_check_mark: (e.g., sunrise/sunset) :x: Fixed tariffs
Built-In :x: Needs HACS :white_check_mark: Native to HA
Ease of Use Moderate Simple

Troubleshooting

  • MeasureIt not resetting? Double-check reset conditions and time format (24-hour).
  • Utility Meter not updating? Verify automations are triggered correctly.
  • Data disappearing? Adjust Recorder settings to retain history.

Final Recommendation

  • For advanced users: MeasureIt (more flexible).
  • For simplicity: Utility Meter (built-in).
1 Like

ChatGPT also gave me the recommendation for the Utility Meter but It does not work as expected right now because the counter restarts at 00 hours for both tariffs

It did not offered MeasureIt though. I will test it.