Seeing the amazing additions to 2022.8 I upgraded HA and my energy cost calculations have gone haywire. My google foo has failed me and I can’t figure out where my calculations are going crazy so I’m reaching out in desperation. Wall of text and images below. Thank you to everyone in advance.
Some background. I’m running HA in Docker with Enphase micro inverters for my solar setup. Following this thread I was able to get my energy dashboard running great and even found some areas where I can reduce wasteful consumption. All was running well from June up until the upgrade to 2022.8. After upgrading I started seeing energy costs in the thousands of dollars and started trouble shooting with no luck. The dashboard appears to be reporting the data correctly and the variable price is set correctly in the helper, but the cost calculations are getting lost in translation. Below are screenshots of the sensor configs along with the data they’re outputting.
Just so we have all the information, click on settings, dashboards and edit the energy dashboard. Click on the little pencil for both your grid consumption and return to grid entities and let us know how each one is configured to track costs and which entity is used if any.
Gotcha that makes sense thank you.
here is the formatted text
template:
- sensor:
name: Grid Import Power
state_class: measurement
icon: mdi:transmission-tower
unit_of_measurement: W
device_class: power
state: >
{{ [0, states('sensor.envoy_122115015836_current_power_consumption') | int - states('sensor.envoy_122115015836_current_power_production') | int ] | max }}
- sensor:
name: Grid Export Power
state_class: measurement
icon: mdi:transmission-tower
unit_of_measurement: W
device_class: power
state: >
{{ [0, states('sensor.envoy_122115015836_current_power_production') | int - states('sensor.envoy_122115015836_current_power_consumption') | int ] | max }}
sensor:
- platform: integration
name: Grid Import Energy
source: sensor.grid_import_power
unit_prefix: k
unit_time: h
method: left
round: 2
- platform: integration
name: Grid Export Energy
source: sensor.grid_export_power
unit_prefix: k
unit_time: h
method: left
round: 2
I’ve seen you mention availability sensors before, Do those go into the config file?
I will research this more.
Hey Tom, Could you please help me and OP understand why this is the issue. I’m failing to see the cause and if troubleshooting myself would be looking at the charts of the relevant sensors next. Thanks
Edit: also OP please note that Tom has added default values to your int functions which you also didn’t have. int(0) vice int
I noticed you are using the same energy price for both grid export and grid import.
Did you want your energy price the same for export as it is for import?
Or a better way to express it, is this a 1:1 feed in tariff?
Hi del13r,
Thank you for the guide to get the energy dashboard working! and helping with my question. Yes we are credited at retail rate so 1:1 for us which was a pleasant surprise after seeing what others are getting.
That’s good too know. I’m not sure what it could be anymore at first it seemed like it a simple rounding error. See This Reply for updated costs over a 3 hour period.
This is correct. I have the compensation one but not the cost one because I use my own sensor calculating the total cost. This means HA doesn’t need to do any further calculations for my cost, but for compensation I have a flat rate configured in the energy dashboard and therefore HA needs to calculate the total itself.
The compensation and cost sensors should be identical to the entity name used in the energy dashboard but with cost/compensation on the end.
@cjueden would be interesting to see what your two sensors look like in developer tools > states
I stumbled upon those as well once and assumed the same as you did. Mine never seem to reset except for one day at 12:00 I may have force them to 0 in the dev tools on that day.