Lovelace: Power wheel card

If you used your sensor.ioatawatt_solar as solar_power_entity you could add a minus sign in value_template: ‘{{ -value | round(1) }}’ but that would effect your dashboard everywhere where this sensor was used. You also could derive an extra sensor of it and feed that to the card:

solar_power_positive:
  unit_of_measurement: 'W'
  value_template: >-
    {{ -(states('sensor.ioatawatt_solar') | float) }}

@firstof9, you also need this, because your image shows a negative solar power value and the card needs a positive one. Then the card values make more sense and the right arrow starts becoming active.


@Mariusthvdb, also not trying to knowing better here :wink: but my energy provider calls me a ‘producer’ when I’m delivering back to the grid. And most of the time I’m a consumer according to them, the grid.

Fact is: half of the world is familiar with A, the other half with B. Half of the world likes to see + and - numbers on the card (perfectly understandable @cjsimmons) and the other half likes positive values with color to show the difference. I can’t serve both worlds or maybe I could, but then the complexity rises (extra parameters, code complexity, etc). And there are already some that say that complexity has risen too far. :slight_smile:

This is about energy, not power. (On the power view this couldn’t happen.) There are times during the day that energy produced by your solar panels wasn’t consumed immediately by your house, but ‘produced’ to the grid. This was the case for 0.90 kWh. But sometimes your house was consuming the produced solar energy immediately, which is shown by the 2.76 kWh at the right arrow. Probably your house was consuming even more than your solar panels did produce, because you were consuming from the grid another 17.43 kWh.
(Same goes for the money view where all the energy values are simply multiplied by the (evt. averaged) energy_price).


Currently I’m working on the upgrade to a higher version of lit-element and I will think about the phenomenon of backward counting energy sensors (@firstof9) . And I want to stay away from breaking changes for a while. :smiley:

exactly, you are of course a producer when you are, as you state correctly, delivering back to the grid. But, that is from the power company’s point of view, and they don’t care if you have true sensors in your HA that are the real producers… and have to make a logical distinction between that sensor, and the returned to grid energy that has taken into account that production and substracted that from the total usage…

and yes, creating a negative value would also be better. right now you choose the third best option I fear. Colors are always customizable, so that could be left to the individual choices.

but hey, its your card… :wink:

