Rewritten Tesla Style Solar Power Card

Thanks for the reply - All connected and data is correctly displaying for each sensor…`I just can’t work it out!

cheers.

On your home assistant go to: /developer-tools/state when you have some sun and do a screenshot of the result when you type in the entity ‘sensor.powerwall_solar_now’ you should get a result. Otherwise you do have a powerwall installed correctly but the sensor name is not preceded by powerwall but by something else. At least it seems like that from the error. You can find your entities there and you might just need to change the name of powerwall to whatever it is called on your installation. This is an error I have not seen yet though.

Thanks for the reply.
State appears correct which is why I am so confused!

image

Hello

Can someone share the templates (or full config) to integrate de new Fronius oficial integration?

Thanks!

I have a little challange, the animations and figures do not work when exporting the battery to the grid; hope this helps?

image

I have the stock templates, I think basically it struggles with battery to grid concept -

template:

  • sensor:
    • name: “Tesla Card Grid Consumption”
      unique_id: ‘tesla_card_grid_consumption’
      state: “{{ states(‘sensor.powerwall_site_now’) | float | max(0) | 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 | min(0) | 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) - (states(‘sensor.tesla_card_grid_feed_in’) | float ) - (states(‘sensor.tesla_card_battery_charging_inside’) | float) ) | 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 | max(0) | 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 | min(0) | abs | round(1) }}”
      device_class: power
      unit_of_measurement: kW

I need to have a ‘tesla_card_battery_to_grid’ entity, any help would be appreciated, many thanks

Hi,

@reptilex Thanks for making this card.

I think I finally have it setup the way I want it.
I have an Enphase Envoy and lets just say it wasn’t exactly plug and play getting this card to work with the envoy sensors.
For some reason I had to create a new sensor which i called “Consumption Net” that subtracts the grid import power from the current_power_consumption so it can be used as the “generation_to_house_entity”.
As a side note, the enphase envoy does not provide ‘grid import power’ sensors.
I needed to create that as well.

image

Things I had to add in the configuration.yaml do to get it looking like this:

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_SERIALNUMBER_current_power_consumption') | int -
               states('sensor.envoy_SERIALNUMBER_current_power_production') | int ]
               | max }}

  - sensor:
        name: Power Wheel House Consumption Net
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        state : >
            {{ states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int -
               states('sensor.grid_import_power') | int }}

  - sensor:
        name: Power Wheel Energy Production
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kWh
        device_class: energy
        state : >
            {{ (states('sensor.envoy_SERIALNUMBER_today_s_energy_production') | int /
               1000) | round(0) }}

  - sensor:
        name: Power Wheel Energy Consumption
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kWh
        device_class: energy
        state : >
            {{ (states('sensor.envoy_SERIALNUMBER_today_s_energy_consumption') | int /
               1000) | round(0) }}

Card Config

type: custom:tesla-style-solar-power-card
generation_to_grid_entity: sensor.grid_export_power
grid_to_house_entity: sensor.grid_import_power
generation_to_house_entity: sensor.power_wheel_house_consumption_net
grid_extra_entity: sensor.today_energy_total_cost
house_extra_entity: sensor.power_wheel_energy_consumption
generation_extra_entity: sensor.power_wheel_energy_production
appliance1_consumption_entity: sensor.sonoff_identifier_power
appliance1_icon: mdi:pool
appliance1_extra_entity: sensor.pool_pump_duration_24h
energy_flow_diagramm: 1
energy_flow_diagramm_line_factor: 2

my figures all reverted to 0 as shown in this card with the 2022 core updates.
I had to remove the min an max from some of my value_templates to get the integration to work again

@Gregory_Peck do you know which entries you had to remove min/max from?

In the end I had to move min(0) and max(0) to the other side of float operation (LHS). You may also have to change float to read float(0)

  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

image

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.