Custom Solar Power Card the Tesla Style (almost)

Hi All,
I need some Noob level help on this one please.

I’m attempting to set it up with the Tesla Powerwall Integration.
When I paste in the template sensor codes into my configuration.yaml, I receive differing errors, such as Platform not found.

Can anyone point me to where I should be pasting this in please?

- platform: template
  sensors:
    tesla_card_grid_consumption:
      unique_id: 'tesla_card_5fee6ddd5c1f42a099067ce9dd44e6d1'
      value_template: "{{ states('sensor.powerwall_site_now') | float | max(0) }}"
      device_class: power
      unit_of_measurement: kW
    tesla_card_grid_feed_in:
      unique_id: 'tesla_card_52d22b847ade42c5b4526b2ff15f5aef'
      value_template: "{{ states('sensor.powerwall_site_now') | float | min(0) | abs }}"
      device_class: power
      unit_of_measurement: kW

    tesla_card_solar_consumption:
      unique_id: 'tesla_card_2bb67bd5264f4ec39f141f1722fea085'
      value_template: >-
        {% set solar = states('sensor.powerwall_solar_now') | float %}
        {% set house = states('sensor.powerwall_load_now') | float %}
        {{ solar if house > solar else house }}
      device_class: power
      unit_of_measurement: kW

    tesla_card_battery_consumption:
      unique_id: 'tesla_card_2b7aaa2588e8480aaba586815a84fcd7'
      value_template: "{{ states('sensor.powerwall_battery_now') | float | max(0) }}"
      device_class: power
      unit_of_measurement: kW
    tesla_card_battery_charging:
      unique_id: 'tesla_card_9c46447cf75942ba9ac4bcaca85ba6c5'
      value_template: "{{ states('sensor.powerwall_battery_now') | float | min(0) | abs }}"
      device_class: power
      unit_of_measurement: kW

There is now a really cool contribution on the github readme about how to setup the powerwall. You just need to copy paste then. Chek the bottom of the github space: https://github.com/reptilex/tesla-style-solar-power-card

Many thanks for all your hard work, it’s a great addition to Home Assistant, love it.

I have added the grid_to_battery_entity which is working well.

The only issue I currently have is that the battery charge level shows as 0%.


image

As you can see it directly relates to sensor.powerwall_charge which in the Powerwall card is showing as expected.


Any help would be appreciated.

I just changed my definitions to the new ones in the bottom of the GitHub readme. The card now seems to be broken. Specifically I noticed that there is no grid_to_battery_entity in the GitHub code. The apparent result is no line from Grid to battery and the kW in the battery reads NaN. I did just reload the code to make sure I wasn’t on an old level.

The example in the Github has simplified my convoluted attempt massively, thank you

I’m not sure if the grid_to_battery_entity is all of my problem or if I’ve messed something else up.

Could somebody please share their sensor for this please?

In response to the question about the powerwall charge, mine is working great. My entry looks the same as yours, I have:
battery_charge_entity: sensor.powerwall_charge

Hey guys!

I’m more than happy about this great card! Perfect!

But I still have one more idea:
Is it possible to configure the icons in a way, that e.g. the house is displayed in green if it is only supplied by solar power, in yellow if it is powered by solar power and power from the grid and in red, if only power from the grid is used?

I tried to chande the *.js file in different ways, but I didn’t become it working…
And I am no specialist in programming cards…

Maybe someone can help me?

Maybe it is also possbile to make the colors configurable via tha yaml-data for the card?

Thanks,
Julian

Have only just started on this journey myself, am not a developer at all, but am happy to share what I’ve done.

For the kW in the battery reading NaN, I’ve used the following in my card configuration, although I just get 0 %, as per my post above.

battery_charge_entity: sensor.powerwall_charge

As for the grid to battery, I’ve changed the template to include another sensor which is calculated as load_now - battery_now - solar_now as follows, although this is still a work in progress.

      tesla_card_grid_to_battery:
        value_template: "{{ (((states('sensor.powerwall_load_now') | float) - (states('sensor.powerwall_battery_now') | float) - (states('sensor.powerwall_solar_now') | float)) | float | min(0) | abs) | round(2) }}"
        device_class: power
        unit_of_measurement: 'kW'

and referenced that in my card configuration as follows.

grid_to_battery_entity: sensor.tesla_card_grid_to_battery

I hope that helps.

For anyone that feels adventurous you can now test the new beta of the card you can download the js file or checkout the branch here:


Beware the configuration variables have changed to allow for a more clear calculation. I’m not sure if it makes it easier, but at least it will be clearer what is what. As soon as I have a few people giving me an ok I will release it to HACS. After that I will create a new thread since this one will be deprecated anyway.
Nothing has changed currently but the next release will sadly be backwards incompatible. So enjoy for now. Next version has all the feature wishes I found until two weeks ago included and new ones will be easier to add.

Can you add this as a issue on the card github page? I will try to do at least some of it soonish :wink: but only in the new version derived from beta

done! Thanks a lot!

Dear all,

first thanks a lot for this great card! Really appreciate the work done!

