Rewritten Tesla Style Solar Power Card

Thanks Greg!

Hi,
I’m trying to convert my power-wheel-card into this testla-style-solar-power-card. As it’s far more beautiful and matching the HA Energy dashboard.
I just have the actual solar production, the actual grid power consumption en the actual grid power production entities available.

Any idea how to convert them into the tesla-style-solar-power-card as I don’t succeed. Based on the 3 entities he should be able to calculate the house consumption I suppose (as the power-wheel-card does).

This is my config in power-wheel-card:

type: custom:power-wheel-card
title: Energievebruik
solar_power_entity: sensor.actuele_opbrengst_zonnepanelen_kw
grid_power_consumption_entity: sensor.power_consumption
grid_power_production_entity: sensor.power_production
power_decimals: 3

I am testing the following config:

type: custom:tesla-style-solar-power-card
name: Actueel energieverbruik
grid_to_house_entity: sensor.power_consumption
generation_entity: sensor.actuele_opbrengst_zonnepanelen_kw
generation_to_grid_entity: sensor.power_production

Many thanks

Edit:
Got it working. I added a new sensor generation_to_house which I calculate using a template: total generation sunpanels - grid power production

All working fine now! Great card! Thanks for all hard work!

I would be interested to see some more of what you did Greg, I’ve just moved from a 2021 version of core and hass to the latest (2022.3) and the my results are more like random numbers. I think I must have something seriously wrong…
Card Definition:
type: custom:tesla-style-solar-power-card
house_entity: sensor.powerwall_load_now
grid_entity: sensor.xtesla_grid_consumption
battery_entity: sensor.xtesla_battery_consumption
generation_entity: sensor.powerwall_solar_now
generation_to_grid_entity: sensor.xtesla_grid_feed_in
generation_to_house_entity: sensor.xtesla_solar_consumption
generation_to_battery_entity: sensor.xtesla_battery_charging
battery_to_house_entity: sensor.xtesla_battery_consumption
grid_to_house_entity: sensor.xtesla_grid_consumption
grid_to_battery: sensor.xtesla_grid_to_battery
battery_extra_entity: sensor.powerwall_charge
appliance1_consumption_entity: sensor.myenergi_zappi_diverted
appliance1_extra_entity: sensor.niro_ev_19_ev_battery

These are working correctly

My Sensors, which were working OK until this update. I’ve moved the max(0) min(0) as shown in Greg’s post resulting in numbers rather than 0s but the numbers are wrong. For example discharge from battery to house was just showing as 8kWh when the Powerwall can only run at 5kWh and at the time the house was using less than 1kWh.

  • platform: template
    sensors:

  xtesla_grid_consumption:
    friendly_name: "Grid Import"
    value_template: "{{ states('sensor.powerwall_site_now') | max(0) | float | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  xtesla_grid_feed_in:
    friendly_name: "Grid Export"
    value_template: "{{ states('sensor.powerwall_site_now') | min(0) | float | abs | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  xtesla_solar_consumption:
    friendly_name: "Solar Consumption"
    value_template: "{{ ((states('sensor.powerwall_solar_now') | float(default=0)) - (states('sensor.xtesla_grid_feed_in') | float(default=0) ) - (states('sensor.xtesla_charging') | float(default=0)) ) | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  xtesla_battery_consumption:
    friendly_name: "PW2 Consumption"
    value_template: "{{ states('sensor.powerwall_battery_now') | max(0) | float | round(1) }}"
    device_class: power
    unit_of_measurement: kW

  xtesla_battery_charging:
    friendly_name: "PW2 charge"
    value_template: "{{ states('sensor.powerwall_battery_now') | min(0) | float | abs | round(1) }}"
    device_class: power
    unit_of_measurement: kW

Here is my card config

type: custom:tesla-style-solar-power-card
name: Power Flow
house_entity: sensor.tesla_card_load
grid_entity: sensor.tesla_card_grid_consumprtion
battery_entity: sensor.tesla_card_battery_consumption
generation_entity: sensor.entire_site_solar_generation
generation_to_grid_entity: sensor.tesla_card_grid_feed_in
generation_to_house_entity: sensor.tesla_card_solar_consumption
generation_to_battery_entity: sensor.tesla_card_battery_charging_inside
battery_to_house_entity: sensor.tesla_card_battery_consumption
grid_to_house_entity: sensor.tesla_card_grid_consumprtion
battery_extra_entity: sensor.powerwall_charge
house_extra_entity: sensor.weatherbit_apparent_temperature
generation_extra_entity: sensor.weatherbit_cloud_coverage
grid_extra_entity: sensor.daily_powerwall_site_export_kwh
appliance1_consumption_entity: sensor.how_many_live_kw_going_into_cars_now
appliance1_extra_entity: sensor.how_many_kwh_went_into_cars_today
appliance2_consumption_entity: sensor.hot_water_at_home_live_kw
appliance2_extra_entity: sensor.daily_power_hot_water
appliance2_icon: mdi:water-boiler
hide_inactive_lines: 1
change_house_bubble_color_with_flow: 1
energy_flow_diagramm: 0
energy_flow_diagramm_line_factor: 5
threshold_in_k: 1
view_layout:
  position: main

Sensor templates, please excuse the typo in the word consumption on one sensor. I have a complex setup here with separate solar systems ontop of what the powerwall is connected to, as I have 3 phase. Hopefully it can help

#
      tesla_card_load:
        friendly_name: "Tesla Card Load Value"
        unit_of_measurement: "kW"
        value_template: "{{ ( 0 - ( 0 - ( states('sensor.powerwall_site_now')) | float(0) + states('sensor.powerwall_battery_reverse') | float(0) - states('sensor.entire_site_solar_generation') | float(0) )) | round(1)  }}"
#
      tesla_card_grid_consumprtion:
        friendly_name: "Tesla Card Grid Consumption"
        value_template: "{{ states('sensor.powerwall_site_now') | float(0) | round(1) }}"
        device_class: power
        unit_of_measurement: kW
#
      tesla_card_grid_feed_in:
        friendly_name: "Tesla Card Grid Feed In"
        value_template: "{{ states('sensor.powerwall_site_now') | min(0) | float(0) | round(1) }}"
        device_class: power
        unit_of_measurement: kW        
#
      tesla_card_solar_consumption:
        friendly_name: "Tesla Card Solar Consumption"
        value_template: "{{ ((states('sensor.entire_site_solar_generation') | float) - (states('sensor.tesla_card_grid_feed_in') | float(0) ) - (states('sensor.tesla_card_battery_charging_inside') | float) ) | round(1) }}"
        device_class: power
        unit_of_measurement: kW        
#
      tesla_card_battery_consumption:
        friendly_name: "Tesla Card Battery Consumption"
        value_template: "{{ states('sensor.powerwall_battery_now') | float(0) | round(1) }}"
        device_class: power
        unit_of_measurement: kW

Thanks Gregory, Started comparing and already made a few improvements in my definitions which looks like I’ve fixed grid and house. More to do.

Can I ask, what is powerwall_battery_reverse?

Many thanks

Sure, it just swaps above zero for below,
Eg -5440w becomes 5440w or vice versa

Depending on the integration or calculation required, the opposite of the Tesla battery sensor reading sensor might be useful.

Thanks for that. This change certainly has messed up my maths. Video is interesting.
Looking in Developer Tools the base numbers look OK and match what the Powerwall app says. The Energy stats graphs are all good as well. It’s just down to sorting the Tesla Style Power Card problems.

Currently, getting darkish, wife is cooking and most coming from solar and rest from grid. Nothing from battery according to my card, whereas in truth it’s all from battery. An interesting evening is in the offing!

Thanks again for the comments.

I have used the old card as well as the new one. I have recetnly switched from the HACS @safepay to the official HA version of Fronius. Maybe this was a bad idéa? So first of all, For thoose of you that have Fronius what integration are you using? And secondly can anyone with the official Fronius integration share a Tesla Solar card code? I just can not get this working and my numbers are mixed up. Looks like this now:

type: custom:tesla-style-solar-power-card
name: Power Flow
house_entity: sensor.current_consumed_positive
grid_entity: sensor.current_grid_usage
generation_entity: sensor.power_photovoltaics_fronius_power_flow_0_192_168_0_3
generation_to_grid_entity: sensor.current_generation_to_grid
generation_to_house_entity: sensor.current_generation_to_house
grid_to_house_entity: sensor.current_generation_to_house
house_extra_entity: sensor.nordpool_kwh_se3_sek_2_10_025
generation_extra_entity: sensor.dark_sky_cloud_coverage
appliance1_consumption_entity: sensor.vf1ag000361750753_charging_power
hide_inactive_lines: 1
change_house_bubble_color_with_flow: 1
energy_flow_diagramm: 0
energy_flow_diagramm_line_factor: 5
show_w_not_kw: 1
threshold_in_k: 1
view_layout:
  position: main

