Lovelace: Power wheel card

Thx for your extensive response. Yes, now the images do reflect the current design. I found some hours this evening to dive into possible performance improvements. Found something in lit-element about the shouldUpdate() function that could help.

What’s happening? HA gives each custom card a large hass property. Cards check this hass object for changes in entities. By default HA and Lit-element cards are designed to update each visible card on every change of every entity (= automations, sensors, scripts, etc, etc). For large HA setups with many entities this can become a problem if you combine it with one or more of the heavier kind of cards. :flushed:

I made a change to the power-wheel-card to update the card only on specific entity changes (e.g. all the input sensors). That should skip a lot of unnecessary updates and should free some browser resources. There’s a version 0.0.9-dev available on the dev branch in the repo if you want to give it a try.

But since HA updates the visible cards only, you could also/first try to temporarily isolate each heavier kind of card on a separate view in Lovelace to test things. This approach could help to pinpoint the performance problems to a specific card.

I hope the dev-release and the test approach can in the end solve some of your performance problems, if not all. :slight_smile:

testing right now…

35

please allow 2 suggestions:

the missing 0 under the sun icon is a bit too clean for me… In fact, it gives an uncertain feeling as the sensor isn’t picking up alright. I’d prefer it if no solar production is available to have it show 0 under the icon.

secondly, what would really be nice is if the title of the card were to change along with the view, and show, Power- Watt, Usage/Energy -kWh and Cost (which sound better than Money iyam) instead of the Power Distribution or whatever fixed title we give it, it is showing now.

thanks for trying to make it better, ill report if anything arises, good or bad…

UPDATE

after having taken out the mini-graph-card and letting it run for more than a day, I can report most of the performance issues have disappeared. (loading the page still takes out the Hue lights…) Apparently the combination of the 2 cards causes trouble. Not sure how and what to ask to check what could be the cause for this, but please let me tag @kalkih here to have a look? fyi, I am using HA 084.3.

Have taken your two suggestions into account already. And I’m following your discussion on performance in the mini-graph-card topic with great interest.

cool. Though I have stopped using that for the cards I had, too much burden on the system. Your power-wheel seems to be much easier on the system lately so that’s fine too :wink:

love the idea of this card :slight_smile:

got a question - I have an Enphase system using an Envoy-S, which provides grid consumption and array production data - is anyone using this card with an Envoy, if so how are you calculating grid export?

Hi @DrewXT, I saw you’re getting support already in another topic by @exxamalte . Super! I understand the naming of the card parameters can be confusing. I will add some more explanation to it in next release. (I want to postpone changing the parameter names itself for a while since that would cause a breaking change and people are still recovering from the last breaking change. :wink: ).

HI,

testing the new card, and the added options seem to work as promised :wink:
trying to use the coloring options, I am a bit puzzled though if what I want is already possible.

First: am I correct the icons don’t color along the customizations set for the individual entities in the HA setup?

If the above is true, how could I

have the solar icon turn yellow when >0 (producing) or else grey;
have the grid icon turn green when returning to the grid, and red when consuming
have the home icon turn green when using only solar energy, orange when using a mix, red when using only grid energy…

lastly I would think it better to have the grid icon to the house turn red when consuming (vs the yellow for the solar energy color arrows which are yellow when producing)

right now we have 2 options, and they go for all icons I think, which could be made more insightful.

if not yet available, please consider this a feature request :wink:

54
02
12

Time for a new release of the power-wheel-card.

0.0.9

Features

  • Set a different title per view by using optional card parameters title_power, title_energy and/or title_money.
    All three card parameters default to the value of card parameter title.
  • Auto-toggle between views. Click the recycle icon to turn on and off the auto-toggle.
    The initial auto-toggle state can be set by optional card parameter initial_auto_toggle_view.
    The period between views can be set by optional card parameter auto_toggle_view_period (in seconds).

Improvements

  • Performance. Update only on specific changes of the hass object.
  • Don’t suppress zero values on solar, home and grid icon; only on arrows.
  • More explanation in the readme about which sensor to use for what card parameter.

(No support for backwards counting energy sensors yet. Have to work on that a bit more.)

Power-wheel-card is still in beta. You can expect breaking changes in future releases.

You have very specific icon coloring requests. Power-wheel-card does support a few out of the box. Let’s explain them for other users first, before diving into your request:

  • You can choose to not color the 3 icons at all. Use color_icons: false which is default.
  • You can choose to color them automatically. Producing icons will turn green. Consuming icons will turn yellow. Use color_icons: true.
  • You can choose to have your own colors for producing and consuming. Use consuming_color: and producing_color: for that.
  • You can set a theme in HA and the power-wheel-card will use --label-badge-yellow of the theme for the yellow color, etc. automatically.

Your coloring requests go beyond these out of the box features and are not supported.

However since some users (you for instance :wink: ) are able to add a color to the sensor itself, I will take the feature request as “let custom colors of the input sensors override the colors in the power-wheel-card”. Like it does for icons already. In that way advanced users can color the icons dynamically very specifically. Can you give an example of how the entity attributes will look like if there is a custom color dynamically set by some other component? (B.t.w. I won’t work on this feature immediately, because there are a couple of other features to go first.)

