Sense Energy Monitor issues with HA Energy

I recently got a Sense Energy Monitor and set up the integration in Home Assistant. When using the “Daily Usage” from Sense as my grid consumption value it seems to work properly throughout the day, until it switches over to the next day when HA Energy reads a negative value that equals the total usage of the previous day. This throws off the Energy calculations for each day. The pictures help explain it a little better. Any ideas how to fix this?

So @badi95 , here’s a few thoughts on the problem and possible fixes. The issue is that HA Energy module is written to use the continuous cumulative energy data that typically comes out of even the dumbest smart meter. Unfortunately, the Daily output of Sense from the integration drops back to zero every midnight+. It can’t measure the two values that happen at midnight- and midnight+. A partial fix is to move HA’s energy inputs to the Sense integration’s Yearly recordings. But that exposes another issue - because Sense aggregates and updates the hourly data that the Sense integration uses AFTER the measured hour is done, the data comes in with at timestamp that is a few minutes into the next hour. You can see the delay in the HA InfluxDB view of the raw Sense integration data below - the data for the 1AM to 2AM period gets updated at 2:09:48.

That delay from Sense and the Sense integration causes HA to push all the hourly data an hour later than the Sense data. One of my friends on the Sense community forum was kind enough to highlight the 1 hour difference on corresponding energy chart from Sense and HA.

image

image

You can read more at the Sense forum, here.

Thank you for the reply. I did end up switching to yearly reporting, but noticed some other strange behavior. I’ll have to look more closely to see if it’s the 1 hour shift you describe.

I’m having all sorts of issues with the HA integration and Sense data not matching up. Not just on power consumption but on device state changes showing in Sense and not in HA. Seem like Sense forums is a better place for this discussion.

One thing I would recommend is looking at the raw HA data from Sense in the InfluxDB viewer rather than the pretty HA Energy dashboard. That gives you a much better shot at diagnosing the issues you are seeing. I think the biggest problem is that the HA Energy dashboard relies on a different set of assumptions about reporting vs the HA Sense Integration.

Do you have any recommended resources for how to setup the InfluxDB viewer to view raw HA data?

There are two steps to setting up:

  1. Add InfluxDB add-in and configure. This allows all the Home Assistant state data to flow into the InfluxDB time series database for viewing.
  1. Set up an InfluxDB dashboard with the the right query. Here’s an overview:

And here’s a view of my query - yours won’t be quite the same.

I just started using Home Assistant and ran into this same one hour offset problem.

It’s not clear to me if an easy fix is possible or if HA just wasn’t designed for non-real-time data so I came up with the following work-around.

Use the real-time power values with the Reimann sum integrals to generate solar production and usage sensors.

Create templates to calculate power to and from the grid and integrate those as well.

sensor:
  - platform: integration
    source: sensor.energy_usage
    unit_prefix: k
    name: Energy Usage (kwh)
  - platform: integration
    source: sensor.energy_production
    name: Energy Production (kwh)
    unit_prefix: k
  - platform: integration
    source: sensor.power_from_grid
    name: Energy From Grid (kwh)
    unit_prefix: k
  - platform: integration
    source: sensor.power_to_grid
    name: Energy To Grid (kwh)
    unit_prefix: k

template:
  - sensor:
      - name: "Power from grid"
        unit_of_measurement: "W"
        state_class: "measurement"
        device_class: "power"
        state: >
          {% set solar = states('sensor.energy_production') | float %}
          {% set usage = states('sensor.energy_usage') | float %}
          {{ [0, (usage - solar)]|max }}
      - name: "Power to grid"
        unit_of_measurement: "W"
        state_class: "measurement"
        device_class: "power"
        state: >
          {% set solar = states('sensor.energy_production') | float %}
          {% set usage = states('sensor.energy_usage') | float %}
          {{ [0, (solar - usage)]|max }}

The sun has set here, so I’ll have to wait until tomorrow to see the full result with the energy Dashboard.

The one downside I suspect with this approach is that the integrations won’t be as precise as what the Sense device provides.

Since I’m new to all this, I welcome any comments on how to improve this!

Opps, I made a mistake assuming the return to grid value of the energy monitor was expecting a positive value. Here are my updated sensors.

sensor:
  - platform: integration
    source: sensor.energy_usage
    unit_prefix: k
    name: Energy Usage (kwh)
  - platform: integration
    source: sensor.energy_production
    name: Energy Production (kwh)
    unit_prefix: k
  - platform: integration
    source: sensor.power_from_grid
    name: Energy From Grid (kwh)
    unit_prefix: k
  - platform: integration
    source: sensor.power_to_grid
    name: Energy To Grid (kwh)
    unit_prefix: k
  - platform: integration
    source: sensor.net_power_from_grid
    name: Net Energy From Grid (kwh)
    unit_prefix: k

template:
  - sensor:
      - name: "Net Power from grid"
        unit_of_measurement: "W"
        state_class: "measurement"
        device_class: "power"
        state: >
          {% set solar = states('sensor.energy_production') | float %}
          {% set usage = states('sensor.energy_usage') | float %}
          {{ (usage - solar) }}
      - name: "Power from grid"
        unit_of_measurement: "W"
        state_class: "measurement"
        device_class: "power"
        state: >
          {% set net = states('sensor.net_power_from_grid') | float %}
          {{ [0, net]|max }}
      - name: "Power to grid"
        unit_of_measurement: "W"
        state_class: "measurement"
        device_class: "power"
        state: >
          {% set net = states('sensor.net_power_from_grid') | float %}
          {{ [0, net]|min }}

Actually, that didn’t work either. The energy monitor is expecting a positive value for power to grid.

Has anyone had luck configuring HA Energy with data from sense?

Here’s what I use with my Sense solar setup:

Here’s what I get:

There’s a 1 hour offset vs Sense display because the Sense update by HA takes place a few minutes into the the next hour

Thank you, yes, that is the setting I am using as well, but I still get some strange issues.

For example:

1/22 issue is understandable and predictable - The Sense integration starts and new year of energy accumulation so the data goes from they total of 2021 energy usage back down to zero, hence the huge negative usage fro Jan 1. The spike on Feb 6th is no predictable, but I’m sure it is explainable if you look at the data - either Sense supplied a big uptick, or the HA integration manufactured one. It would be interesting to see your Sense Monthly graph for Feb.