Lovelace: Power wheel card

Hi @Mariusthvdb,

I read you connected a modbus power sensor. I’ve ordered a solaredge PV-system with a solaredge modbus energy meter. Soon to be installed :slight_smile:

How did you read values trough the modbus connection? What hardware did you use? How is it wired?

I use a Iungo system which is connected to my modbusses (?) and Ha reads the Mqtt topics it publishes

I’ve recently installed a Solaredge PV system with the optional modbus power meter which measures your internal consumption.
I’ve got his set up using the built-in HA integration via solaredge web API
Thought it would be good to install this custom card. Like a few others here, and I assume all solaredge users, the built in solaredge sensors don’t conform to the +ve/-ve values for import/export.
Solaredge has:
‘sensor.solaredge_solar_power’ which gives solar production in kW
‘sensor.solaredge_grid_power’ which is the import (+ve) and export (-ve)
in addition, ‘sensor.solaredge_power_consumption’ tells me how much the house is consuming… I FOUND USING THIS ENTITY JUST CONFUSES ALL THE NUMBERS IN THE POWER WHEEL CARD!!

To make this work I needed both export and import to be positive values. To achieve this I created two template sensors, the first to read export and convert it to a positive value, the second to read import.

Export: this looks at ‘sensor.solaredge_grid_power’. if value is -ve (exporting) it converts to positive. if value already +ve it reads 0.
In the ‘sensors’ section of your config.yaml

platform: template
    sensors:
      solar_power_export:
        unit_of_measurement: 'kW'
        value_template: >-
          {%- if (states('sensor.solaredge_grid_power') | float <0) -%}
          {{ -(states('sensor.solaredge_grid_power') | float) }}
          {%- else -%}
          0
          {%- endif -%}
      solar_power_import:
        unit_of_measurement: 'kW'
        value_template: >-
          {%- if (states('sensor.solaredge_grid_power') | float >=0) -%}
          {{ (states('sensor.solaredge_grid_power') | float) }}
          {%- else -%}
          0
          {%- endif -%}

The second sensor is the opposite, reads the +ve value or zero.

Then in the lovelace frontend (I just add a manual card with this config as I find it easier)

grid_power_consumption_entity: sensor.solar_power_import
grid_power_production_entity: sensor.solar_power_export
power_decimals: 2
solar_power_entity: sensor.solaredge_solar_power
type: 'custom:power-wheel-card'
title: Power Distribution

Voila!

I’m looking to use this card to replicate my Sense monitor’s Solar ‘wheel’ in HA. Issue is I don’t know if I have the right sensors to use this card.

I have two sensors: First is sensor.energy_production which is my instantaneous solar production measured in watts (provided by my Sense monitor). Second is sensor.energy_usage which is my instantaneous house consumption (from both solar and grid) measured in watts. I don’t have sensors for what I’m pulling from the grid or what I’m exporting to the grid.

Can I use just these two sensors to drive the Power Wheel card? Or do I have to create a value template to do the math required to determine the grid import/export amounts? Is that template as simple as grid_nett = sensor.energy_production - sensor.energy_usage?

Use the integration integration to create kWh sensors for the card.

With the 2 values you have you will need to create 2 more. the maths is the easy bit, getting the syntax correct can take some trial and error.
Grid usage = house consumption - solar generation (when > 0)
Grid export = solar generation - house consumption

best way to learn is copy someone else’s code and modify to suit your needs.

If you get really stuck I’ll see what I can do to assist

After getting this up and running I went down another track of installing Floorplan ans whilst this is predominantly as the title suggests, it can be used to create any card where you want graphics to change state.
I integrated my own version of the power wheel and have the arrows change direction and colour based on the value.
I’ve got quite a bit more going on but there’s nothing to stop you making a card using floorplan purely for the power wheel.

1 Like

I assume this Reimann intregral is to get from my current instant Power values to an energy-over-time value? Thanks, I’ll keep it in mind if I decide I want that view.

Sense already provides sensors for solar energy produced and total energy consumed for daily/weekly/monthly/yearly.

Check this out:
Created something you might want to use:

Thanks for the response. Looks like you can actually do it with just a single additional template value: Net Grid Export (positive when you’re exporting power to the grid and negative when you’re importing power from the grid). This is the YOUR_GRID_POWER_SENSOR called out in the power wheel github docs. And using the optional grid_power_entity (C) parameter for the lovelace card.

Here’s my code for future readers:
In Sensors.yaml:

- platform: template
  sensors:
    grid_power_export: # Grid Power Export for Sense Power Wheel
        friendly_name: 'Grid power export'
        unit_of_measurement: 'W'
        value_template: >-
          {{ (states("sensor.energy_production") | float | int) - (states("sensor.energy_usage") | float | int) }}

And here’s my Lovelace Manual Card config:

type: 'custom:power-wheel-card'
solar_power_entity: sensor.energy_production  # <-- the Sense monitor's sensor
grid_power_entity: sensor.grid_power_export  # <-- the template value I created in sensors.yaml

Reminder to install the power wheel card plugin from the HACS marketplace. Also add the module text to your resources section of your lovelace.yaml.

HACS does that for you :slight_smile:

Any idea why HACS requires you to take a 2nd action to add the required module to your lovelace.yaml file? You click the install button, HACs installs, but then it prompts you to click a second button (‘add to lovelace’ or something like that). Why require the two separate actions? Why not just include the ‘add to lovelace’ step in the install process?

You’d have to ask leedus about his design decisions. :slight_smile:

1 Like

Anyo9ne having trouble with the production is positive value? I used to have ‘false’, but this is now changed to ‘1’. When I try to change it to negative 1 or 0 or 2 (trying to work out the false equivalent) it keeps reverting to 1 on save?

Hi everyone,
first thank you for your work!
I’d like to use this card but have a (noob) question about grid power production.
The solar power production sensor is retrieved by a PZEM-004 installed at the exit of my solar system.
The grid power consumption sensor is retrieved by a PZEM-004 installed at the exit of the energy meter.
How can I retrieve values for grid power production? Do I need a 3rd PZEM-004?
Thank you,
SoL

Hi SoL, does the PZEM-004 also gives you the direction of how the power is flowing? E.g. by giving a negative or a positive value of the power? Because otherwise you don’t know if you are measuring consumption (import) or production (export) at “the exit of the energy meter”.

Hi Gurbyz, thank you for your answer.
I have exactly this schema in my grid setup:


The value of the power is always positive.
SoL

On 0.106.0, I’m seeing originally working card now showing as:

“production_is_positive” is read-only

Delete production_is_positive: true gives me:

can’t define property “production_is_positive”: Object is not extensible

Has 0.106 changed anything that would break this custom card? The 0.106 blog post does link to here, but I can’t see anything that might cause this error.

Likely the change has broken the card.

Are you on the latest version?
No problems here with 0.106.0.

EDIT: I tested it! :upside_down_face:

2 Likes

Fixed! Thank you.

I am on latest version, 0.0.16, managed by HACS and hadn’t touched it after upgrade HA to 0.106. Inspired by your issue report on possible download problems, I pressed Reinstall in HACS and the card started to work after a refresh.

1 Like