Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do the Recommended APF Sensors Show Impossible Transfers Compared to the Older "Tesla Card Sensors" ? #154

Open
ziptbm opened this issue Apr 14, 2023 · 2 comments
Labels
configuration issue software is fine, configuration not correct

Comments

@ziptbm
Copy link

ziptbm commented Apr 14, 2023

This Tesla Style Solar Power Card is the best, hands down, HACS add-in for Home Assistant.

I've been using it for a while now and started out with some template sensors that came from one of the forums (yaml below), which I've referred to as "Tesla Card xyz." After the documentation was updated with the Actual Powerflow (APF) sensors, I added those as well to see the differences side by side. While the APF sensors appear to make everything "add up" I still find odd readings that make no sense for my setup. e.g. as I'm writing this message at this moment, the APF version is showing 2W from my solar to battery, but the sun has already set. And it's showing 10W from my grid to my battery (I only charge from grid during storm watch events).

Could anyone help me understand why the recommended APF sensors from the readme are superior to the "Tesla Card" sensors I had before? Or what's wrong with the "Tesla Card" sensors?

And is anyone else seeing impossible energy transfers from the APF sensors? Thanks.

- sensor:
  - name: "Tesla Card Grid Consumption"
    unique_id: 'tesla_card_grid_consumption'
    state: "{{ [ ((states('sensor.powerwall_site_now') | float(0)) - ([(([states('sensor.powerwall_site_now') | float(0) , 0] | max | abs ) - (states('sensor.powerwall_load_now') | float(0))) | float(0) , 0] | max | abs)) | float(0) , 0 ] | max | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  - name: "Tesla Card Grid Feed In"
    unique_id: 'tesla_card_grid_feed_in'
    state: "{{ [ states('sensor.powerwall_site_now') | float(0) , 0 ] | min | abs | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  - name: "Tesla Card Solar Consumption"
    unique_id: 'tesla_card_solar_consumption'
    state: "{{ [ (states('sensor.powerwall_solar_now') | float(0)) - (states('sensor.tesla_card_grid_feed_in') | float(0) ) - (states('sensor.tesla_card_battery_charging_inside') | float(0)) | float(0) , 0 ] | max | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  - name: "Tesla Card Battery Consumption"
    unique_id: 'tesla_card_battery_consumption'
    state: "{{ [ states('sensor.powerwall_battery_now') | float(0) , 0 ] | max | round(1) }}"
    device_class: power
    unit_of_measurement: kW
      
  - name: "Tesla Card Battery Export"
    unique_id: 'tesla_card_battery_export'
    state: "{{ [ (( [ states('sensor.powerwall_battery_now') | float(0) , 0 ] | max ) - ( [ states('sensor.powerwall_load_now') | float(0) , 0 ] | max )) | float(0) , 0 ] | max | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  - name: "Tesla Card Battery Charging Inside"
    unique_id: 'tesla_card_battery_charging_inside'
    state: "{{ [ (([ states('sensor.powerwall_battery_now') | float(0) , 0 ] | min | abs) - ([(([ states('sensor.powerwall_site_now') | float(0) , 0 ] | max | abs ) - (states('sensor.powerwall_load_now') | float(0))) | float(0) , 0 ] |  max |abs)) | float(0) , 0 ] | max | round(1) }}"
    device_class: power
    unit_of_measurement: kW
      
  - name: "Tesla Card Battery Charging Outside"
    unique_id: 'tesla_card_battery_charging_outside'
    state: "{{ [ (([states('sensor.powerwall_site_now') | float(0) , 0 ] | max | abs ) - (states('sensor.powerwall_load_now') | float(0))) | float(0) , 0 ] | max | abs | round(1) }}"
    device_class: power
    unit_of_measurement: kW
@reptilex reptilex added the configuration issue software is fine, configuration not correct label May 7, 2023
@NathanReus
Copy link

I'm in the same boat as you here. Was using the old "Tesla Card" template sensors. Have now seen these APF ones, and compared the two. Seeing a few watts import or export from/to solar, battery, or grid when that shouldn't be the case.

@mkanet
Copy link

mkanet commented Oct 31, 2023

I'm in the same boat as you here. Was using the old "Tesla Card" template sensors. Have now seen these APF ones, and compared the two. Seeing a few watts import or export from/to solar, battery, or grid when that shouldn't be the case.

Below is the reason. I found the comments below in the APF Template sensor code that we're supposed to use. However, I don't know how/why it was working correctly using the old "Telsa Card" I'd like to know how to old Tesla card handled this differently. @reptilex do you know why it used to work correctly before and not now?

Inverter consumption and power losses due to Inverter transfers and power conversions (AC/DC) excludes rounding errors made worst by the fact that some inverters round all sensors readings to INT Occasionally this might be negative probably due to cumulative errors in not so accurate power readings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration issue software is fine, configuration not correct
Projects
None yet
Development

No branches or pull requests

4 participants