Sensor calculateion on the fly?

With the last update we got power graphs in the energy dashboard. That’s great.

To get the reading right, I have to choose a sensor that creates positive numbers when energy flows OUT of the battery. My battery counts exactly opposite.

So the natural(?) solution is to create a sensor that simply negates the value of the current sensor. This certainly works great.

But … I create just another sensor that stores yet another series of values in the statistic database. And I only get values, starting with the time of the creation of the new sensor.

What I REALLY want is a sensor that just calculates “value = -other_sensor” wherever a value is needed. Need a history? Request “value = -other_sensor” from the current history of an existing sensor.

Or a possibility to name “a formula” wherever “a sensor” is asked.

Similar to a unit-conversion.

Does that sound unrealistic?

Seems like you want a similar thing as I requested here:
https://github.com/orgs/home-assistant/discussions?discussions_q=is%3Aopen+author%3ATheFes+

You can create template sensors to get usable sensors for the Energy Dashboard, but if you want to use the already existing history, you need to be able to use the existing sensors. Maybe you can add your request to mine.