not sure if this is what you mean but I use a template sensor:

  levering_of_verbruik:
    friendly_name_template: >
      {% if states('sensor.netto_verbruik')|int > 0 %} Verbruik
      {% else %} Levering
      {% endif %}
    icon_template: >
      {% if states('sensor.netto_verbruik')|int > 0 %} mdi:import
      {% else %} mdi:export
      {% endif %}
    value_template: >
      {{states('sensor.netto_verbruik')}}

which I customize like this:

sensor.levering_of_verbruik:
  state_card_mode: badges
  templates:
#    icon_color: >
#      if (state === 'Levering') return 'rgb(251, 210, 41)';
#      return 'rgb(54, 95, 140)';
    theme: >
      if (state > 0) return 'orange';
      return 'green';
    unit_of_measurement: >
      ${Math.round(entities['sensor.calculated_bruto_verbruik'].state)}

45

based on these:

05

(different numbers caused by real time updating, energy flow sensors not colored in customize yet )

would be really nice if we could set these customizations, but for the Home icon bottom right, that would not be possible would it, since the card calculates that?

Home icon is same as my (sh)own sensor.levering_of_verbruik, but that isn’t used in the config entities…

you might think I have a specific colorizing request, but I feel when you give it some thought it is very useful one. Having a default setting for all of the entities simply doesn’t do the card justice, and tacks back from its purpose

And what do the attributes look like when you look up the sensor in the /dev-state page? Do they get a color attribute e.g.?

a sorry, didn’t follow…

no I don’t set a color in that template but a theme. Could be a color of course, that is, icon_color (see my commented icon_color template).

this is the dev-state:

{
  "friendly_name": "Verbruik",
  "icon": "mdi:import",
  "custom_ui_state_card": "state-card-custom-ui",
  "state_card_mode": "badges",
  "templates": {
    "theme": "if (state > 0) return 'orange'; return 'green';\n",
    "unit_of_measurement": "${Math.round(entities['sensor.calculated_bruto_verbruik'].state)}\n"
  },
  "theme": "orange",
  "unit_of_measurement": "444\n"
}

btw heres a view hat might explain my coloring request:

42

Sun is yellow when producing (or active, and grey when inactive)

while returning to the grid is green and consuming from the grid is red.

as your an see here the kWh view combines with the money view, which is quite effective. Might be a good idea for your card also?

cheers!

And what about inverting the grid color? :pray:

separate post, because this could be something to point out for reference and use for others.

just templated this, which I think is the most compact way of defining both entities for production and consumption, based on a netto verbruik sensor:

{{[0,(states('sensor.netto_verbruik')|int|abs)]|max}}

which means I can now use:

  grid_power_consumption:
    friendly_name: Grid power consumption
    unit_of_measurement: 'Watt'
    value_template: >
     {{[0,(states('sensor.netto_verbruik')|int|abs)]|max}}
  
  grid_power_production:
    friendly_name: Grid power production
    unit_of_measurement: 'Watt'
    value_template: >
      {{[0,(states('sensor.netto_verbruik')|int|abs)]|max}}

instead of

  grid_power_consumption:
    friendly_name: Grid power consumption
    unit_of_measurement: 'Watt'
    value_template: >
      {% if states('sensor.netto_verbruik')|int > 0 %}
        {{ states('sensor.netto_verbruik')|int }}
      {% else %}
        0
      {% endif %}


  grid_power_production:
    friendly_name: Grid power production
    unit_of_measurement: 'Watt'
    value_template: >
      {% if states('sensor.netto_verbruik')|int < 0 %}
        {{ (states('sensor.netto_verbruik')|int|abs )}}
      {% else %}
        0 
      {% endif %}

or worse, depending on your available sensors of course:

  grid_power_production:
    friendly_name: 'Current Energy Exporting'
    value_template: >
      {{ [0, (states('sensor.zp_actuele_opbrengst') | int - 
              states('sensor.calculated_bruto_verbruik') | int)] | max }}
    unit_of_measurement: 'Watt'

  grid_power_consumption:
    friendly_name: 'Current Energy Importing'
    value_template: >
      {{ [0, (states('sensor.calculated_bruto_verbruik') | int - 
              states('sensor.zp_actuele_opbrengst') | int)] | max }}
    unit_of_measurement: 'Watt'
1 Like

Almost but not quite. Because now you want to use exactly the same value_template for both sensors. But I like the idea. You could use a min in the latter, but don’t forget to abs in the end then.

why? the sensor.netto_verbruik shows the positive usage when consuming, and a negative value when returning.
using an |abs on a positive value does nothing, and on the negative makes it positive, as is required by the card.

but i see I have to add a condition, otherwise there’s always the same value for both… pfff, thought I had it…;-((

1 Like

Hi @VDRainer . Could be done if the feature request mentioned here would be implemented. But then you still have to (learn how to) dynamically customize colors on the sensors itself. I have no experience in that, but others have.

Try something like

{{[0,states('sensor.netto_verbruik')|int]|min|abs}}

for the production sensor. Didn’t test this, but it could help you on your way.

Thanks @gurbyz!!
I don’t want to customize colors, i only want to revert the grid color.
(grid icon as consuming when the power goes to the grid)

… yes, I think that’s correct for both entities, only switch min/max:

14

replace watt by my sensor.netto_verbruik: