Custom Solar Power Card the Tesla Style (almost)

Great card, love it. It would be perfect with some more optional appliances, 2-3 more at least. Can it be done?

Also, an option to configure the size of the circles and the font, and maybe to choose rectangle vs circle.

Just throwing there some wishes. Amazing job, thanks for sharing it. :slight_smile:

Ok. So I started a new job and probably this card will only seldom see new features @alexdelprete unless other people join in. But you are right, I would also like to have more appliances, but maybe next year I can add them.
@MJPVDH I have the impression that you are trying to use negativa values, so import and export can be both positive and negative. This won’t work with my card, you have to create separate sensors for negative and positive since they mean different things.
As you will find in the docs you need to define the flows. So from what I see at least:
grid_to_house:
generation_to_house:
generation_to_grid:
And if you have a battery a few more. Have you gone through the readme?
So your templates should calculate the flows I defined above. So grid_to_house might be just importing. But the solar production will be calculated as a sum of generation_to_house and generation_to_grid and house consumption will be a sum of grid_to_house and generation_to_house. This sum is going to be done by the card. You have to provide each flow.

Yeah, this is because the first rendering does sometimes not get a width for the card. I’m thinking of at some point doing the whole animation just as a few css steps and a css based animation not with svgs. But I haven’t found the time and it will be a while.

1 Like

No problem, life comes first, we can live without extra appliances on the card.

All the best for your new job.

1 Like

This is a rather easy feature but I have some others lined up before this one. Could you create an issue in github please?

I’ve just migrated to this power card with an Envoy system. I had to add one more template sensor (just found a prettier version here):

sensor:
  - platform: template
    sensors:
      current_generation_to_house:
        friendly_name: "Current Generation to House"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.exporting') | int)] | max }}"
        unit_of_measurement: 'W'
        icon_template: 'mdi:flash'

And then the simplest configuration (no battery) looks like this:

type: custom:tesla-style-solar-power-card
grid_to_house_entity: sensor.importing
generation_to_grid_entity: sensor.exporting
generation_to_house_entity: sensor.current_generation_to_house

Hi, I am getting graphics scaled to dots almost. Can I somehow reset the scale or help it in any other way ?
Regards
Yassith

With the help from exxamalte i tink i get it done!

Put his info in the configuration.yaml

  - platform: template
    sensors:
        exporting:
          friendly_name: "Current Energy Exporting"
          value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_energy_consumption') | int)] | max }}"
          unit_of_measurement: 'W'
          icon_template: 'mdi:flash'
        importing:
          friendly_name: "Current Energy Importing"
          value_template: "{{ [0, (states('sensor.envoy_current_energy_consumption') | int - states('sensor.envoy_current_energy_production') | int)] | max }}"
          unit_of_measurement: 'W'
          icon_template: 'mdi:flash'
        current_generation_to_house:
          friendly_name: "Current Generation to House"
          value_template: "{% if (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_energy_consumption') | int) > 0 %}{{ states('sensor.envoy_current_energy_consumption') | int }}{% else %}0{% endif %}"
          unit_of_measurement: 'W'
          icon_template: 'mdi:flash'

And this info in the Lovelace card.

type: custom:tesla-style-solar-power-card
grid_to_house_entity: sensor.importing
generation_to_grid_entity: sensor.exporting
generation_to_house_entity: sensor.current_generation_to_house

But now I get these values which are different from the custom:power-wheel-card

Only when export to grid then i see this:

My configuration works fine in both scenarios - importing from and exporting to grid.

From your screenshot taken while importing from the grid I would say that each card in itself is consistent, it’s just that the two cards are not in sync, correct?
When you observe the underlying sensor values for each of the cards, are the cards at least in sync with those sensor values?

Okay, but can you email me your config/sensor/ui-lovelace.yaml for the specific envoy setup please?

Or post it here?

My card configuration looks like the one you posted here.

And the original Envoy sensors are these two - everything else is just maths:

  • sensor.envoy_current_energy_production
  • sensor.envoy_current_energy_consumption
1 Like

You have probably an error in your generation_to_house_entity.

I don’t understand it any more, I have the following in my system:

sensor.yaml

################################################################
#      Solar Stuff                                                                                                     #
################################################################

  - platform: enphase_envoy
    ip_address: 192.168.178.41
    monitored_conditions:
      - production
      - daily_production
      - seven_days_production
      - lifetime_production    
      - consumption
      - daily_consumption
      - seven_days_consumption
      - lifetime_consumption
      - inverters
################################################################
#      Solar Stuff (tesla-style-solar-power-card)                                                                                                     #
################################################################

  - platform: template
    sensors:
      envoy_house_consumption:
        friendly_name: "Current House Consumption"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_exporting') | int)] | max }}"
        unit_of_measurement: 'W'
        icon_template: 'mdi:flash'
      envoy_current_exporting:
        friendly_name: "Current Energy Exporting"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_energy_consumption') | int)] | max }}"
        unit_of_measurement: 'W'
        icon_template: 'mdi:flash'
      envoy_current_importing:
        friendly_name: "Current Energy Importing"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_consumption') | int - states('sensor.envoy_current_energy_production') | int)] | max }}"
        unit_of_measurement: 'W'
        icon_template: 'mdi:flash'
      envoy_today_s_energy_exporting:
        friendly_name: "Today Energy Exporting"
        value_template: "{{ [0, (states('sensor.envoy_today_s_energy_production') | int - states('sensor.envoy_today_s_energy_consumption') | int)] | max }}"
        unit_of_measurement: 'Wh'
        icon_template: 'mdi:flash'
      envoy_today_s_energy_importing:
        friendly_name: "Today Energy Importing"
        value_template: "{{ [0, (states('sensor.envoy_today_s_energy_consumption') | int - states('sensor.envoy_today_s_energy_production') | int)] | max }}"
        unit_of_measurement: 'Wh'
        icon_template: 'mdi:flash'
      envoy_today_s_consumption_negative:
        value_template: '{{ ((states.sensor.envoy_today_s_energy_consumption.state | float * -1)) | round(1) }}'
        friendly_name: 'Today Energy Consumption'
        unit_of_measurement: 'Wh'
      power_kw:
        friendly_name: "Power Available"
        unit_of_measurement: 'kW'
        value_template: >
          {% if states('sensor.envoy_current_exporting')|float > states('sensor.envoy_current_importing')|float %}
            {{ (states('sensor.envoy_current_exporting') | int / 1000) | round(2)}}
          {% else %}
            {{ (states('sensor.envoy_current_importing') | int / -1000) | round(2)}}
          {% endif %}
      grid_consumption:
        friendly_name: "Grid Consumption"
        unit_of_measurement: 'W'
        value_template: >
          {% if states('ensor.envoy_current_energy_consumption') | int > 0 %}
            0
          {% else -%}
            {{ (states('ensor.envoy_current_energy_consumption') | int) | abs }} 
          {% endif %}      
      grid_feed_in:
        friendly_name: "Grid Feed In"
        unit_of_measurement: 'W'
        value_template: >
          {% if states('ensor.envoy_current_energy_consumption') | int > 0 %}
            {{ states('ensor.envoy_current_energy_consumption') }}
          {% else -%}
            0
          {% endif %}
      current_generation_to_house:
        friendly_name: "Current Generation to House"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.envoy_current_exporting') | int)] | max }}"
        unit_of_measurement: 'W'
        icon_template: 'mdi:flash'

In lovelace

type: custom:tesla-style-solar-power-card
generation_entity: sensor.envoy_current_energy_production
grid_to_house_entity: sensor.envoy_current_importing
generation_to_grid_entity: sensor.envoy_current_exporting
generation_to_house_entity: sensor.current_generation_to_house

I just compared my entity definitions with yours, and other than then names their definitions are exactly the same.
The other differences are that I have my Envoy integration defined via the UI, but that shouldn’t have any impact. I am on Home Assistant version 2021.6.6 at the moment. And, the last difference is that I currently do not have property generation_entity defined in my card.

I have been watching it today. The weather was nice, so it was easy to watch!

At full power of the solar panels the orange balls go to the house consumption and to the export grid. So that goes well.

As soon as the solar panels start delivering less and they have to be imported from the grid, things go wrong and the value of the solar panels drops.

the picture below is when there is export to grid and home from the solar panels. Then it does go well.

One thing I found very helpful in setting up the cards was to use the Template tab in Developer Tools to see what the various template values were doing during the day, to assist with debugging.

The frontend has a template editor tool to help develop and debug templates. Navigate to Developer Tools > Template, create your template in the Template editor and check the results on the right.

1 Like

Hi @reptilex … thank you so much for creating this card, it is extremely useful. I’ve managed to implement the card … see picture below, and added a few extra_entity fields which I’d like to improve. Specifically, the total generation & consumption entities I’d like to convert to kWh (from Wh). Here is the sensor specification that I guessed at, but which doesn’t work.

    tesla_card_generation_kWh:
      friendly_name: "Total Generation Today"
      value_template: "{{ (sensor.envoy_122108000251_today_s_energy_production / 1000 ) | round(1) }}"
      unit_of_measurement: "kWh"

Here is the error I receive when checking my configuration.yaml
“Invalid config for [sensor.template]: invalid slug tesla_card_generation_kWh”