Perfect explanation of what’s going on and how you’d like it to work. I am almost certain this could be accomplished by sort of modifying the current flow sensor functions. For that approach I would need to know a couple of things about your sensor and how you would like to approach the “when it needs water” problem.
First can the sensor be set to output a signal once a certain threshold of light is met? Say I reach the 10k lux limit to trigger watering does your sensor send 10k or a digital 1? If it sends 10k does it send thousands of pulses until it reaches that amount or does it figure the total and send only the total?
My assumptions are the sensor is sending an analog voltage value for the current lux, so we may need an analog to digital conversion because the standard sensor input for the OS is digital only. Then it is as simple as setting a threshold to water and counting pulses until the threshold is reached.
If that is correct the next thing we need to know is how important is it to accumulate light levels during a watering event? Should we stop measuring the light while watering and then start again? Or should we keep accumulating during a watering event? If we do it the second way what happens if it triggers again while watering? Do we only focus on the current water needed, should we add to the water needed, or do we stop where we are and start again very quickly with the new information?
Okay that seems like enough questions to get the info needed to make it work for you. If I’ve missed what you are looking to do entirely don’t be afraid to let me know. I’d much rather do this right once than have to tweak everything 1000 times. Thanks again for your patience and I’ll definitely get this going for you once I know I’m looking at the problem correctly.
If you already have a light sensor you wish to use or are currently using, could you send me the model number? Then I can look up the data sheet and actually answer pretty much everything I would need to know about the sensor.