Tesla Powerwall Daily Sensors for Peak Import Incorrect and Not Matching Tesla App Values

My PV system has Tesla Powerwalls and I’ve been using helper sensors off of the native integration to calculate daily energy imported and exported from my system to/from the grid during peak and offpeak times. It’s been reasonably accurate for months, but for the last week, I’ve noticed it reporting energy imported from the grid during Peak Times even though the Tesla app reports 0 kWh during those hours.

Configuration

  • Tesla Powerwall native integration - this provides sensor.powerwall_site_import which provides the running total of kWh imported to my house from the grid.
  • A Utility Meter Helper sensor
    • input sensor: sensor.powerwall_site_import
    • master reset cycle: daily
    • meter reset offset - zero (I believe as I set this up over 1.5 years ago and can’t see the setting)
    • net consumption - off (I believe as I set this up over 1.5 years ago and can’t see the setting)
    • delta values - on (I believe as I set this up over 1.5 years ago and can’t see the setting)
    • periodically resetting - on
    • tarrif - configured via yaml in template sensors and automations to enable/disable
  • Tesla Configuration - Time-Based Control with the correct times and values

This sensor used to match the data reported in the Tesla app with no issue, but as shown in the visuals above, it’s increasing throughout the Peak hours even though nothing is being pulled from the grid per Tesla. I have not changed anything in this environment other than the Home Assistant updates which I’m currently on 2023.10.3.

Any ideas or suggestions here as to what is causing this? As of this moment this helper sensor is reporting 0.4 kWh consumed, but the Tesla App clearly shows 0 kWh has been pulled from the grid during the peak hours.

Responding to my own post as this also been discussed at length in this github issue and I have yet to find a real solution.

@mkanet As I shared in the github issue, I’ve added the APF template sensors back to my setup and started tracking it against daily sensors directly built off the native powerwall integration and the values reported in the Telsa app. I also use Power Flow Card Plus, and since I have mine set up to show import and export PEAK grid consumption for the day, the inaccuracies are quite obvious.

Here is a recap of the variances between the daily values generated off of the Native Integration, the APF sensors, and what’s reported in the Tesla app as the baseline. If positive, it’s greater than the Tesla app, and if negative, it’s less than the Tesla app.

Native Integration APF Tesla App
Grid Export 0.011 -0.954 Baseline
Grid Import -0.256 -1.300 Baseline
Solar Production 0.022 -0.048 Baseline
House Import -0.211 -0.102 Baseline
Grid to Battery -0.105 -0.112 Baseline
Grid Export - Peak -0.011 -3.205 Baseline
Grid Export - Offpeak 0.011 -0.349 Baseline
Grid Import - Peak 0.922 0.086 Baseline
Grid Import - Offpeak -2.111 -5.554 Baseline

The PEAK and Offpeak calculations are not directly reported in the Tesla app, but since I care more about PEAK IMPORT due to the cost, I have verified manually that the Tesla app reports 0 kWh export during peak times on each of these days.

Based on this data, it seems like the daily sensors built off of the native integration is generally closer to the Tesla app than the APF sensors. The main exceptions being House Import and Grid Import - Peak.

So, the question - any guidance on what specifically I should do to more accurately measure and track my PEAK and OFFPEAK calculations?

Here’s how I’ve set up the native integration Daily Grid Import Peak sensor.

  • Utility Meter with Daily reset
  • Source: sensor.powerwall_site_import
  • Tariffs set as peak and offpeak, and switched through automation at the exact times M-F 11AM-7PM is Peak ← this is correctly changing and has consistently for 1.5 years.

Here’s how the APF Daily Grid Import Peak Sensor has been confugired.

  • Utility Meter with daily reset
  • Source: sensor.cumulative_grid_energy_import ← this sensor is an integration with source of sensor.apf_grid_import
  • Tarrifs, same as above and built off of same automations to swtich it.

Any other suggestions here to improve the accuracy of these sensors?

