Home Assistant Energy Tracking Integration Issue

I’ve been really excited about setting up energy tracking in Home Assistant to monitor my hallway light usage. After some research, I decided to create a template sensor to track the power consumption of my hallway light. Here’s what I did:

yaml
sensor:

  • name: Hallway Light Power
    unit_of_measurement: W
    device_class: power
    state: >
    {% if is_state(‘light.hallway_light’, ‘on’) %}
    {{ 13.0 }}
    {% else %}
    {{ 0.0 }}
    {% endif %}

This sensor works perfectly, showing 13W when the light is on and 0W when it’s off. I then wanted to track the total energy usage over time, so I set up an integration sensor:

yaml
sensor:

  • platform: integration
    source: sensor.hallway_light_power
    name: Hallway Light Energy
    unit_prefix: k
    method: left

The integration sensor is supposed to accumulate the energy usage in kWh, but I noticed an issue. Instead of updating gradually over time, the energy value only updates when the light turns off. This means that if I leave the light on for 12 hours, the energy usage is added all at once when I turn it off, which messes up my daily and monthly utility meters.

I’ve tried adjusting the scan interval and checking the sensor configuration, but nothing seems to work. Does anyone have a solution for making the integration sensor update in real-time or on a set interval? I’d really appreciate any advice or workarounds!