Lovelace: Power wheel card

i cant figure this out.
image

how is the grid and house delivering power to my solar.
the numbers are right only the arrows and calculation is messed up.
how to fix this ?

lovelace:

color_icons: true
grid_power_consumption_entity: sensor.emoncms_grid_consumption
grid_power_production_entity: sensor.emoncms_grid_production
solar_power_entity: sensor.emoncms_solar_production
type: ‘custom:power-wheel-card’
view: energy

config:

- platform: mqtt
  state_topic: "emoncms/grid_consumption"
  name: "emoncms.grid_consumption"
  unit_of_measurement: "W"
- platform: mqtt
  state_topic: "emoncms/grid_production"
  name: "emoncms.grid_production"
  unit_of_measurement: "W"
- platform: mqtt
  state_topic: "emoncms/solar_production"
  name: "emoncms.solar_production"
  unit_of_measurement: "W"

Hi, do you still have the same situation as you had in April here? Please check in your /dev-state page if you have negative values for one/more of your 3 sensors.

If so, please reread my answer I gave you in April here. If you still can’t figure it out, let me help you step by step. But first you have to know for each sensor in what situation it gives you a positive value and when a negative value.

all values are now not negative anymore
image
now i get this error:

Pls check the unit of all power sensors you have as input. They should be defined and be equal to each other.
Don’t mix unit_of_measurement: 'Watt' with unit_of_measurement: 'W', because the card see them as unequal. Nor mix kW with W, etc.

image

is int this correct ?

Seems correct to me. I you still get the error, check for leading or trailing spaces in your unit_of_measurement definition. If there is a 'W ' and the others are 'W' then it’s not going to work.

If that’s not the case, please check if your card is really using this three sensors. You can check that using the debug mode. In the dev console of your browser you can see information about what sensors the card has parsed out of your card definition. More info about debug mode is here: https://github.com/gurbyz/custom-cards-lovelace/wiki/Before-submitting-an-issue-report, see step 3.

If you can’t find the error doing this, please share the complete output of the debug logging here.

it’s possible to integrate in HACS?

1 Like

In a offgrid installation, where there is no any grid source, Could I simply replace the grid entity with my battery entity? This way I will have how much energy my panels are putting in my battery, and how much energy my loads are getting out of my batteries.

What do you think?

Of course, a real battery integration will be great

Essentially the same thing, give it a shot see what happens.

Power Wheel Card should be able to work on Home Assistent Cast now. Thx to @Bram_Kragten for his pull request.

(Nothing changed for HACS integration, but feature request is already made here: https://github.com/gurbyz/custom-cards-lovelace/issues/22)

Version 0.0.14

Improvements

  • Update for HA Cast. LitElement is taken from hui-view.

Fixes

  • Fixed a link in readme.

Is there any way to use this when the grid power production is a negative value? I have two seperate ways to retrieve data for solar, grid energy use and energy to the grid via powerwall2 and fronius sensors, but both provide a negative value for energy going to the grid.

Either sensor ( in this case sensor.pw2_house_now and sensor.fronius_house_usage) give a positive value for grid usage (power draw) or a negative number for grid production (grid feed in).

If a sensor for power handles both consuming from the grid and producing to the grid, you can use grid_power_entity. You should skip the separate input parameters grid_power_consumption_entity and grid_power_production_entity.

Default polarity for this grid_power_entity is: “positive values for producing to the grid”, but you can set production_is_positive: false if you want to swap the polarity.

Thanks, for the info, I will give this a try.

Edit: I am having difficulty with the configuration. I have this, but config y’all check states there is an error but doesn’t give me a line etc just a question mark ?

I have:

grid_power_entity;
friendly name: ‘Grid power meter’
unit of measurement: ‘W’
value_template; >-
{{ (1000 * (states(“sensor.pw2_grid_now”) | float | int }}

What am I doing wrong?

Cheers

Adjust this line: value_template: you have a ; not a :

1 Like

Please use the </>-button in the editor when pasting code. Then the rest is able to see the indents.

I see a ; (after value_template) that should be a :. And there are 3 “(” but only one “)”. The number of parenthesis open vs close should match. Also making it first a float and then an int doesn’t make sense to me. Pls try:

{{ (1000 * (states(“sensor.pw2_grid_now”))) | int }}

EDIT3: And friendly_name should have an underscore in it.

EDIT4: And the ; after grid_power_entity should be a :

1 Like

Ok thanks for all that. I did this on my phone while at the airport so some of the formatting wasn’t accurately reflected to what I had. The brackets and float were a issue. O will have another play when I stop travelling. :+1:

I have a powerwall 2 battery. This is something I would like to implement. How would you do this if the same sensor (in this case power to house or power to the grid) with a positive and negative value (negative to grid) are the values I have to work with? The battery values are along the same lines (positive and negative values) for charging and discharging.

You can make several template sensors for the needed values.

      e3dc_net_power_neg2pos_only:
        unit_of_measurement: 'W'
        value_template: >
          {% if states('sensor.e3dc_net_power') | int > 0 %}
            0
          {% else -%}
            {{ (states('sensor.e3dc_net_power') | int) | abs }} 
          {% endif %}      

      e3dc_net_power_pos_only:
        unit_of_measurement: 'W'
        value_template: >
          {% if states('sensor.e3dc_net_power') | int > 0 %}
            {{ states('sensor.e3dc_net_power') }}
          {% else -%}
            0
          {% endif %}

For showing the card i meanwhile use the state_switch and a template sensor.

       e3dc_pv_batt_power_stat:
        value_template: >
          {% if states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
            sun
          {% elif states('sensor.e3dc_pv_total') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            batt
          {% elif states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
            sun_batt
          {% else %}
            sun
          {% endif %}

lovelace:

          - type: custom:state-switch
            entity: sensor.e3dc_pv_batt_power_stat
            states:

              batt:
                type: "custom:power-wheel-card"
                title: Leistungsverteilung
                solar_power_entity: sensor.e3dc_battery_power_neg2pos
                grid_power_production_entity: sensor.e3dc_net_power_neg2pos_only
                grid_power_consumption_entity: sensor.e3dc_net_power_pos_only
                home_icon: mdi:home-outline
                solar_icon: mdi:car-battery
                grid_icon: mdi:transmission-tower
                color_icons: true
                consuming_color: var(--my-green)
                producing_color: var(--my-yellow)

              sun:
                type: "custom:power-wheel-card"
                title: Leistungsverteilung
                solar_power_entity: sensor.e3dc_pv_total
                grid_power_production_entity: sensor.e3dc_net_power_neg2pos_only
                grid_power_consumption_entity: sensor.e3dc_net_power_pos_only
                home_icon: mdi:home-outline
                solar_icon: mdi:white-balance-sunny
                grid_icon: mdi:transmission-tower
                color_icons: true
                consuming_color: var(--my-green)
                producing_color: var(--my-yellow)

              sun_batt:
                type: "custom:power-wheel-card"
                title: Leistungsverteilung
                solar_power_entity: sensor.e3dc_pv_batt_power
                grid_power_production_entity: sensor.e3dc_net_power_neg2pos_only
                grid_power_consumption_entity: sensor.e3dc_net_power_pos_only
                home_icon: mdi:home-outline
                solar_icon: mdi:solar-power
                grid_icon: mdi:transmission-tower
                color_icons: true
                consuming_color: var(--my-green)
                producing_color: var(--my-yellow)

When the power comes from the sun and the battery it shows
20190821_19%3A50%3A45_001

Thanks for that.

Good info.

Cheers