I’m a bit embarrassed to say I don’t know what you mean my Peak/Off-Peak. Do you mean your Power company’s tariffs? If so…

I haven’t paid much attention to peak/off peak since we don’t really consume power from the grid at our home; even while the sun is down. My home just utilizes the stored energy from both of my Powerwall 2’s when the panels aren’t generating power. We also send power to the grid at random times (regardless of peak/off-peak)… when there’s no way to store or consume the excess solar power.

Having said that, I’ve been using my APF sensors mainly for the power-flow-card-plus card’s real-time Solar/Grid/House/Battery values; which always shows the same values as the Tesla app. I like it; and, prefer it over the Tesla app for monitoring real-time values.

I’ve also been using my daily cumulative APF sensors (based on collecting real-time sensors from the Powerwall Integration) to keep track of how much Battery/Grid/Solar consumption I get daily… which is “predictably close” to what I see in the Tesla app. They always seem to be ~5% more than the Tesla values at any given time; similar to the Battery Charge sensor from the Powerwall integration. I’m not sure why it’s always just a little bit more. Whatever is causing the values to be a little bit more, at least it’s consistent. I don’t think it’s a coincidence that the Battery Charge sensor value also is around the same amount higher than the Telsa app value. However, I wouldn’t say the values are “way off” or unpredictable. I even thought about just subtracting 5% from the totals at any given time for more precise values.

UPDATE: Coincidentally yesterday, I made another set of Daily cumulative sensors (based on Import/Export sensors from the Powerwall Integration identical to the native HA Energy Panel). I haven’t had a chance to compare it against the Tesla app yet; but, I’m guessing it’s going to be the same values I get in the native HA Energy panel. The only problem with using these sensors is the Import/Export source sensors don’t update very frequently as the instant sensors do; so, the values may not represent the actual value in real-time.

I’ll post the results after a day or 2 of monitoring the new sensors. If the new sensors are more precise than the APF sensors, I’ll probably switch to them.

Let me know if you find anything new that could help increase the precision of these cumulative sensors.

1 Like

Yes, I have a time of use plan from my grid provider. So I want to import zero during peak and export as much as I can during those times. And unfortunately, I don’t generate enough in the winter for this not to be a concern.

The TL;DR of my issue is that the Tesla app clearly shows zero imported from the grid during Peak times, but the native integration sensor for Powerwall is regularly showing consumption during those peak times. I was hopeful APF would correct this, but on my system as reported in the previous post, it’s less accurate for me in matching the Tesla app values than the native sensors.

@mkanet Per your suggestion to show my full code, here are those details. I moved this part of the conversation back to this thread because I was having issues with formatting so much information through github.

Hardware Setup - PV System with Tesla Gateway and 2x Tesla Powerwalls 2

Software Setup

  • Hardware connected to HA through the native Tesla Powerwall integration
  • [Power Flow Card Plus] to visualize Active Power and Daily Energy
  • Utility Meter Helpers - used to calculate Daily Energy for solar, house, battery, and grid
  • Utility Meter Helpers - used to calculate peak and OFFPEAK import and export of energy to/from grid
  • Automation - used trigger the PEAK/OFFPEAK selection on specific utility meters per the grid specifics outlined below
  • APF Template Sensors - tested several times now to see if it matches Tesla app values better than native HA integration, sample of results here - no longer using these sensors.

Grid Specifics - Time-of-use plan with a different rate during PEAK/OFFPEAK times (M-F 10A-7P) and Season (June-Oct for SUMMER), other times are OFFPEAK or WINTER.

Sensors

Active Power Sensors in kWh
Name Entity Type Source Sensor
Grid Power Now sensor.powerwall_site_now Native Powerwall Integration Powerwall
Solar Power Now sensor.powerwall_solar_now Native Powerwall Integration Powerwall
House Power Now sensor.powerwall_load_now Native Powerwall Integration Powerwall
Battery Power Now sensor.powerwall_battery_now Native Powerwall Integration Powerwall
Grid to Battery Power Now sensor.powerwall_grid_to_battery Template Sensor Template Sensor shared below

