wirelesssensorsNew.py to fix loss of rain data on WR2 reset
Feb 6, 2023 8:21:11 GMT -8
SDL likes this
Post by berne on Feb 6, 2023 8:21:11 GMT -8
Hi Doc,
I finished coding a new wirelessensorsNew.py which I am attaching for your review and comment. This uses a new SQL table SkyWeather2.adjusttotalrain to store cumulativerain and corrected TotalRain values. This table only updates when raining or after a WR2 reset. Also attaching the SQL for this new table. The first row in this table needs to be populated by the user based on their own corrected data for total rain and current cumulativerain data.
(I exported SkyWeather2.weatherdata to excel and did a whole slew of corrections to the bad data using excel, including correcting TotalRain. I then copied weatherdata to weatherdata_BU, then truncated the weatherdata table and reimported the fixed data as a csv file. This was all done using phpmyadmin.)
I've had this running now for over a day without any problems. weatherunderground and your dash app are working correctly and weatherdata and indoorthsensors are being updated every 15 minutes. I've disabled blynk and weatherstem as they weren't working anyway, so those haven't been tested.
During testing I simply renamed the existing wirelesssensor.py to wirelesssensorOld.py and renamed wirelesssensorsNew.py to wirelesssensors.py. I initially disabled the autoloading of SkyWeather2.py in /etc/rc.local and manually loaded it at the command line to check for syntax or other errors. But now I have reenabled the auotloading in /etc/rc.local and its working fine.
This would have been done sooner but I mistakenly started with an old or corrupted version of wirelesssensors.py and only by using the VS Code Compare feature with the 5/7/22 version of wirelesssensors.py and correcting discrepancies was I able to get it working. Also since I do my python work on my windows machine, MySQLdb is a problem in a windows environment so I did the initial testing in windows using mysql.connector, but have changed that over to MySQLdb in the attached. I tested the performance to a simulated reset zeroing cumulativerain using a jupyter notebook on the windows machine and it worked fine. I have not done a WR2 reset yet with this code running. I did however pour some water in the rain detector and it correctly captured that amount in the TotalRain and cumulative rain, updating the adjusttotalrain table in the process.
NOTE: I believe the user must have upgraded to the 5/7/22 release for this to work!
Let me know if you find anything that needs correcting or changing. I can eventually upload this to Github for the general user community. Creat_adjusttotalrain_table.sql (205 B) wirelessSensorsNew.py (30.45 KB)
I finished coding a new wirelessensorsNew.py which I am attaching for your review and comment. This uses a new SQL table SkyWeather2.adjusttotalrain to store cumulativerain and corrected TotalRain values. This table only updates when raining or after a WR2 reset. Also attaching the SQL for this new table. The first row in this table needs to be populated by the user based on their own corrected data for total rain and current cumulativerain data.
(I exported SkyWeather2.weatherdata to excel and did a whole slew of corrections to the bad data using excel, including correcting TotalRain. I then copied weatherdata to weatherdata_BU, then truncated the weatherdata table and reimported the fixed data as a csv file. This was all done using phpmyadmin.)
I've had this running now for over a day without any problems. weatherunderground and your dash app are working correctly and weatherdata and indoorthsensors are being updated every 15 minutes. I've disabled blynk and weatherstem as they weren't working anyway, so those haven't been tested.
During testing I simply renamed the existing wirelesssensor.py to wirelesssensorOld.py and renamed wirelesssensorsNew.py to wirelesssensors.py. I initially disabled the autoloading of SkyWeather2.py in /etc/rc.local and manually loaded it at the command line to check for syntax or other errors. But now I have reenabled the auotloading in /etc/rc.local and its working fine.
This would have been done sooner but I mistakenly started with an old or corrupted version of wirelesssensors.py and only by using the VS Code Compare feature with the 5/7/22 version of wirelesssensors.py and correcting discrepancies was I able to get it working. Also since I do my python work on my windows machine, MySQLdb is a problem in a windows environment so I did the initial testing in windows using mysql.connector, but have changed that over to MySQLdb in the attached. I tested the performance to a simulated reset zeroing cumulativerain using a jupyter notebook on the windows machine and it worked fine. I have not done a WR2 reset yet with this code running. I did however pour some water in the rain detector and it correctly captured that amount in the TotalRain and cumulative rain, updating the adjusttotalrain table in the process.
NOTE: I believe the user must have upgraded to the 5/7/22 release for this to work!
Let me know if you find anything that needs correcting or changing. I can eventually upload this to Github for the general user community. Creat_adjusttotalrain_table.sql (205 B) wirelessSensorsNew.py (30.45 KB)