Rewritten Tesla Style Solar Power Card

I have a new version of the Tesla Style Solar Power Card , which I posted in this old thread for the first time. The new version is a complete rewrite and will cause some headaches due to changed configurations. So here is a thread to address all the new problems and questions. (Custom Solar Power Card the Tesla Style (almost))
It comes with at least 12 enhancements and a lot of tests (not enough yet).
Enjoy and share.

3 Likes

Hey @reptilex thanks! I like it a lot!

I implemented following the new guideline and I have a doubt regarding how generation should be configured.

In my case I have only one sensor reporting the amount of generation. Now how can I configure those 3?

  • generation_to_grid_entity
  • generation_to_battery_entity
  • generation_to_house_entity

For the first one I use a grid sensor (seems to be fine)
For the last one I use the house sensor (seems to be fine)

But for the generation to battery I dunno what to do. I don’t have a sensor indicating only the charging power of the battery. I do have a sensor showing the battery power and it’s negative when charging and positive when discharging.

Should I create a template sensor and value it only with the negative amount of the battery power?

Thanks for any suggestions

NEVERMIND!!! IT’S WELL DOCUMENTED IN THE READMEEEEEEEEE :frowning:

templates for missing sensors or for negative sensors

HI @reptilex

question: is this a bug or a mistake on my side?

grid import is now feeding house consumption:

bubbles correctly display it but the value associated to ‘grid_to_house_entity:’ is not being used to display value (show 0 instead of the actual). If I click on the bubble given ‘grid_entity:’ is set to the same value I get the proper reading:

guess it’s

generation_to_grid_entity: sensor.solaredge_grid_power

Thanks this is working very well for me now, with SolarEdge (15 mins), various power monitoring plugs around the house and of course the car. Next step, switch to SolarEdge ModBus to get realtime updates.

I really like this card. Thank you for all the great work. I had it up and running with the old version with my Fronius inverter. It worked perfect. However I am lost now. Maybe someone who is using Fronius can share their code.

Hi,

Let me share this :slight_smile:

This is my card, I have a Fronius Symo 3-phase inverter. At the big red dot I have 3x PZEM004t CT-clamp meters. (importance is that this also could be in the grid entry point, but then the below ± operations must be modified accordingly.)
2021-04-16 103901
Card base config:

type: 'custom:tesla-style-solar-power-card'
grid_to_house_entity: sensor.grid_cons_pac
generation_to_grid_entity: sensor.grid_solar_pac
generation_to_house_entity: sensor.house_solar_pac
grid_entity: sensor.grid_cons_pac
house_entity: sensor.house_pac
generation_entity: sensor.solar_pac

Template sensors base config to make this work:

  - platform: template
    scan_interval: 15
    sensors:
      house_pac:
        value_template: >-  ### House power, I have 3 phase power line, *PAC is for Power AC ###
            {{ (( states('sensor.ac1_power') | int ) + ( states('sensor.ac2_power') | int ) + ( states('sensor.ac3_power') | int )) }}
      grid_pac:
        value_template: >- ### Calculated power grid, sensor.solar_pac is the output of my Fronius inverter, I have this entity defined in MODBUS config ###
            {{ ( states('sensor.house_pac') | int ) - ( states('sensor.solar_pac') | int ) }}
      grid_solar_pac:
        value_template: >- ### This is to not to go negative, as this is an absolute value and makes no sense if we're getting power into solar generator ###
          {% if (states('sensor.solar_pac') | int ) >= ( states('sensor.house_pac') | int ) %}
            {{ ((states('sensor.solar_pac') | int ) - ( states('sensor.house_pac') | int )) | int }}
          {% else %}
            {{ 0 | int }}
          {% endif %}
      grid_cons_pac:
        value_template: >- ### Same here, because we need grid-to-house, and house is not generating anything ###
          {% if  (states('sensor.solar_pac') | int ) >= ( states('sensor.house_pac') | int ) %}
            {{ 0 | int }}
          {% else %}
            {{ (( states('sensor.house_pac') | int ) - (states('sensor.solar_pac') | int )) | int }}
          {% endif %}
      house_solar_pac:
        value_template: >- ### Solar generation consumed by house ###
            {{ ((states('sensor.solar_pac') | int ) - ( states('sensor.grid_solar_pac') | int )) | int }}