The main issue is that the house consumptions shows wrong value. I have added extra templates.hacard1

Does anyone with a Tesla Powerwall that’s using this card know how to accurately configure a daily consumption sensor for house power consumption in kWh?

Specifically for house_extra_entity I would like the top number to show me how much energy my home has consumed today and then reset to zero at midnight. I have corresponding sensors over the solar (how much produced) and grid (how much pulled from grid).

I originally setup a Utility Meter sensor to look at the sensor.powerwall_load_import from the Tesla Powerwall integration, which appears to regularly match what’s reported in the Tesla app for total daily home consumption. However, I have noticed that the number appears to be inflated when my Powerwall charges from solar. It doesn’t exactly add up, but it’s within a few tenths of a kWh, so I’m thinking I need to somehow create a sensor that excludes battery charging as home energy consumption. It’s too bad the Tesla Integration just don’t provide a sensor that shows the same daily numbers reported in the app.

Any pointers for configuing a sensor to show me this value above the home icon in this card? Thanks!

I pretty much do what you have suggested. I have a utility meter on load_import.

The numbers seem to be out by a small margin as well. 12.6 kWh vs 12.8 kWh.

Thanks. I really don’t get why mine is so off.

I’m wondering if there’s a problem with the Tesla PowerWall integration or something. Here are the types of differences I’m seeing day to day. Sharing in case anyone is seeing differences.

Apr 28 (as of right now)

  • Tesla - 56.5 kWh
  • HA Consumption Sensor from Tesla Integration - 61.6 kWh
  • Energy Dashboard - 57.7 kWh

Apr 27

  • Tesla - 36.2 kWh
  • HA - 42.3 kWh
  • Energy Dashboard - 36.2 kWh

Apr 26

  • Tesla - 33.1 kWh
  • HA - 36.3 kWh
  • Energy Dashboard - 32.9 kWh

Apr 25

  • Tesla - 36.2 kWh
  • HA - 37.1 kWh
  • Energy Dashboard - 36.4 kWh

Apr 24

  • Tesla - 71.8 kWh
  • HA - 78.2 kWh
  • Energy Dashboard - 71.7 kWh

Apr 23

  • Tesla - 69.1 kWh
  • HA - 78.9 kWh
  • Energy Dashboard - 69 kWh

Can you check back against the HA energy dashboard.

I get really close results there. Thus I suspect the error maybe the utility meter calculations.

Screenshot 2022-04-29 12.18.56

good call. I just updated my previous post with those values too.

The Energy Dashboard is definitely closer to the Tesla app than my HA utility sensor. So you think it’s a utility meter calculation error?

Are there any plans to adapt this awesome card to match the style of the standard energy dashboard of Home Assistant? The two cards are similar in setup but not in style.
Energy dashboard:
Screenshot 2022-05-26 at 21.17.37
Tesla style solar power card:
Screenshot 2022-05-26 at 21.18.07

If you are just looking for the gaps in the connecting lines, use this config

show_gap: true

That’s a nice one, thanks. But I also ment the color and thicker circles.

For those with Tesla Wall Connectors and using this awesome integration, what’s the preferred method to insert consumption data for the Tesla Wall Connector on one of the appliances?

I just replaced my JuiceBox with a Tesla Wall Connector and was surprised to see it measure three separate phases for Current and Voltage, but not the aggregate watts actively being used.

This person has created a config Value Template or this calculation, but is there a more preferred way to bring this information into the Tesla Style Solar Power Card?

@reptilex / Hi Guys,

Awesome UI Card, Thank you I have been using it since 2021.

Since the latest HA update to 2024.06.1 I note that the bubbles and the numbers have all become very small and unreadable on my Android phone. I refer to this one card almost every time that I open HA as it gives me a perfect overview of everything that I want to see. Is there anyway to increase the bubble size and the text font sizes to make them proportional and how they used to be?

Thank you for any feedbacks.

Thank you for the update, Now it is perfect again!