From 8d5a08a929f13711b9db6d52db06682a1ff27c6d Mon Sep 17 00:00:00 2001 From: deepcore2 Date: Sun, 10 Feb 2019 11:39:20 +0100 Subject: [PATCH] Add daily maintenance at midnight For now just to reset the daily rainfall count. More may follow. --- GroveWeatherPi.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/GroveWeatherPi.py b/GroveWeatherPi.py index 4704a1a..fd6b520 100644 --- a/GroveWeatherPi.py +++ b/GroveWeatherPi.py @@ -1805,6 +1805,21 @@ def checkForButtons(): while True: + # Check for new day to do some daily maintanance. + # For now, just reset the daily rainfall count. More might come... + today = datetime.now().day + if 'yesterday' in locals(): # Not the first run + if today != yesterday: # A new day has begun + # Reset daily rain count + print "Reset rain count" + totalRain = 0 + yesterday = today + else: # First run, define yesterday + print "First run, define yesterday/initialize variables..." + yesterday = today + totalRain = 0 + # New day can start... + # process Interrupts from Lightning if (as3935Interrupt == True):