I have a Fronius Symo and using the integration by Safepay in HACS. These are the templated sensors I needed to make the rewritten card work:

current_generation_to_grid:
  value_template: >
          {% if states("sensor.fronius_relative_autonomy") | float > 99 %}
          {{ '%.1f' | format ((states("sensor.fronius_panel_status") | float) - (states("sensor.current_consumed_positive") | float)) }}
          {% else %}
          0
          {% endif %}
  friendly_name: 'Current generation to grid'
  unit_of_measurement: kW

current_generation_to_house:
  value_template: >
          {% if states("sensor.fronius_relative_self_consumption") | float == 100 %}
            {{ states("sensor.fronius_panel_status") | float | round(2) }}
          {% elif states("sensor.fronius_relative_self_consumption") | float > 0 %}
            {{ states("sensor.current_consumed_positive") | float | round(2) }}
          {% else %}
          0
          {% endif %}
  friendly_name: 'Current generation to house'
  unit_of_measurement: kW

current_grid_to_house:
  friendly_name: 'Current use from grid'
  unit_of_measurement: 'kW'
  value_template: >
          {% if states('sensor.fronius_grid_usage') | float < 0 %}
          0
          {% else %}
          {{ states("sensor.fronius_grid_usage") }}
          {% endif %}

current_consumed_positive:
  friendly_name: 'House load'
  unit_of_measurement: 'kW'
  value_template: '{{ states("sensor.fronius_house_load") | float * -1 }}'

and the card configuration (without any extra sensors):

type: 'custom:tesla-style-solar-power-card'
name: Electricity
generation_icon: 'mdi:solar-power'

grid_to_house_entity: sensor.current_grid_to_house
generation_to_grid_entity: sensor.current_generation_to_grid
generation_to_house_entity: sensor.current_generation_to_house

grid_entity: sensor.fronius_grid_usage
house_entity: sensor.fronius_house_load
generation_entity: sensor.fronius_panel_status

I was very abscent from the forum for a while seems to me you all got fronius working. I have added some new features and have started with the visual configuration, but it’s a slow process. Hopefully this will be better next month.

1 Like

I have this updating now over ModBus now (every 5 seconds), so the resolution is great!

Hi @markpurcell, are you able to share your code? i’m having an issue where my solar is feeding both the house and grid at the same rate (Solar & Grid values should be half or what they are - image below has the correct values) - i feel that i’m missing something:

So the Solar and the House are both feeding the grid which should not be the case, only the solar should be feeding the gird. The house should only be getting power from the grid only if the solar is below the house usage.

image
Solar feeds the house & grid, house is also feeding the grid which is incorrect

config:

name: test
type: 'custom:tesla-style-solar-power-card'
generation_to_house_entity: sensor.modbus_sma_pv_power
generation_to_grid_entity: sensor.modbus_sma_pv_power
grid_to_house_entity: sensor.power_total

image
Solar feeds the house and excess power goes to the grid

config:

type: 'custom:tesla-style-solar-power-card'
grid_consumption_entity: sensor.power_total
generation_to_house_entity: sensor.modbus_sma_pv_power
house_consumption_entity: sensor.current_power_usage
grid_to_house_entity: sensor.power_total
house_extra_entity: sensor.home_temp_max_0
generation_extra_entity: sensor.modbus_sma_temperature
grid_extra_entity: sensor.energy_total
grid_entity: sensor.power_total
generation_entity: sensor.modbus_sma_pv_power
house_entity: sensor.current_power_usage

It’s not critical, but if i can get my image to look like the top one i’d be happy - but if not possiable i’ll have to leave it as the lower image.

Hope this makes sense :slight_smile:

Thanks for your guidance on this one.

1 Like

Pedro,

I had the same issue.

You need to use some templates to ensure you don’t get negative values:

When grid_to_house is positive you are importing to grid, however if it is negative you need to set it to zero and set that value to generation_to_grid.

Here are some of my template rules, which you will need to modify for sma.

# This is used for Telsa Solar / Consumption power distribution card  
# https://community.home-assistant.io/t/custom-solar-power-card-the-tesla-style-almost/220705/95

    # sensor used to show power flow from Panels to Grid, but shows a negative at night   
    solaredge_template_panels_2_grid_day:
      friendly_name: 'Panels 2 Grid during daylight'
      value_template: >-
        {{ (states('sensor.solaredge_solar_power') | float - 
                              states('sensor.solaredge_power_consumption') | float ) | round(2) }}
      unit_of_measurement: 'kW' 
      device_class: "power"

    # shows the current grid power being fed from the grid to the house and doesn't allow it to show a negative number only positive numbers  
    solaredge_template_curent_grid_consumption:
      friendly_name: 'Consumption'
      unit_of_measurement: kW        
      device_class: power
      value_template: >-
        {% if states('sensor.solaredge_grid_power')|float < 0 %}
          0
        {% else %}
          {{ states('sensor.solaredge_grid_power') }}
        {% endif %}

    # sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
    solaredge_template_panels_2_grid:
      friendly_name: 'Panels 2 Grid'
      unit_of_measurement: 'kW' 
      device_class: "power"
      value_template: >-
        {% if states('sensor.solaredge_template_panels_2_grid_day') | float > 0 %}
          {{ states('sensor.solaredge_template_panels_2_grid_day') }}
        {% else -%}
          0
        {% endif %}        

    # shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers 
    solaredge_template_curent_solar_consumption:
      friendly_name: 'Solar 2 House'
      unit_of_measurement: kW        
      device_class: power
      value_template: >-
        {% if states('sensor.solaredge_template_panels_2_grid_day') | float > 0 %}
          {{ states('sensor.solaredge_power_consumption') }}
        {% else -%}
          {{ (states('sensor.solaredge_power_consumption')| float - states('sensor.solaredge_grid_power')| float) }}
        {% endif %}

Great thanks Mark i’ll give that go,

Which entities from Solaredge Modbus TCP do you use? I have only 22 entities from Modbus


This is a great card, just wondering if it is possible to add more appliances?
Ie maybe 3 more ?

Hi everyone
disclaimer, i am a home assistant user and reasonably technical but in no way a dev.

Got a new solaredge SE6000H inverter, panels, optimisers, solaredge immersion diverter and solaredge modbus. Get all the stats i need on the app but its via cloud with 15min refresh. Just set up TCP Modbus as i thought getting info from the inverter real time would be great
(want to set up some node red to turn on/off boiler hot water in favour of solar excess via immersion diverter to make use of excess energy), however i dont see any metrics from my modbus box
only the inverter. The kind of thing i am looking for is export to grid, grid consumption etc
(all visible on my app) but not via TCP modbus. Am i being stupid or is this a genuine limitation? any help would be great. thanks

Its ok, answered my own question in the end, realised i had not ticked the Meter 1 option in the solaredge TCP modbus integration setup
now got access to lots more information. thanks anyway

Sadly that is not as easy as it should and I won’t be adding more appliances for now. Maybe you want to group them with templates and show groups like “appliances” and “climate”

Thanks, all good great card as it is anyway

Hey what a really great work!
I got stuck with my configuration and cannot figure out my mistake: My PV is an LG ESS HOME System. It serves four main values via MQTT: Load_power (sum of all house consumption), PV_Total_Power (like name says), GRID_Power (like name says), Battery_DC_Power (like name says). But additionally I have to cope with “directions” telling me if the value is from or to house, from or to battery, from or to grid.
Since the directions come as 0 or 1, I tried calculating as simple as possible with template sensors.

But even the simplies configuration seems to be incorrect: In the evening (PV is zero, battery is empty) I simply have GRID buying.
So I assume, that the numbers beneath the bubbles house and grid show exactly the same vaule?
GRID bubble shows 573Wh, HOUSE bubble shows 5,7kWh. The numbers are relating 1:10.
What am I doing wrong?