Energy: Support for REST sensors

I’m using a REST interface to fetch data from my solar system (Envertech, without any official HA integration), and obviously I’d like to have it included in HA’s Energy.

I was hoping I could just add the attribute

  state_class: measurement 

to the rest sensor, but that gives me

Invalid config for [rest]: [state_class] is an invalid option for [rest].

This means that I’m unable to include my solar system in the Energy dashboard.

→ Please add support for state_class to rest sensors (both RESTful and RESTful Sensor)

As a side note, here’s a thread on the topic:

You can, use customize.

I turns out that with the 2021.11 release of HA, it’s now possible to set the state_class attribute of REST sensors! That’s much more convenient than customizing the entitities. Hurray!