Lovelace: Power wheel card

Version 0.0.15 has been released.

0.0.15

Improvements

  • Removal of support for Customer Updater.
  • Preparations to support HACS. Repo file tree restructuring and repo name change from custom-cards-lovelace to power-wheel-card.

The repo is prepared for HACS now. But HACS has to accept the card first before you can find it as a plugin in the HACS UI.

EDIT: HACS accepted the PR and Power Wheel Card is available in its store.

1 Like

Wonderful card concept here. Trying to figure out how to get this to work with my setup.

I’m attempting to make a template sensor because I don’t have an actual sensor for whats being delivered back to the grid.
So I created

- platform: template
  sensors:
    solar_production:
      friendly_name: 'Solar Production'
      value_template: '{{ (sensor.solaredge_v2_power_meter.state | float / 1000) | round(2) }}'
      unit_of_measurement: 'kW'
    grid_power:
      friendly_name: 'Grid Power Consumption'
      unit_of_measurement: 'W'
      value_template: >
        {{ (1000 * (states('sensor.whole_house_energy') | float - 
          states.('sensor.solaredge_v2_power_meter') | float)) | int }}

But I’m getting

Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['sensors']['grid_power']['value_template']. Got "{{ (1000 * (states('sensor.whole_house_energy') | float - states.('sensor.solaredge_v2_power_meter') | float)) | int }}\n". (See /config/mqtt/sensors.yaml, line 41). Please check the docs at https://home-assistant.io/components/sensor.template/
Thrown back at me in the logs.

Its my understanding that once I have this plugged in then I can use this sensor in the cards configuration because this sensor “should” show if I’m pumping into the grid or consuming.

Thank you for your assistance with this.

great I was waiting for this integration in Hacs

You hopefully found out already, but there is a dot after states in

states.('sensor.solaredge_v2_power_meter')

Pls remove that dot.

Lol sigh no not yet but thank you. I’ve actually been dealing with a bigger fish. My zwave got all messed up so I just got in the new stick for it today and I’ve been having “fun” adding all of my devices back in.

Alright so now that I’ve sorted out my template mess and I have the sensors reporting in HA now. My grid power is reporting a 0

- platform: template
  sensors:
    solar_production:
      friendly_name: 'Solar Production'
      value_template: '{{ (sensor.solaredge_v2_power_meter.state) }}'
      unit_of_measurement: 'W'
    grid_power:
      friendly_name: 'Grid Power Consumption'
      unit_of_measurement: 'W'
      value_template: >
        {{ (1000 * (states('sensor.home_energy_power_meter.state') | float -
          states('sensor.solaredge_v2_power_meter.state') | float)) | int }}

I know for certain that I am drawing from the grid especially since my dryer is running right now so I’m drawing over 3000W
image
But I don’t get why with my math it would report a 0 there instead of the wattage that I’m consuming.

Ok now off to the next piece

I cannot for the life of me get the card to show up in the lovelace add card section.

This is my current ui config

resources:
  - url: /local/dual-thermostat/dual-thermostat.js?v=2
    type: js

  - url: /local/power-wheel-card.js?v=1
    type: module


views:
  - id: power_usage
    cards:
      - type: custom:power-wheel-card
        solar_power_entity: sensor.solaredge_v2_power_meter
        grid_power_consumption_entity: sensor.whole_house_energy
        grid_power_production_entity: sensor.grid_power
cards:
  - type: custom:dual-thermostat
    name: Downstairs
    entities:
      - entity: climate.honeywell_unknown_type0011_id0003_cooling_1_3
        type: cool
      - entity: climate.honeywell_unknown_type0011_id0003_heating_1
        type: heat
    fan_control: true
    min_slider: 60
    max_slider: 80

I think something broke a while back with my lovelace config because my dual thermostat stopped working but I have no idea what. I know I don’t have much in here and I hope that I have it formatted properly.

Hi how do you get the battery %?

That’s the solax app wheel ss. Is not the custom card

I have had some time to look at your code, and to be honest its beyond me :stuck_out_tongue: I have the power wheel (no battery) working with

- platform: template
    sensors:
      solar_power:
        friendly_name: 'Solar power production'
        unit_of_measurement: 'kW'
        value_template: >-
          {{ (1000 * (states("sensor.fronius_current_production") | float)) | int }}
      
      grid_power_sensor:
        friendly_name: 'Grid power sensor'
        unit_of_measurement: 'kW'
        value_template: >-
          {{ (1000 * (states("sensor.fronius_grid_usage") | float)) | int }}
      

and Lovelace as:

- type: 'custom:power-wheel-card'
        title: House Power Flow
        solar_power_entity: sensor.solar_power
        grid_power_entity: sensor.grid_power_sensor
        production_is_positive: false

I understand that I would have to delete the old template sensors I made above and create new ones,
and that you have changed the negative value of the grid sensor to a positive one, but I am lost on how your code would translate my existing solar and grid sensors?

Is this code below on the right track?

- platform: template
     sensors:
         fronius_grid_usage_neg2pos_only:
            unit_of_measurement: 'kW'
            value_template: >
                {% if states('sensor.fronius_grid_usage') | int > 0 %}
                  0
                {% else -%}
                   {{ (states('sensor.fronius_grid_usage') | int) | abs }} 
                {% endif %}      

         fronius_net_power_pos_only:
         unit_of_measurement: 'kW'
         value_template: >
                {% if states('sensor.fronius_grid_usage') | int > 0 %}
                  {{ states('sensor.fronius_grid_usage') }}
                {% else -%}
                  0
                {% endif %}
            

