xiaomi flower sensor integrated in HA reports lux values while in xiaomi app you can see also light accumutation (useful if you want to see if plant position is good or not)
Can someone please support me to create a sensor that combine single values in a new one?
I have been looking into the same thing. As far as I understand the most difficult step is to calculate the integral of the graph; that is to calculate the area under the curve (of the lux sensor). But we need to do it numerically and with nonumiform spacing between data points.
I’m thinking there must be some python libraries that can be used.
Ok so I did some research and experiments.
The first problem is that I don’t have a quantum sensor, which is required to get accurate measurements.
Instead I have to make an assumption that my lux readings matches a pre calibrated light source.
So to convert my lux measurements to PPFD (Photosynthetic Photon Flux Density) as if it was sunlight I use this table: PPFD to Lux conversion
Next step is to calculate the integral of all measured values over a whole day.
For this I found a python library called scipy which has numerical integration functions, of which I used the integrate.trapz function. It takes two arrays (here PPFD values and timestamps from HA) as input and gives a single number as output.
Because the timestamp includes microseconds I divide by 1000000 which should give me the unit μmol/day-m^2 and then by 1000000 again to get mol/day-m^2 which is the unit for DLI.
I am not sure how accurate all of this is but here are the results for two of my plants.
Plant 1 which is standing outside near an east facing wall:
DLI = 27.17
Plant 2 which is standing a bit inside from an east facing window:
DLI = 2.36
FYI, HomeAssistant already has a integration sensor capable of both the Riemann sum or trapezoidal method.
You might just be able to throw the Lux sensor into the integration sensor and get a reasonable output. Or use a template sensor to convert Lux to PPFD, and integrate that.
I can now see that the Integration Sensor is a cumulative sensor that does not reset every day. So some combination of Statistics Sensor and History Statistics Sensor would also be needed. I might look into a custom version of the Integration Sensor when I get the time again.
Edit: Maybe the Utility Meter component could be used instead to get daily peak values of the Integration Sensor.