Lovelace: Power wheel card

Hi @kroonen,

I’d like to keep the code as simple as possible. Instead of taking into account every situation that could occur for an individual sensor, there are some requirements in the readme. Otherwise the card becomes too heavy/slow and/or the code too complex. E.g. the value of the sensor always should be parsable as an int of float. The value ‘unknown’ doesn’t comply to that.

Maybe you already know how to fix this with a derived sensor, but then the explanation below can be useful for other people.

You can create a sensor based on your solarpanel sensor that is complying to the requirements:

sensor:
  - platform: template
    sensors:
      better_sensor:
        friendly_name: 'My better sensor'
        unit_of_measurement: 'W'
        value_template: >-
          {%- if is_state('sensor.original_sensor', 'unknown') -%}
            0
          {%- else -%}
            {{ states('sensor.original_sensor') }}
          {%- endif -%}

Then use the sensor.better_sensor as input for the card. I expect that both solar value and home value in the power-wheel-card will be correct when you do this. It’s because the ‘unknown’ value will be replaced by a zero value.

If you don’t want to record both sensors in your database, you can exclude one in your recorder setting.

recorder:
  exclude:
    entities:
      - sensor.original_sensor
1 Like

Thnx for this solution, this also a good option.

1 Like

best would be when the original sensor wouldn’t return ‘unknown’ of course… maybe you should file an issue at the components GitHub. Even at night/dark the sensor should work correctly and show 0, if no energy was produced.

Thank you very much. I really love this card!

1 Like

Awsome card!! Thanks! Any update on the saving/costs config anyone?

The card doesn’t work anymore.
Tried a fix for other custom cards, but no luck.

That fix worked for me, though I didn’t do the whole clear cookie and reboot HA thingy. Just a few page refreshes later ctrl+F5.

1 Like

You’re right, hammering CTRL-F5 on the keyboard multiple times fixed it.

1 Like

see Custom animated weather card for Lovelace for a local solution, hope @gurbyz will check if this is a viable option for the Powerwheel card! No reason to depend on the cloud.

As it stands, the card won’t load with this local setting, so probably a version conflict.

1 Like

I’m about to release version 0.0.5. I first do the fix which @VDRainer referred to. For a future release I will look into the suggestion of @Mariusthvdb which looks promising.

EDIT: version 0.0.5 has been released.

2 Likes

Hi @eh50. Please have a look in the changelog for the next release where the money view is introduced. This version will be released soon. Currently I’m figuring out if I can make an option for auto toggling through the three different views.

To everyone: if you want to prepare for release 0.0.6 please read about the breaking changes. You can already setup the new sensors and have a more smooth start when it will be released.

1 Like

Thats just awesome, going to buy my solar panels soon and a power wall. Would be super to have it all intergrated. Will tinker around with the money option.

Also, i’ve changed the url and from the webui in firefox it works again. Though, the IOS app doesnt show the card, still broken. Anyone knows how to clear that cache?

Thanks!

Edit: We also need a way to tackle the High/Low rate of the energy price, perhaps based on time? or based on a sensor, my “Slimme meter” (dsmr 5) has a value of tariff low/normal

Yes, I’ve posted a request like that here
Lovelace: Power wheel card - #69 by Mariusthvdb Maybe that got buried under several other issues. Anyways a big + for that :wink:

1 Like

It worked for me too . Thanks!

Clearing the cache of iOS web apps isn’t possible, as far as I know. But you can trick iOS web view cache by changing the filename of the cached file by adding/changing a dummy parameter when importing it in ui-lovelace.yaml. Look for the word Note in the first post of this topic please.

clearing the cache for the app is only possible by deleting the app and then reinstalling. had to do that frequently when changing icons in the Tiles setup, or other images.

might not be necessary for this card alone, and the Note-trick would do probably.
Otoh, I’m not using the app with Lovelace yet, and use the Chrome app on my iPhone for that. And that shows the red card also, as it does for other cards like the Dark Sky weather card. Clearing the app there wouldn’t help, so Im stuck for now with this… Or?

1 Like

I’m sure you tried clearing the iOS Chrome app cache already and updated the ?v=number parameter. Maybe opening the power-wheel-card.js file and the lit-element.js file directly in your Chrome app? And refresh that? It’s just guessing. Cache invalidation is said to be one of the two hard things in Computer Science. :wink:

Image of version 0.0.6 (not released yet):
Home_Assistant
I’m investigating that, but I’m not convinced that it will be very significant for the card. E.g. yesterday, my house burnt 14 kWh. That is 2.63 euro when calculating with the average price for high/low tariff. If all was burnt in low tariff, that would be 2.54 euro. If all was high tariff, that would be 2.73 euro. But probably some was low and some was high, so that would be about 2.60 à 2.66 euro. I can live with just displaying the 2.63 euro on the card. How about you guys?