Thought as much, thanks! but, tbh, can’t imagine that happened yesterday… but will have an extra eye on that to check if this shows the real situation correctly. In an all grey and rainy day, my house almost always consumes more than that tiny fraction of solar power :-((
otoh, if your card shows me that right now, that would be all the more valuable information.

you really should have a look at this thread, talking about insight in power consumption… so cool.

EDIT

also have a look at this graph, which shows tin another way. Export (returning to the grid, production in your card) being the total of the real production minus self consumption.

At night the negative power on the solar is the inverter pulling power from the grid, while the solar is active it’s a positive number.

Ah, then you’re okay with the polarity of the input sensor. Sorry, the arrows don’t start pointing the other way around. They can’t cope with the negative values. In my household the energy consumption of the inverter is part of the (bottom-right) home energy.

Yup that doesn’t bother me and I can do the template for the exporting/importing of watts, just can’t do anything about the kWh going backwards.

I think i’m categorie B, i want too see the grid icon as consuming when the power goes to the grid.
As i only use the power view, i changed line 150 from

      data.grid = this._makePositionObject(hass, data.grid.val, config.grid_power_entity, config.grid_icon,
          'mdi:flash-circle', this.power_decimals, false);

to

      data.grid = this._makePositionObject(hass, data.grid.val, config.grid_power_entity, config.grid_icon,
          'mdi:flash-circle', this.power_decimals, true);

Now the color is OK for me.
@gurbyz, what about a simple flag invert_grid_color: true ? :upside_down_face:

Was totally unhappy that the home_power_entity is no more used, as i have a battery. :disappointed_relieved:

I’m now using the card twice with the conditional card.
Only changed the solar_power_entity to the battery sensor, and the icon.
If the sun is down and the power comes from the battery, it shows the sun as battery.

Auswahl_176

      - type: conditional
        conditions:
          - entity: binary_sensor.e3dc_pv0_batt_neg   
            state: 'on'
        card:
          type: "custom:power-wheel-card"
          title: Leistungsverteilung
          solar_power_entity: sensor.e3dc_battery_power_pos
          grid_power_production_entity: sensor.e3dc_net_power_pos
          grid_power_consumption_entity: sensor.e3dc_net_power_neg
          home_icon: mdi:home-outline
          solar_icon: mdi:car-battery
          grid_icon: mdi:sitemap
          color_icons: true
          consuming_color: "#9bc53d"
          producing_color: "#fde74c"

      - type: conditional
        conditions:
          - entity: binary_sensor.e3dc_pv0_batt_neg   
            state: 'off'
        card:
          type: "custom:power-wheel-card"
          title: Leistungsverteilung
          solar_power_entity: sensor.e3dc_pv_total
          grid_power_production_entity: sensor.e3dc_net_power_pos
          grid_power_consumption_entity: sensor.e3dc_net_power_neg
          home_icon: mdi:home-outline
          solar_icon: mdi:white-balance-sunny
          #grid_icon: mdi:transmission-tower
          grid_icon: mdi:sitemap
          color_icons: true
          consuming_color: "#9bc53d"
          producing_color: "#fde74c"

Thanks for your effort!

1 Like

First of all thanks for all the great effort. I will get my solar panels in a month and wanted to start with the lovelace configuration before so everything is ready when they arrive. So… I just migrated to HA 0.86.1. And now lovelace is default. I wanted to wait to implement everything until now. However I was able to set this up before but now I started from scratch. If I understand this correct I now press the plus sign in the gui, choose a card to add but as this card is not default I press skip and is presented with an editor. I just do not get the syntax here. Would anyone want to share their code if you are able to edit the card. I wanted to do this in the gui prior to use the raw editor as I am afraid to mess everything up.

I’m only using yaml mode, so nut sure, but i think you need the raw editor to configure custom cards.

The alternative CDN does break the current version. On DEV is already a better version. I will release later today to MASTER.

EDIT: Release is done.

0.0.7

Improvements

  • Upgrade to lit-element 0.6.5.

Fixes

HI @gurbyz

any thoughts on this: Cross-origin script load denied by Cross-Origin Resource Sharing policy

suddenly I see these, didn’t change a working setup …

Hi @Mariusthvdb Please see the message above your message. It’s the CORS error. It was caused by firebaseapp.com. Maybe they weren’t too happy that everyone switched from unpkg.com to them (because of the ‘localhost issue’ that occurred on the original unpkg.com CDN a while ago.)
It’s fixed in release 0.0.7 yesterday.

duh, I am so sorry…

one thing to note, in the new version you use render without a _

  render({ hass, config }) {
    let data = {
      solar: {},
      solar2grid: {},
      solar2home: {},
      grid: {},
      grid2home: {},
      home: {},
    };

while in the old versions you use

  _render({ hass, config }) {
    let data = {
      solar: {},
      solar2grid: {},
      solar2home: {},
      grid: {},
      grid2home: {},
      home: {},
    };

is that correct or a typo (all other functions use the _ )?

That’s part of the changes that lit-element had between version 5.2 and 6.5. In fact, almost all the changes of release 0.0.7 are because of this reason. I have a few major changes of lit-element to go before I get to your suggestion (to include the local version of lit-element). :slight_smile:

ok thanks, Ive changed that, but not showing the card yet… this Lit thing is quite annoying o the cards that use it…

I can use it on ha 0.84.3 can I, havent updated to higher HA yet

Should be fine, because the lit-element is taken from the CDN, not from HA itself. It’s independent.
What did you do to update the power-wheel-card to 0.0.7?

your were quicker than I could be deleting my post…

I edited my older card, and have replaced it with your new card now, and it is showing!
thanks.

now that i have your attention :wink:

would you consider adding a config option for the font-styles, and especially the central toggle-view one, which now is rather large and bold…
? It seems really out of content with the rest of the Ha style.

I probably can edit the style in the card, but making the a config option would make everyone happy?

1 Like

I want to switch to a different layout a.s.a.p. Nice big curvy arrows to make it a circle and the ‘wheel’ part of the name starts to make sense. All styling requests are postponed till after that.

But first, the backwards counting energy sensor and the confusing names issue to solve…

Ah yes, but don’t forget power distribution doesn’t always cycle like a wheel… maybe you shouldn’t focus as much on that for layout, especially when batteries are going to be used more in the nearby future. combined with domestic car electricity.

+1 on that :wink:
start with ditching the word entity, and the config will become much cleaner… (changed grid_production to grid_return, cause that’s what it is, and solar is the only production entity… in the current setup.

  - type: 'custom:power-wheel-card'
    title: 'Power distribution'

    # Watt units, as in real_time power
    solar_power_production: sensor.zp_actuele_opbrengst #production = opbrengst
    grid_power: sensor.netto_verbruik
    grid_power_consumption: sensor.grid_power_consumption
    grid_power_return: sensor.grid_power_return

    # kWh units, as in total day energy
    solar_energy_production: sensor.solar_energy_production
    grid_energy: sensor.grid_energy_total
    grid_energy_consumption: sensor.calculated_totaal_dag_afname
    grid_energy_return: sensor.calculated_totaal_dag_levering #return = levering

    color_icons: true
    power_decimals: 2
    energy_decimals: 2
    energy_price: 0.51
    initial_view: energy

my 2 cents. :wink:

o and changing to this:

ha-icon {
  transition: color 0.5s ease-in-out, filter 0.3s ease-in-out;
  color: var(--paper-item-icon-color, #44739e);
  width: 36px;
  height: 36px;
}

and

    .unit {
      display: table-cell;
      text-align: center;
      vertical-align: middle;
      font-size: var(--paper-font-headline_-_font-size);
      color: var(--secondary-text-color);
      font-weight: bold;
    }

wasn’t much of an effort, making all the difference (to me), so never mind the cosmetics for now :wink:

51

hope im not yet again asking a stupid question, but since I updated yesterday to your newest card version, I have this issue in a power returning situation:

07

as you can see a double minus…

and NaN in the card:

57
you must have changed the calculations in your CC, because my template is unchanged:

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

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

or can we use the same netto sensor for both entities again ?

I know my sensors are working as expected because of 32 :wink:

I did change the calculations, but it’s the input sensor that behaves a bit strange. The value probably isn’t parsable as a number. Maybe you could try changing your sensor to this:

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

Hope this helps.