Custom Solar Power Card the Tesla Style (almost)

Like you saw on git I added the two cars feature, but currently it’s on a separate branch, so look here:


copy the js file and you should be ok. If one or two people can test it and deem it ok I might merge to the main branch.

Thank you for pointing it out and for reminding me to update :stuck_out_tongue_winking_eye:

It seems the hacs approval process will take on a few more weeks. I have added the pull request, my stuff went through all tests but needs 2 more approvals to go into hacs. The boys there seem very busy.

1 Like

For anyone interested 2 cars support is now in main branch as well as the dynamic battery icon :wink:

Can I say this is a great card. One question is there a way to visualise the battery charging from the grid and not just the solar. You can see below there is 10 watts going to the battery but the power is coming from the grid not the solar.

Yes, you just need the newest version. Then you will get that line, it was a feature request that got implemented

Thank you, you are a legend

Would it be possible to document each entity? I have my solar and grid readings coming through the PVOutput sensor and the names are a bit different than yours so I’d like to make sure I’m putting the entities in the right place. Something like below would be great. I’d be happy to help write up this section once I get an understanding of the parameters for your card. Thanks!

Examples:

solar_yield_entity - the amount of solar energy currently being received into your system from the panels. Usually expressed in watts.

grid_feed_in_entity - the amount of electricity currently being pulled from the grid. If you have net metering and are pushing unused solar energy back to the grid then this value may be negative. Usually expressed in watts.

house_consumption_entity - the total amount of solar and grid energy that has been used by your house today. Usually expressed in Kilowatt hours.

Just noticed that you have this embedded as code comments in your example. I probably should have read a bit more before commenting. I’d still suggest pulling these out into the body of the article. Thanks for thinking ahead of me. :slight_smile:

This is by far the best looking power card there is! But I can’t seem to get it working and get NaN kW for the grid state.

Card yaml below and sensors used in same order screenshot. Is there something I am missing?

type: 'custom:tesla-style-solar-power-card'
house_consumption_entity: sensor.current_consumed_positive
grid_consumption_entity: sensor.fronius_grid_usage
grid_feed_in_entity: sensor.current_solar_kwh_sold
solar_consumption_entity: sensor.current_solar_consume
solar_yield_entity: sensor.fronius_panel_status

image
image

So it seems you have some sensors that are kwH and some that are kw. The card is supposed to show only power shifts therefore no kwh sensors should be used.
Strangely the Grid usage is not one of those, so it should work. Could it be that the value is misspelled in the card? Have you tested your values on the developer tools? Those might give you a hint. I try to open two windows to check the values at the same time.

Sorry. I should have tested at day time so I could see the states better (or had dummy states).

The kWh is unit of measure so shouldn’t matter but I should fix that also.

My Grid Usage was showing negative and I had maths wrong on using/sold. For anyone with a Fronius this is the sensors I added… using with the standard “sensor.fronius_panel_status” status for production.

      current_solar_kwh_sold:
        value_template: >
                {% if states("sensor.fronius_relative_autonomy") | float > 99 %}
                {{ (states("sensor.fronius_panel_status") | float ) - (states("sensor.current_consumed_positive") | float ) | round(2) }}
                {% else %}
                0
                {% endif %}
        friendly_name: 'Current Solar kWh sold'
        unit_of_measurement: kW
      current_solar_consume:
        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 %}
        unit_of_measurement: kW
        friendly_name: 'Current Solar kW using'
      current_grid_positive:
        friendly_name: 'Grid Usage'
        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 }}'

type: ‘custom:tesla-style-solar-power-card’
house_consumption_entity: sensor.current_consumed_positive
grid_consumption_entity: sensor.current_grid_positive
grid_feed_in_entity: sensor.current_solar_kwh_sold
solar_consumption_entity: sensor.current_solar_consume
solar_yield_entity: sensor.fronius_panel_status

image

3 Likes

This is great @sini180 !
I’ve struggled with the sensors with my Fronius as well. Changed my Fronius entities to kW, copied yours templated sensors but I don’t get the blue dot for consuming. I get the correct info in the card but only the orange producing dot. Do yours work now?

I actually changed the code as it wasn’t working 100%, I have edited the post now. It should work with edited post above.

1 Like

I’m also getting a NaN result for my grid power and I can’t see why. The entities I created to use have the correct values.
image

entity: sensor.iotawatt_total_house_consumption
grid_consumption_entity: sensor.iotawatt_grid_consumption
grid_feed_in_entity: sensor.iotawatt_grid_feed
house_consumption_entity: sensor.iotawatt_total_house_consumption
solar_yield_entity: sensor.fronius_ac_power
type: 'custom:tesla-style-solar-power-card'

image

Grid consumption is currently zero because my solar is producing more than enough for my house and I have net grid feed at the moment.

Any ideas?

Show states of all the sensors from the card. Hard to say otherwise. Any reason you have fronius for yield and other sensors for rest?

Here are all the sensors used in the card with their rough values (because they are changing before I get a chance to copy all of them, they won’t quite match up)

sensor.iotawatt_grid_consumption              0
sensor.iotawatt_total_house_consumption	      248
sensor.iotawatt_grid_feed	                  1233.0
sensor.fronius_ac_power                       2579

The solar production value comes directly from the inverter whereas the other values are from CT’s connected to an Iotawatt unit

Oh yea. I think some of the data comes the smart meter, but might not have that and pull from iota instead? All of my data comes from the Fronius / smart meter. Additional sensors build on this data (ie; info not available, have to calculate it from available data or data is negative but needs to be positive).

Should the ac_power minus grid_feed match the total_house_consumption? About 1,000W out by looks of it, which is a fair bit even if things are changing.

Correct. I think I have a discrepancy there due to power factor and 3 phase power which I need to sort out, but that shouldn’t affect the card operation

This is really great stuff, thank you for this card. I love it and it works for me in almost all situations - except one (minor): Charging the battery from grid.
Basically this works, the animation looks good (speed) but the number in the battery circle does not show the real value (it shows just the power from PV panels). Could you have a look?
G2Bat is the ‘grid_to_battery_entity’, PV2Bat is the ‘battery_charging_entity’.