How do i get graphs for my solar panels (smart plugs that show -watt values)

I have some smart plugs in home assistant, running on z2m, that report wattage in minus values because they are connected to solar panels. But the KWH values from these plugs stay on 0, they do not support minus values.

How do i get graphs from these plugs, so i can see their values individually but also together, and over time?

Thanks!

You can feed the power readings to the Riemann Sum helper to measure energy. Be sure to use method: left.

To get totals of your individual sensors you can create template sensors (be sure to create an availability template as well to prevent odd readings if one or more sensors becomes unavailable).

To get graphs just add the entities to a history graph card:

i used this and messed around with it, however i see that my graphs and meters are upside down. it starts at 0kwh and the graph drops down. How do i reverse this way of reporting?

You would need to create template sensors for your power sensors that removes the minus sign and makes them positive.

template:
  - sensor:
      - name: PV Array Power
        state_class: measurement
        device_class: power
        unit_of_measurement: W
        state: "{{ states('sensor.your_minus_power_sensor_here')|float(0)|abs }}"
        availability: "{{ has_value('sensor.your_minus_power_sensor_here') }}"

Then feed these power sensors to the Riemann Sum integration to get energy.

Then use those energy sensors in your energy dashboard.

it is not working. i created the templates and they are showing watt values, but the riemann som gets no values.

It also suggests values at the end that are a bit extreme. megawatts etc.

The Riemann Som is created successfully, but does not report anything.

Firstly, for your Riemann Sum helpers:

Also can you show the template sensor configs please?

here you go. what they are showing:
image
the template itself:

screenshotted the above helper template as maybe i created a template the wrong way/location?

Yeah that is the wrong place. Delete that UI helper.

This:

template:
  - sensor:
      - name: PV Array Power
        state_class: measurement
        device_class: power
        unit_of_measurement: W
        state: "{{ states('sensor.your_minus_power_sensor_here')|float(0)|abs }}"
        availability: "{{ has_value('sensor.your_minus_power_sensor_here') }}"

Needs to go in your configuration.yaml file. Then restart home assistant.

that worked perfect, thanks a lot!

1 Like