Lovelace: Power wheel card

yes, I’ve thought about saving these values. Might be better to have the CC variable do that? Custom component to declare/set variables

it can store several historic data, maybe easier? I use it in various other places and it works beautifully.

could you share your input_number setup? I don’t have that yet.

still, I am a bit surprised your DSMR doesn’t support this, aren’t that industry standardized configurations?

Thx for the link. Here’s the setup that I use to get the values of the meter counters every midnight.

The input_numbers in configuration.yaml:

input_number:
  solar_energy_midnight:
    name: "Solar energy production 00:00"
    min: 0
    max: 999999
    mode: box
    unit_of_measurement: 'kWh'
    icon: mdi:white-balance-sunny
  grid_energy_consumption_midnight:
    name: "Grid energy consumption 00:00"
    min: 0
    max: 999999
    mode: box
    unit_of_measurement: 'kWh'
    icon: mdi:flash-circle
  grid_energy_production_midnight:
    name: "Grid energy production 00:00"
    min: 0
    max: 999999
    mode: box
    unit_of_measurement: 'kWh'
    icon: mdi:flash-circle
  home_energy_midnight:
    name: "Home energy consumption 00:00"
    min: 0
    max: 999999
    mode: box
    unit_of_measurement: 'kWh'
    icon: mdi:home

The automation:

- alias: set_energy_midnight
  trigger:
    platform: time
    at: '00:00:00'
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.solar_energy_midnight
      value: >-
        {{ states("sensor.solar_energy") }}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.grid_energy_consumption_midnight
      value: >-
        {{ states("sensor.grid_energy_consumption") }}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.grid_energy_production_midnight
      value: >-
        {{ states("sensor.grid_energy_production") }}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.home_energy_midnight
      value: >-
        {{ states("sensor.home_energy") }}

Then I use their values in other sensors, e.g.

- platform: template
  sensors:
    solar_energy_today:
      friendly_name: 'Solar energy production today'
      unit_of_measurement: 'kWh'
      value_template: >-
        {{ (states("sensor.solar_energy") | float - states("input_number.solar_energy_midnight") | float) | round(3) }}
1 Like

Aha, I see now. You use these as I use my daystart sensors. I don’t need these input_numbers for that. Luckily :wink:

I thought you wanted to save the daily usage/production somehow. Since we’ve disable the sensors_today in recorder, it would be possible to do the same to my sensor.grid_energy_total, save it automatically at midnight in a sensors/input/variable, and have recorder record these values once a day, instead of constantly during the day.
Hope this makes sense…

input_number:
  daily_grid_energy
    name: 'Daily grid energy production 00:00"
    min: 0
    max: 999999
    mode: box
    unit_of_measurement: 'kWh'
    icon: mdi:flash-circle


variable:
  daily_grid_energy:
    value: 'Not set'
    restore: true
    attributes:
      icon: mdi:ener-circle
      name: 'Daily grid energy'

automation:
# Update Grid energy variable
  - alias: 'Update Daily Grid Energy'
    id: 'Update daily grid energy'
    initial_state: 'on'
    trigger:
      platform: time
      at: '00:00:00'

    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.daily_grid_energy
          value: >-
            {{ states('sensor.grid_energy_total') }}
      - service: variable.set_variable
        data:
          variable: daily_grid_energy
          attributes_template: >
            {
                  "history_1": "{{ variable.state }}",
                  "history_2": "{{ variable.attributes.history_1 }}",
                  "history_3": "{{ variable.attributes.history_2 }}",
                  "history_4": "{{ variable.attributes.history_3 }}",
                  "history_5": "{{ variable.attributes.history_4 }}"
            }
        data_template:
          value: >
            {{ trigger.to_state.attributes.friendly_name }}

beware, this is a quick and dirty transplant of one of my other variable automations, so i must still check everything… especially the data_template, which seems a bit useless right now.
Added a quick input_number to it, so recorder can save that too …:wink:

Would just like to share a new recently added icon:

mdi:transmission-tower

https://materialdesignicons.com/icon/transmission-tower

2 Likes

@dgomes Been wanting this. This will work well for me.

UPDATE: I can’t get this icon to show… :exploding_head:

Great icon @dgomes . I will add this as the default icon for the grid in the next release after HA includes this icon.

@cjsimmons The icon is just created at https://materialdesignicons.com. It takes a while before you can use it in HA. See this topic.

@gurbyz thanks. I did not know about that. Learnt something new. :slight_smile:

@gurbyz, great lovelace card.

I have one question. I’m using the plugin from hass for my solarpanel (sma). This gives values wh en the sun is up, and works fine. At night, the sma plugin gives the status: unknown. Because the power wheel gives with the solar NaN W, but also the home power is now NaN W. (see picture). It should be nice that if the solar is not working or unknown is that the power grid is the home power.

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