Grid to Battery Power Now Template Sensor

{% set grid_power = states('sensor.powerwall_site_now') | float %}
          {% set house_power = states('sensor.powerwall_load_now') | float %}
          {% set battery_power = states('sensor.powerwall_battery_now') | float %}
          {% set solar_power = states('sensor.powerwall_solar_now') | float %}
          
          {% if grid_power > house_power %}
            {{ grid_power - house_power }}
          {% else %}
            0
          {% endif %}
Cumulative Energy Sensors in kWh
Name Entity Type Source Sensor
Grid Energy Export sensor.powerwall_site_export Native Powerwall Integration Powerwall
Grid Energy Import sensor.powerwall_site_import Native Powerwall Integration Powerwall
Solar Energy Export sensor.powerwall_solar_export Native Powerwall Integration Powerwall
House Energy Import sensor.powerwall_load_import Native Powerwall Integration Powerwall
Battery Energy Export sensor.powerwall_battery_import Native Powerwall Integration Powerwall
Battery Power Import sensor.powerwall_battery_import Native Powerwall Integration Powerwall
Grid to Battery Energy Import sensor.powerwall_grid_to_battery_energy Integration - Riemann Sum sensor.powerwall_grid_to_battery
Daily Energy Sensors in kWh
Name Entity Type Source Sensor
Grid Energy Export Daily sensor.site_energy_export_daily Utility Meter sensor.powerwall_site_export
Grid Energy Import Daily sensor.site_energy_usage_daily Utility Meter sensor.powerwall_site_import
Solar Energy Export Daily sensor.solar_production_daily Utility Meter sensor.powerwall_solar_export
House Energy Import Daily sensor.load_energy_import_daily Utility Meter sensor.powerwall_load_import
Grid to Battery Energy Import Daily sensor.powerwall_grid_to_battery_energy_daily Utility Meter sensor.powerwall_grid_to_battery_energy
Grid Energy Export Daily select.dte_daily_export Utility Meter sensor.powerwall_site_export
Grid Energy Export Daily PEAK sensor.dte_daily_export_peak Utility Meter sensor.powerwall_site_export
Grid Energy Export Daily OFFPEAK sensor.dte_daily_export_offpeak Utility Meter sensor.powerwall_site_export
Grid Energy Import Daily select.dte_daily_consumption Utility Meter sensor.powerwall_site_import
Grid Energy Import Daily PEAK sensor.dte_daily_consumption_peak Utility Meter sensor.powerwall_site_import
Grid Energy Import Daily OFFPEAK sensor.dte_daily_consumption_offpeak Utility Meter sensor.powerwall_site_import

Powerwall Charge Actual

- sensor:
  - name: "powerwall_charge_actual"
    unique_id: "powerwall_charge_actual"
    state_class: "measurement"
    unit_of_measurement: "%"
    device_class: "battery"
    state: >-
      {% set percent = ((states('sensor.powerwall_charge') | float(0) / 100.0) - (0.05)) / (0.95) | float(0)%}
      {{ (percent * 100) | round(1) }}

Power Flow Card Plus Code

