Calculate own Solarproduction

Hello everyone. I am new with InfluxDB 1.8 and Grafana and want to calculate the amount of power i am overproducing and selling. I have read out my smartmeter and got information from my Fronius inverter every second.

Thats the idea

image

To compare the usage with production and if there is a minus a want to add them. That i know how much power i sold and how much a consumed.

With Chatgpt i got the following code:

CREATE CONTINUOUS QUERY subtract_query ON Nodered BEGIN
  SELECT A.field_A - B.field_A AS result INTO new_measurement
  FROM measurement_A AS A
    JOIN measurement_B AS B ON A.time = B.time
  WHERE A.time >= now() - 1d
  GROUP BY time(15m)
END;

If possible, it would be very nice to set the retention time for Measurement A and B on maybe 1 week or so.

I would be very gratefull if someone could ceck the and the idea - wheter it is correct and possible or not

Thank you for help

Any ideas? i will not break my actual config.

Hello @Hans_Wurst,
That would work if you want to set up a continuous query.
You can only set retention policies to buckets/databases not individual measurements.

You can also use a client library and python for example to do any transformation work you need.

Thank you for your help and for the important information about the retention policies

I Solved it on another way - i am now using the Performance measurement and sum the negative values to see what I feed into the power grid.