Solar production from a Restful sensor to Energy Dashboard

I’ve been trying to find a way to get my solar panels production to show up in the Home Assistant Energy Dashboard, but haven’t been able to figure out a way to do it.

The problem is, that my solar inverter is too old to provide any direct way to integrate it with HA. The only thing I have is a cloud service provided by the company that installed my panels, which includes an API I can use to get my current production values. So I created a Restful Sensor to do just that:

 platform: rest
     resource: "*URL*"
     name: "Solar power"
     value_template: "*Code*"
     device_class: energy
     unit_of_measurement: "W"
     unique_id: "Solar_Production"
     state_class: total

The sensor itself is working fine, and I can see its data in the Statistics tab in the Developers Tools page. It shows a nice graph with accurate numbers.

I’ve tried various combinations of device_class (power/energy) and state_class (total/measurement) with no luck. The UI says that the sensor should report Wh, so I tried that too. No luck. I just couldn’t get the sensor to show up in the Energy Dashboards sensor list for Solar Production.

So does anyone have any ideas how to I could get this working? The value I get from the API is the current power of the array in watts. Is it even possible to get Home Assistant to use this kind of data in the Energy Dashboard?

I managed to solve this, so I’ll post the solution here in case someone else might benefit from it in the future.

What I needed was a helper to convert the value to an hourly value of kWh. I found the solution from the documentation of the Energy Integration in HA’s integration store. It pointed me to the Riemann sum integral integration, which I then created according to the instructions on the page.

And I changed my rest sensor to class of power and state_class of measurement.

Now I see my solar production in the Energy Dashboard and the values seem correct.

1 Like