type: custom:power-flow-card-plus
entities:
  battery:
    state_of_charge: sensor.powerwall_charge_actual
    entity: sensor.powerwall_battery_now
    display_state: one_way_no_zero
    display_zero_tolerance: 20
  grid:
    entity: sensor.powerwall_site_now
    power_outage:
      entity: binary_sensor.grid_status
      state_alert: 'off'
    secondary_info:
      template: '{{ states(''sensor.site_energy_usage_daily'') | round(1) }} kWh'
    display_state: one_way_no_zero
    color_circle: true
    use_metadata: false
    display_zero_tolerance: 99
  solar:
    entity: sensor.powerwall_solar_now
    display_zero_state: true
    use_metadata: false
    display_zero_tolerance: 10
    secondary_info:
      template: '{{ states(''sensor.solar_production_daily'') | round(1) }} kWh'
  home:
    entity: sensor.powerwall_load_now
    secondary_info:
      template: '{{ states(''sensor.load_energy_import_daily'') | round(1) }} kWh'
  individual1:
    entity: sensor.emporiavue2_total_fcsp_power
    icon: mdi:car-pickup
    secondary_info:
      unit_of_measurement: '%'
      entity: sensor.bluey_battery_level
    name: Bluey
    calculate_flow_rate: true
    display_zero: true
  individual2:
    entity: sensor.direct_wire_indoor_outdoor_smart_switch_electric_production_w
    secondary_info:
      entity: sensor.dayman_battery_level
      unit_of_measurement: '%'
    icon: mdi:car-sports
    name: DayMan
    color_icon: false
    calculate_flow_rate: true
    show_direction: false
    inverted_animation: false
    color_value: false
    display_zero: true
    display_zero_state: false
  fossil_fuel_percentage:
    icon: mdi:home-export-outline
    display_zero_state: false
    display_zero: true
    name: Export
    state_type: power
    secondary_info:
      template: '{{ states(''sensor.site_energy_export_daily'') | round(1) }} kWh'
    display_zero_tolerance: 0
    unit_white_space: true
    entity: sensor.powerwall_site_export
clickable_entities: true
display_zero_lines:
  mode: hide
  transparency: 50
  grey_color:
    - 189
    - 189
    - 189
use_new_flow_rate_model: true
w_decimals: 0
kw_decimals: 1
min_flow_rate: 0.75
max_flow_rate: 6
max_expected_power: 2000
min_expected_power: 0.01
watt_threshold: 1000
transparency_zero_lines: 0


My focus has been on trying to get the data shown in Home Assistant to match what’s reported in the Tesla App, but be more flexible to show the detail I care about. e.g. PEAK/OFFPEAK export and import, and Grid to Battery charging so the energy dashboard can properly calculate costs.

I was hopeful that the APF sensors would solve this, but as I shared above, I found the DAILY sensors based off of the native integration sensors to be more accurate for all except for House Import, which could be the inverter sensor calculation for real_house?

To summarize the persistent issues:

  • Utility Meters for PEAK/OFFPEAK add up to the total for Daily IMPORT and EXPORT, but the split between PEAK/OFFPEAK does not match what’s visible in the Tesla app (usually 0 import during peak hours).
  • Power Flow Card Plus does not properly show GRID to BATTERY charging, except for when solar is producing energy. I’ve been tracking this issue here.

There’s a lot here and the formatting is horrible (apologies for that). The net of this appears to be that the native Powerwall integration for Grid Import is increasing during PEAK hours even though the Tesla app shows 0 importing during those windows. And per my original thread, it did not always do this.

So, am I doing something wrong, is the native Powerwall integration reporting false data, or the Tesla app reporting false data?

Update, since Dec 15, it appears the accuracy switched to the APF taking the lead for most of the sensors I’m tracking. Nothing has changed in the environment (other than consumption, production, etc.), so I do not understand why the accuracy would improve so drastically compared to the start of the month.

Either way, it looks like I’m switching to the APF Sensors as it seems futile to continue troubleshooting the native sensors and why they’re showing consumption/export when Tesla reports 0.

This opens up a few additional questions/comments:

  1. The Solar Production APF sensor appears to consistently report 0.1 less than the Tesla App and Native integration. Any ideas why or what could be adjusted to correct this?

  2. Historical sensor data in Energy Dashboard - I’d like to retain all of my historical data (despite the inaccuracies) so it doesn’t show zero for anything before these sensors being created. Has anyone found a successful way to merge the history data?

I also found the same issue: the site import and site export sensors / utility meters in the energy dashboard were correct till october 2023 and fully aligned to Tesla values. Now they’re not anymore.

The sensors diverge from the Tesla app counters everyday: the “net total” between the two (imported energy minus exported energy) is correct every day and month.
But both counters on the utility meters are greater than what appears on the Tesla app. And of the “real” numbers measured on the energy meter…