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.
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
@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.
*** 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 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 ?
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.
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.
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
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.
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.
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?