Sense Energy Meter and Energy how to configure?

Hello everyone - asking for help on how to configure the Sense ( Sense - Home Assistant (home-assistant.io)) integration with the new Energy tracking capability.

I currently have it as “Daily usage” as Grid consumption, but I know that is incorrect. For instance yesterday my Solar generated 38.8Kwh, my Consumption was 28.4kwh. I returned the difference (-10.4) to the grid. As reported by the Sense integration “sensor.daily_usage” should be configured as 'Home" not as “Grid”.

I suppose I might need to create a new entity using a template but not sure how to do that exactly, can someone help with config ?



Maybe I figured something out, sharing here for others that may have interest. The math seems to work out OK when configuring “Daily Production” as reported by Sense in both “Return to Grid” and in “Solar Panels”, and “Daily Usage” reported by Sense as "Grid Consumption.

The math seems to check out with 1 exception : The self consuming energy calculation in HA does not work as configured in my case (0%). Sense reports 50% solar independent from the Grid.

FWIW :slight_smile:



I’m looking to set this up as well. What you proposed seems like it would not work in my situation, as I use a significant part of what the panels are producing in the house without it going to the grid, so adding production to the Grid Return value wouldn’t fit what is happening for me.

I tried creating a new template sensor to take my usage minus the production and if it is negative, then treat that as a positive “Grid Return” number. This sensor in HA works great and has positive numbers as desired, but I can’t select it to add to the Grid Return section of the Energy page. There is a link to a page about long term statistics

which I gathered was saying I needed to add a state_class which I set as ‘measurement’, but it still doesn’t appear.
Anyone have any tips or can it not be done with a template sensor?

      - name: "Grid Return"
        # Sense return to grid, taking usage minus the production, anything above grid usage
        unit_of_measurement: "kWh"
        state: >
          {% set grid_usage = states('sensor.energy_usage') | float - states('sensor.energy_production') | float %}
          {% if grid_usage < 0 %}
          {{ grid_usage | abs }}
          {% else %}
          {{ 0 }}
          {% endif %}
        device_class: energy
        state_class: measurement
        unique_id: sense_calc_grid_return

THanks, I will try the new template sensor.

From what I gather from the other thread you also need to add a last reset :

@MallocArray , using your template and adding the extra code for last_reset in customize.yaml, I am able to add the new sensor to the Energy config. It shows zero at the moment since it is evening here. We’ll have to see tomorrow how this all calculates out…

@mviamin
Thanks. I think my template definition is incorrect, as energy_usage and production are logged in W and in what I had originally, I was using it as kWh. I’m having to re-think through the settings, as I think it should be device_class: power and unit_of_measure: W
but I’m still not seeing it in my Return section of Energy.

homeassistant:
  customize:
    sensor.grid_return:
      last_reset: "2021-08-21T00:00:00+00:00"

*** Edit I was trying to use the unique_id field, but needed to use the name of the sensor in all lower case separated with _ and I also needed to add a : at the end of the sensor name, which I didn’t see in the linked examples, but found in this thread:

I updated my example above to include the correct name and the colon.

With the addition of that customize section at the bottom of my configuration.yaml file, I’m able to add the sensor to the Return section, as long as I leave the device class as Energy and unit as Wh. But this sensor is actually tracking watts, not watt hours, so unsure what the long term implication will be.

The math does not work given the way the Sense Entities are defined. Sense reports Home Consumption, not Grid Consumption, which is what HA is asking as an input.

btw, I think we need to use sensor.daily_usage and sensor.daily_production, those are reporting back in KwH.

template: 
  - sensor:
      - name: "Grid Return"
        # Sense return to grid, taking usage minus the production, anything above grid usage
        unit_of_measurement: "kWh"
        state: >
          {% set grid_usage = states('sensor.daily_usage') | float - states('sensor.daily_production') | float %}
          {% if grid_usage < 0 %}
          {{ grid_usage | abs }}
          {% else %}
          {{ 0 }}
          {% endif %}
        device_class: energy
        state_class: measurement
        unique_id: sense_calc_grid_return

I just changed and the variable shows zero, I guess I’ll have to wait until and see what goes…

As I suspected the math does not fully work.

Here is how it’s setup today :

  • sense.daily_production as HA Production
  • the new entity “Grid Return” as HA Consumption

It works when solar > consumption

But it does not work when solar < consumption because the definition of the new entity calculates to zero in that case.

        state: >
          {% set grid_usage = states('sensor.daily_usage') | float - states('sensor.daily_production') | float %}
          {% if grid_usage < 0 %}
          {{ grid_usage | abs }}
          {% else %}
          {{ 0 }}
          {% endif %}

I have zero to no programming skills, how do I change the code above so that the variable is calculated either way ? Then the question will be do I need an abs or do I let the variable be negative ?

Thanks !

Can somebody help me with this? Not sure exactly how to configure the new template sensors

Does anyone have this issue? My energy reading seems to zero out daily, always at 10PM…I don’t have solar, but wondering if this is an issue with my integration or some setting on the sense side.
Has anyone seen this before?
Below are images for 2 separate days. Too similar to be a coincidence. All days looks exactly the same.

I’ve experienced the same issue, but haven’t had a chance to dig into it at all yet.

Every since the time changed I start my day of with negative numbers. It the total from the day before I guess. It appear to be a time issue but I have no idea how to figure out why. Is anyone else having this issue.

image

image

image

I am also seeing large negative spikes at the beginning of every day. Guessing it has something to do with when sense resets that stat. I’m going to try basically creating my own aggregate sensor and try to use that

1 Like

I also have the same issue - Not sure if this is HA Specific or Sense is feeding like this - so far the sense integration is not at all playing nice with the HA Energy Monitoring

My issue with Sense and home assistant. it look like the daily usage aggregates each hour values.
It shoes that my daily usage is 1377.6 kWh. It look like aggregates each hour usage which is not the usage for the hour but also an aggregation from the begining of the day.

My settings use the Daily Usage entity from sense.

Waking up this thread. I just added Sense to my HA setup and I am seeing all of the issues mentioned before. Just wanted to see if anyone had progressed on this before I start digging in? Thanks.

Just came across this thread. I use the these Sense-provided entities for the Energy Dashboard:

sensor.daily_from_grid for grid consumption
sensor.daily_to_grid for energy returned to the grid
and sensor.daily_production for solar production.

Values are close to what are reported by my utility.



I haven’t had much luck with this. I have reset everything now to see if it works. As I understand it the daily_production only updates at the end of the day. So these graphs will make sense over time but you can’t look at them during the day for one day as production will remain zero until it clicks into the next day?