jeroenterheerdt / HAsmartirrigation

Smart Irrigation custom component for Home Assistant
MIT License
301 stars 47 forks source link

Incorrect calculation including rain #304

Closed elenril2 closed 7 months ago

elenril2 commented 7 months ago

What happened?

It appears that the bucket calculation incorrectly took into account rainfall. Over the last few days with no rain, the bucket has shrunk by about 2mm. Last day, my weather station recorded 9. 9mm of rainfall, and the bucket count was still 0.2mm off.

How to reproduce

Submit a rainfall that exceed standard bucket.

Relevant log output

Nothing unexpected in log.
Diagnostic file:
[config_entry-smart_irrigation-f2f59f4233cca0fb6e63c993212765fb.json.txt](https://github.com/jeroenterheerdt/HAsmartirrigation/files/12839181/config_entry-smart_irrigation-f2f59f4233cca0fb6e63c993212765fb.json.txt)

Which version are you running?

v2

Diagnostics file

Additional information

I use a cumulative rain sensor from my weather station. In sensors groups I use the default, last of sensor values to calculate duration. Evapotranspiration source is none, and in the modules section I choose PyETO not to estimate, so if I read the documentation correctly, it should use my solar radiation sensor.

Info from calculation:


Note: this explanation uses '.' as decimal separator and shows rounded values. Module returned Evapotranspiration deficiency of -0.2. Bucket was -4.1.
maximum bucket size is 20.0.New bucket value is [old_bucket]+[delta]=-4.1+-0.2=-4.3.
Since bucket < 0, irrigation is necessary.
To calculate the exact duration, the following steps were taken:
The precipitation rate is defined as [throughput]*60/[size]=18.0*60/106.0=10.2
The duration is calculated as abs([bucket])/[precipitation_rate]*3600=4.3/10.2*3600=1526
Now, the multiplier is applied. The multiplier is 1.0, hence the duration is 1526
Then, the maximum duration is applied. The maximum duration is 3600.0,
Finally, the lead time is applied. The lead time is 0.0, hence the final duration is 1526```
RobinI30N commented 7 months ago

The problem may be due to the fact that the integration works in UTC time. If you are in a different time zone, calculations may be made when the weather station resets the daily rainfall. This is an integration error - it should be possible to set TZ to synchronize the activities of the weather station and integration. I have the same problem.

jeroenterheerdt commented 7 months ago

@RobinI30N where do you see that we're tracking UTC time? We track intervals, which has nothing to do with timezones and sunrise, which should be automatically converted by HA to your timezone. Unless I am missing something I don't think this issue is related to UTC time.

jeroenterheerdt commented 7 months ago

@elenril2 rainfall does not equate bucket negative increase. Loads of other factors go in, including wind speed, temperature, etc. I can't spot any issue with the data in the diag file. So you had X mm rainfall, but maybe it was not windy? was it very sunny? warm?

RobinI30N commented 7 months ago

Iryg1 iryg2 inryg3 I took the screenshot a moment after manually performing the calculations. The automatic calculation set for 23:00 will be performed the next day at 1:00. My WS resets the daily rainfall at 0:00. You may need Maximum rainfall measurement? I set the automatic calculation time to 9:00 p.m. which should perform the calculations at 11:00 p.m. Maybe I'm wrong, I need time to check it thoroughly.

iryg4 Daily rainfall - at this point the calculation takes place when it is set to 23:00

elenril2 commented 7 months ago

In my case the calculation time is correct, I am currently UTC+2. I set this time to 23:55 so that it occurs just before the sensor data resets. In the case of RobinI30N, however, it may be a different error, because I think he is also in my time zone, and has a greater offset relative to UTC. image image

I realize that irrigation time also takes into account factors other than rainfall, but I know from experience and daily tracking of calculations in V1 that in my case it is impossible to compensate for 10mm of rain. In summer, the highest readings per day were 4-5 mm subtracted from the bucket. In the last few days it was about 2mm. For reference, here is the debbug log from yesterday, made after the last data update before the calculation itself. config_entry-smart_irrigation-f2f59f4233cca0fb6e63c993212765fb.json (5).txt The results are a bit disturbed by multiple calculations just after midnight - this was probably caused by the changes I made in the automatic weather data update section (by the way, it is possible that these duplicate entries in the log from this period are also an error, as I understand it, because the dynamic script loaded each my value entry in this section). My delta yesterday was 0.015, which I also suspect may be wrong - it was a very damp and cold day, albeit with quite a lot of sun, but I don't think the bucket without rain would have decreased by more than 2-3mm (and there was over 4mm of rain - therefore the bucket should increase by approximately 2mm). Is there any simple way to check these calculations? Could you remind me of the calculation formula? As I understand it, Evapotranspiration from the module is first calculated and then compensated with potential precipitation?

jeroenterheerdt commented 7 months ago

Iryg1 iryg2 inryg3 I took the screenshot a moment after manually performing the calculations. The automatic calculation set for 23:00 will be performed the next day at 1:00. My WS resets the daily rainfall at 0:00. You may need Maximum rainfall measurement? I set the automatic calculation time to 9:00 p.m. which should perform the calculations at 11:00 p.m. Maybe I'm wrong, I need time to check it thoroughly.

iryg4 Daily rainfall - at this point the calculation takes place when it is set to 23:00

This makes zero sense. Have you set up your timezone in HA correctly? We are just asking HA to track the local time so whatever timezone you set up in HA config should be applied by HA.

jeroenterheerdt commented 7 months ago

In my case the calculation time is correct, I am currently UTC+2. I set this time to 23:55 so that it occurs just before the sensor data resets. In the case of RobinI30N, however, it may be a different error, because I think he is also in my time zone, and has a greater offset relative to UTC. image image

I realize that irrigation time also takes into account factors other than rainfall, but I know from experience and daily tracking of calculations in V1 that in my case it is impossible to compensate for 10mm of rain. In summer, the highest readings per day were 4-5 mm subtracted from the bucket. In the last few days it was about 2mm. For reference, here is the debbug log from yesterday, made after the last data update before the calculation itself. config_entry-smart_irrigation-f2f59f4233cca0fb6e63c993212765fb.json (5).txt The results are a bit disturbed by multiple calculations just after midnight - this was probably caused by the changes I made in the automatic weather data update section (by the way, it is possible that these duplicate entries in the log from this period are also an error, as I understand it, because the dynamic script loaded each my value entry in this section). My delta yesterday was 0.015, which I also suspect may be wrong - it was a very damp and cold day, albeit with quite a lot of sun, but I don't think the bucket without rain would have decreased by more than 2-3mm (and there was over 4mm of rain - therefore the bucket should increase by approximately 2mm). Is there any simple way to check these calculations? Could you remind me of the calculation formula? As I understand it, Evapotranspiration from the module is first calculated and then compensated with potential precipitation?

There is no simple way to check unless you want to read the scientific papers... Quickest way is set up pyeto library in a test script and run the data from your diagnostic file through it after applying aggregates. That's what I do. Now we have a weird issue with precip when using OWM, so maybe that caused it?

RobinI30N commented 7 months ago

iryg

I have TZ set correctly in HA. The installation is on Docker and UTC is actually set there. It has always worked properly and all HA schedules execute correctly. There were also no problems with irrigation of the V1.

Thank you

jeroenterheerdt commented 7 months ago

iryg

I have TZ set correctly in HA. The installation is on Docker and UTC is actually set there. It has always worked properly and all HA schedules execute correctly. There were also no problems with irrigation of the V1.

Thank you

Which version of the v2 are you running?

RobinI30N commented 7 months ago

Yes,, last v2

jeroenterheerdt commented 7 months ago

Yes,, last v2

For me to be able to change this down I need to get a diag file from you or at minimum the actual version number. Not 'last'.

RobinI30N commented 7 months ago

Sorry, the calculations are performed at the correct local time. Only the information from the zone tab is displayed incorrectly. This has no effect on operation. This confused me. I have v2023.9.2 - I will monitor its operation

jeroenterheerdt commented 7 months ago

Sorry, the calculations are performed at the correct local time. Only the information from the zone tab is displayed incorrectly. This has no effect on operation. This confused me. I have v2023.9.2 - I will monitor its operation

thanks

elenril2 commented 7 months ago

I think I found a bug. I am checking data from the calculate_et_for_day function. I noticed that it took the precip value as 1.4895833333333333, even though my sensor (set to last) was reading 3.8mm that day. Why did this happen? I have the forecast days set to 0, so it seems to me that the actual rainfall should be directly taken into account when calculating eto. Based on the number of decimal places, it looks like it may be an average, not the last value.

jeroenterheerdt commented 7 months ago

Please open another bug instead of tagging on something else.

elenril2 commented 7 months ago

Hmmm... but this is directly related to my original submission opening this topic.

jeroenterheerdt commented 7 months ago

please open a new issue regardless as I need a new diag file and version info