pierus
New Member
Posts: 4
Raspberry Pi: Yes
|
Post by pierus on Sept 1, 2020 14:30:38 GMT -8
I posted several times asking if the rain fall value reseting to zero had been fixed or if there was a known work around. After not getting any response I decided to get it fixed myself. SkyWeather.txt (60.01 KB) Rename the attached file to SkyWeather.py and put in the correct directory on your Pi (Backup the current file). This version will keep the rainfall values across reboots and SkyWeather script restarts. Restarting SkyWeather at exactly one minute after midnight on the 1st day of the month will reset the rainfall value to zero. I am currently doing this via a crontab job. Works great. You can also reset the value of rainfall to zero by removing a file called total_rain.npy Hopefully others will find this useful. Maybe the powers that be will incorporate this or something like it into the next release.
|
|
|
Post by SDL on Sept 2, 2020 14:26:15 GMT -8
Thank you! We are putting this in our new release (which will be in Python3).
BP
|
|
smurphy
Full Member
Posts: 169
Raspberry Pi: Yes
Other Device: many ...
|
Post by smurphy on Sept 2, 2020 23:16:32 GMT -8
When will he new python 3 release be available?
|
|
smurphy
Full Member
Posts: 169
Raspberry Pi: Yes
Other Device: many ...
|
Post by smurphy on Sept 3, 2020 6:08:05 GMT -8
Just looked through the code and methods in extracting data from everywhere. Maybe we should open a new thread for that. But for the next release at least, this could be very nice to have. IMHO - we should rework the way we store the data to disk in a state file.
2 Things I noticed: 1. The change time of the file is not updated. means, we can't check with a simple script if we should reread the file for new content or not. We have to actually read it all and compare to the backup file. 2. We have no indication as to when the data was extracted (Written into the file). There os no timestamp in it.
What should be done is as follows: If there will be no update of the file time change, at least implant a current timestamp (can also be an epoch tag - seconds since 1.1.1970). We could append the epoch to each entry. Making it kind of a csv type file. ` 0.0;1599141749 0;1599141749 0;1599141750 0;1599141750 ;1599141750 0.0;1599141755 0.000349245965562;1599141755 0.0;1599141756 26.41;1599141757 93.81;1599141757 645.332015672;1599141758 93.822;1599141759 23.1000003815;1599141760 26.2000007629;1599141760 270.0;1599141761 4.4454375;1599141761 25.3;1599141762 23.7;1599141762 `
Then of course, we could also have the option to have that data formatted in json or so.
That would make post-processing way easier. Especially, of the data is already there, we can of course add some other entries like the currently use Unit, and entry name etc.
I for example, extract the data, put it into a MySQL DB for analysis, then dump it again. But I'm never sure from what time exactly the data is.
|
|
|
Post by SDL on Sept 3, 2020 12:35:41 GMT -8
The Python3 version should be available this fall. We are still trying to work it into our schedules. We may just do another python 2.7 release.
BP
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Oct 29, 2020 23:59:07 GMT -8
There is an error in your script replacement - but only noticeable if you are logging to a database.
The Line that does the insert was changed to include the value od totalRain[-1] - MarioDb complains with these types of tables that have [-1] - it was probably done through a global search and replace and never noticed until someone like me came along to test your code and found the fault because I log to a db.
The line was easily changed in removing totalRain[-1] to totalRain as per here...
query = 'INSERT INTO WeatherData(TimeStamp,as3935LightningCount, as3935LastInterrupt, as3935LastDistance, as3935LastStatus, currentWindSpeed, currentWindGust, totalRain, bmp180Temperature, bmp180Pressure, bmp180Altitude, bmp180SeaLevel, outsideTemperature, outsideHumidity, currentWindDirection, currentWindDirectionVoltage, insideTemperature, insideHumidity, AQI) VALUES(UTC_TIMESTAMP(), %.3f, %.3f, %.3f, "%s", %.3f, %.3f, %.3f, %i, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f)' % (as3935LightningCount, as3935LastInterrupt, as3935LastDistance, as3935LastStatus, state.ScurrentWindSpeed, state.ScurrentWindGust, state.currentTotalRain, state.currentInsideTemperature, state.currentBarometricPressure, state.currentAltitude, state.currentSeaLevel, state.currentOutsideTemperature, state.currentOutsideHumidity, state.ScurrentWindDirection, currentWindDirectionVoltage, state.currentInsideTemperature, state.currentInsideHumidity, state.Outdoor_AirQuality_Sensor_Value)
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Oct 30, 2020 15:36:40 GMT -8
What is the expectation of rain total - total rain for the day, or total rain forever.
After applying this fix, and running overnight I was suprised to see weatherunderground actually reporting no rain overnight, but the total was still showing everything from the previous day.
Yes I tested the above code - that it preserved rain totals from a reboot - great.. but there seems to be an issue that it does not reset back to 0 for the next day. It might be a timing issue of UTC, and I will see it reset later today, or maybe I missed a bit of code to see it go back to 0 at the new day....
Some more debugging to do....
|
|
smurphy
Full Member
Posts: 169
Raspberry Pi: Yes
Other Device: many ...
|
Post by smurphy on Oct 31, 2020 4:45:12 GMT -8
Confirm to have noticed that too. The Rain stays for a long time. It is never reset to 0.
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Oct 31, 2020 5:18:02 GMT -8
Yup - going to revert back... Not sure why it was complicated with NP and arrays.. I think I can see where the code needs to reset to 0 - but think its all overkill maybe.... Gotta play some first
I looked at the code and arrays - there appears to be an array for TotalRain adn Total_Rain - so not sure why or what yet, but its all confusing... The routine that checks at midnight to reset things I would have thought needed to reset things back to 0 - but its using the previous array... hmmm...
I have reverted back, and going to play now !
I have also noticed that the Lightning Count does not reset itself either... So I had lightning 2 days ago, and the count is still saying 1 - I would have thought the lightning count would also reset daily - or I start to wonder if it ever needs to increment. Guess the count is useful to show the number of strikes - but as its an interrupt thought it would interrupt on each count.
I intend to reset this daily as well.
I will try and get this working the way I think it should, and include the option of the time to reset. Most meteorological places I know - reset daily stats at 9am... Historical reasons... but for me I like the simplicity of midnight...
|
|
impactoz
Full Member
Posts: 142
Raspberry Pi: Yes
|
Post by impactoz on Nov 1, 2020 4:27:03 GMT -8
|
|