and for showing the card;

       e3dc_pv_batt_power_stat:       <----- can I name this anything?
        value_template: >
          {% if states('sensor.fronius_current_production') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
            sun
          {% elif states('sensor.fronius_current_productionl') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            batt
          {% elif states('sensor.fronius_current_production') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            sun_batt
          {% else %}
            sun
          {% endif %}

Not sure what your ‘sensor.e3dc_battery_power’ is? What do I use here?

Thanks for any help on this.

The indentation is a bit off, should be

- platform: template
  sensors:
    fronius_grid_usage_neg2pos_only:
      unit_of_measurement: 'kW'
      value_template: >
        {% if states('sensor.fronius_grid_usage') | int > 0 %}
          0
        {% else -%}
          {{ (states('sensor.fronius_grid_usage') | int) | abs }} 
        {% endif %}      

    fronius_net_power_pos_only:
      unit_of_measurement: 'kW'
      value_template: >
        {% if states('sensor.fronius_grid_usage') | int > 0 %}
          {{ states('sensor.fronius_grid_usage') }}
        {% else -%}
          0
        {% endif %}

Whatever you want.

This is the value from the battery (positive = charging, negative = discharging)

You also have to create template sensors for the battery (neg to pos when discharging) and one for the addition of the sun and battery.

Ok got it. Just lost on the sun and battery sensor. How is that being templated? Cheers

This is the template for the solar_power_entity i use. Remove the comments if you use it.

      e3dc_pv_batt_power:
        unit_of_measurement: 'W'
        value_template: >
          # Sun is shining and battery is charging
          {% if states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
            {{ states('sensor.e3dc_pv_total') }}
          # Sun isn't shining and battery discharging
          {% elif states('sensor.e3dc_pv_total') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            {{ (states('sensor.e3dc_battery_power') | int) | abs }}
          # Sun is shining and battery discharging 
          {% elif states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            {{ states('sensor.e3dc_pv_total') | int + (states('sensor.e3dc_battery_power') | int) | abs }}
          {% else %}
            {{ states('sensor.e3dc_pv_total') }}
          {% endif %}

BTW, now that i look at my config, this sensor template could be used for all 3 cards that i show with the state switch.
The only reason for the 3 cards was to have another icon for the solar_icon

Ok, thanks for all your help. Sadly, despite my best efforts, I am struggling with this one coming from a non-coding background. This is the first one that has beat me so far. I may look at this again later when I have a clearer head. Or who knows, might be lucky and have the a battery implemented in this power wheel card at some future date :sunglasses:

Hey all. I just got a new SolarEdge installation on my roof - just missing more sun as it started to rain since the works are done :wink:

I’m puzzled with how to match the solaredge sensors with the requirements of the power wheel card. Here the sensors I have available:

  • sensor.solaredge_solar_power : the production in kW from my PV panels
  • sensor.solaredge_power_consumption : the total current power consumption, in kW, from my house
  • sensor.solaredge_grid_power : how much I’m drawing (+) or injecting (-) from the grid, in kW

solar_power is straightfoward but I’m puzzled about how to match the other ones with the required entities for both power & energy panels.

1 Like

Some simple rules are:

  • For power view only use sensors in unit W (or kW).
  • For energy view only use sensors in unit kWh (or Wh, MWh, etc.).

About your 3 sensors:

  • Use the first one for solar_power_entity
  • Use the third one for grid_power_entity, but also set parameter production_is_positive: false to swap the polarity of this input sensor

The second sensor isn’t necessary, because the card will calculate the power your house is consuming.

I hope you will see the sun soon! :wink:

1 Like

@gurbyz Thanks, works great ! I now only need to find a way to get a Wh sensor for my grid usage. The SolarQuest has a sensor for solar production in Wh (“energy today”, “energy this month”, “energy this year”) but not for the grid sensor.

Would there be a way to create a custom sensor (template / history /…) that compute a grid energy Wh value based on some time rule and the grid_power_entity ?

Maybe I have to revise my first answer. Looking at your 3rd sensor, you write “how much I’m drawing (+) or injecting (-) from the grid, in kW” but I have to read / you have to add something to it. That is “as far as your solar panels know”. And the sensor of your solar panels doesn’t know e.g. what is consumed from the grid and directly going into your home.

To really see what you house is consuming and what you are consuming from the grid or delivering to the grid you need an extra sensor placed where the electricity is entering your house. Some people have a DSMR (a digital meter) that can be connected to HA. Other people use ‘clamps’ on certain electricity cables.

I do have that extra sensor indeed. It was optional on the solaredge inverter and I took that option. It is indeed via an amperometric clamp.

O, great, then your inverter indeed does know about grid consumption/production and the configuration for the power view is correct.

Maybe for the missing energy sensor (Wh), you can create something with a template sensor on top of a statistics sensor? Please note that for taking the most out of the power-wheel-card you have to create two Wh sensors for the grid: one for consuming from the grid and one for producing to the grid. (See also the readme file > requirements for energy view > point 4i and 4ii.)

An example to make that clear: let’s say you have one sensor and it has a value of +50 Wh. Then you don’t know if that’s the value because you produced 50 Wh to the grid and didn’t consume anything from the grid. If you have both sensors then they could have values of e.g. +250 Wh and -200 Wh and you know what happened exactly to get the nett result of +50 Wh.

You should use https://www.home-assistant.io/components/integration/ instead of the statistics sensor

3 Likes