Of course you can double the amount of sensors and variables for grid energy in HA and I could add a lot of card parameters and double the complexity of the calculations, but you still have to find a solution for not having the production of the solar panels split in high and low tariff. Since solar energy production is part of many calculations, I then can’t put the costs/savings in all display positions of the card anymore (without falling back to an average energy price for high/low tariff).

So, it’s not looking good for this feature request for the card. :wink: But it’s possible to do this (only for grid energy, not for home energy and solar energy) in HA itself (not in the card) with some extra sensors and variables. This could be useful if you have a grid energy sensor with a larger scope than ‘energy this day’. Then it gets more significant.

not really sure where you live, but right now isn’t the best time for comparing differences between low and high tariff (living in the Netherlands in wintertime…) During summer when it really makes a difference and one can ‘plan’ the power consumption during sun hours, this will be significant.

and, even so, if you create this, you would want it to be precise wouldn’t you, especially when all data is available in HA, reading the DSMR or other Solar panels sensors.

that being said, Im still struggling to find the difference between the coming update 0.06 with the money view and the new sensors opposed to:

  - type: 'custom:power-wheel-card'
    title: 'Power distribution'
    solar_power_entity: sensor.zp_actuele_opbrengst
    grid_power_entity: sensor.netto_verbruik
    solar_energy_entity: sensor.solar_energy_entity
    grid_energy_entity: sensor.grid_energy_total
    color_icons: true
    power_decimals: 2
    energy_decimals: 2
    initial_view: energy

which is my current setting. unless you say the new sensors do the math, which right now is performed by my sensors.
Note that I don’t have the home-sensors either, but I don’t think I am missing out on anything?
please have a look if you would, thanks!

these are my sensor grid energy:

grid_energy_total_verbose:
  friendly_name: Grid energy total verbose
  unit_of_measurement: 'kWh'
  value_template: >
    {{ (states('sensor.teller_1')|float + states('sensor.teller_2')|float -
        states('sensor.teller_1_terug')|float - states('sensor.teller_2_terug')|float -
        states('sensor.teller_1_daystart')|float - states('sensor.teller_2_daystart')|float +
        states('sensor.teller_1_terug_daystart')|float +
        states('sensor.teller_2_terug_daystart')|float)|round(2) }}

grid_energy_total:
  friendly_name: Grid energy total
  unit_of_measurement: 'kWh'
  value_template: >
    {{(states('sensor.grid_energy_teller_1')|float + states('sensor.grid_energy_teller_2')|float)|round(2)}}

grid_energy_teller_1:
  friendly_name: Grid energy 1
  unit_of_measurement: 'kWh'
  value_template: >
    {{ (states('sensor.teller_1')|float - states('sensor.teller_1_terug')|float -
        states('sensor.teller_1_daystart')|float + states('sensor.teller_1_terug_daystart')|float)|round(2) }}

grid_energy_teller_2:
  friendly_name: Grid energy 2
  unit_of_measurement: 'kWh'
  value_template: >
    {{ (states('sensor.teller_2')|float - states('sensor.teller_2_terug')|float -
        states('sensor.teller_2_daystart')|float + states('sensor.teller_2_terug_daystart')|float)|round(2) }}

my grid_power_entity cant be split up because it is read directly from the DSMR… so, how to proceed here?

Hello, love your card :heart:

I would just like to share some of the backend work I’ve been doing (currently under review)

https://github.com/home-assistant/home-assistant/pull/19718

I think this will help everyone :slight_smile:

1 Like

If you’re using the HA DSMR component you already would have your power and energy sensors split in consumption and production at your disposal.

If you’re using other ways (I don’t exactly know what you mean with ‘direct’ reading) and you don’t have the input sensors split in consumption and production, you could derive the two yourself. Something like:

grid_energy_consumption:
  friendly_name: Grid energy consumption
  unit_of_measurement: 'kWh'
  value_template: >-
    {%- if states('sensor.grid_energy_total') | float > 0 -%}
      {{ states('sensor.grid_energy_total') }}
    {%- else -%}
      0 
    {%- endif -%}

The production sensor would have < 0 and a minus sign before taking the value, because both consumption and production sensor have to be positive for the card.

But looking again at your sensor setup, you seem to have both sensors: teller_1 would be consumption and teller_1_terug would be production? Since the card doesn’t do two counters, you would have to add teller_1 and teller_2 for consumption and you would have to add teller_1_terug and teller_2_terug for production.

Hope this helps you and others to set up the card as of version 0.0.6 which will be release soon.