As I added it to successfully to my HA, I quickly wanted to share the stepd and config.
Since I use a Kostal Plenticore inverter and a BYD battery, I hope this might be helpful for others.

  • For the Kostal inverter, I added per HACS the Kostal Plenticore integration that creates a lot of sensors right away. Bear in mind that the inverter´s IP and interface password is required!

  • Then I added the Tesla Style Power Card via HACS (in the frontend section).

In order to get the correct & positive values for the missing sensors, I added the below in the configuration.yaml (took me a while as I am not familiar with any coding syntax):

- platform: template
    sensors:
     
     battery_discharging:
       friendly_name: "Battery discharging"
       unit_of_measurement: 'W'
       value_template: "{{ states('sensor.kostal_battery_power') | float | max(0)}}"
       device_class: "power"
       
     battery_charging:
       friendly_name: "Battery charging"
       unit_of_measurement: 'W'
       value_template: "{{ states('sensor.kostal_battery_power') | float | min(0) | abs }}"
       device_class: "power"
       
     grid_infeed:
       friendly_name: "Grid Infeed"
       unit_of_measurement: 'W'
       value_template: "{{ states('sensor.kostal_power_grid') | float | min(0) | abs }}"
       device_class: "power"

Once they were set up (and the core was restarted) , I recommend first to check in the developer tools, if the entity is properly created and working. If all is well, it looks like this:

2021-03-12 10_57_11-Entwicklerwerkzeuge - Home Assistant

With this done, I used the below code to create the card in lovelace:

type: 'custom:tesla-style-solar-power-card'
house_consumption_entity: sensor.kostal_home_power
grid_consumption_entity: sensor.kostal_home_power_from_grid
grid_feed_in_entity: sensor.grid_infeed
solar_consumption_entity: sensor.kostal_home_power_from_pv
solar_yield_entity: sensor.kostal_pv_power
battery_charge_entity: sensor.kostal_battery_state_of_charge
battery_charging_entity: sensor.battery_charging
battery_consumption_entity: sensor.battery_discharging
show_w_not_kw: 1

Which made it look like this in the end:

2021-03-12 11_00_12-Übersicht - Home Assistant

1 Like

Great integration, thank you. My case is as follows. I have two wallboxes but I do not have a battery, in this configuration the EVs overlap. When I add batteries, the EVs are OK!

what version are you using? The latest Beta should not have that problem beta1.1.3. But if you are migrating from a prior version beware, the entities required have changed and will change again when 1.1 is out

Dear All,

For anyone trying to setup up this card with the default Solaredge integration https://www.home-assistant.io/integrations/solaredge, I have finally worked out the correct yaml to use.

# This is used for Telsa Solar / Consumption power distribution card  

      # 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: grid 2 house"
        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') | int > 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') | int > 0 %}
            {{ states('sensor.solaredge_power_consumption') }}
          {% else -%}
            0
          {% endif %} 
  - type: 'custom:tesla-style-solar-power-card'
    house_consumption_entity: sensor.solaredge_power_consumption
    grid_consumption_entity: sensor.solaredge_template_curent_grid_consumption
    grid_feed_in_entity: sensor.solaredge_template_panels_2_grid
    solar_consumption_entity: sensor.solaredge_template_curent_solar_consumption
    solar_yield_entity: sensor.solaredge_solar_power

I hope this helps somebody

2 Likes

Hey you all. I’m about to push the latest beta release 1.1.5 as the new version of the card. This one is NOT backwards compatible. Meaning you have to redefine the configuration. Now the flows are determining everything. Could some of you try to check out the Readme and let me know if this makes sense and you would know how to deal with it? Any feedback is welcome.

I will create a new forum topic for it as soon as I do create a new normal release.

Think you should baptize the new card too :wink:

1 Like

Call it the Volt Card :rofl: or Ampera Card :sweat_smile:

Will keep the name for now :wink: but I get you. Here is the new thread for any questions about the new version.

Thanks, very useful…

Hi, I have the following yaml:

type: 'custom:tesla-style-solar-power-card'
name: Power Flow
house_consumption_entity: sensor.power_consumption_total
grid_to_house_entity: sensor.power_consumption_w
generation_to_house_entity: sensor.growattmodbus_output_power
generation_to_grid_entity: sensor.power_production_w
show_w_not_kw: 1

sensor.power_consumption_total gives ~1300W (my house consumpotion calculated in home assistant)
sensor.growattmodbus_output_power gives ~4000W (solar panel production)
sensor.power_production_w gives ~2750W (Meter production)
sensor.power_consumption_w gives ~0W (Meter consumption)

Why and where does it count that big value from? And what does the orange pictogram mean? The grid? I assume the solar panel :see_no_evil: :rofl:

image

Thank you for you support

Think I got it by adding an extra entity to deduct the total:

type: 'custom:tesla-style-solar-power-card'
name: Power Flow
generation_to_grid_entity: sensor.power_production_w
grid_to_house_entity: sensor.power_consumption_w
generation_entity: sensor.growattmodbus_output_power
generation_to_house_entity: sensor.power_consumption_solar_new
show_w_not_kw: 1

image