Skip to content

Commit

Permalink
Merge pull request #25 from Drealine/development
Browse files Browse the repository at this point in the history
2020.12-1
  • Loading branch information
Drealine committed Dec 28, 2020
2 parents b406475 + 4dc95f0 commit 650411b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 159 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.idea/modules.xml
.idea/weatherlinklive-driver-weewx.iml
.idea/workspace.xml
docs/_config.yml
docs/index.md
60 changes: 30 additions & 30 deletions bin/user/WLLDriver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3

DRIVER_NAME = "WLLDriver"
DRIVER_VERSION = "0.3a"
DRIVER_VERSION = "2020.12-1"

import json
import requests
Expand Down Expand Up @@ -317,13 +317,6 @@ def calculate_rain(self, dt_wll, rainFall_Daily, rainRate, rainSize):
rain = None
rain_multiplier = None

# Reset previous rain at midnight
if dt_wll is not None and self.last_midnight < dt_wll:
loginf('Reset rainfall_Daily at midnight')
self.rain_previous_period = 0
self.last_midnight = self.get_last_midnight(int(dt_wll))
logdbg("Last midnight set is : {}".format(self.last_midnight))

# Check bucket size
if rainSize is not None:
if rainSize == 1:
Expand All @@ -333,24 +326,36 @@ def calculate_rain(self, dt_wll, rainFall_Daily, rainRate, rainSize):
if rainSize == 3:
rain_multiplier = 0.1

# Calculate rain
if rainFall_Daily is not None and rain_multiplier is not None:
if self.rain_previous_period is not None:
if (rainFall_Daily - self.rain_previous_period) < 0:
logerr("rain can't be a negative number. Skip this and set rain to 0")
rain = 0
else:
rain = (rainFall_Daily - self.rain_previous_period) * rain_multiplier

if rain is not None and rainSize is not None and rain > 0:
logdbg("Rain now : {}".format(rain))

if rainSize == 2:
rain = rain / 25.4
if rainSize == 3:
rain = rain / 2.54
# Reset previous rain at midnight
if dt_wll is not None and self.last_midnight < dt_wll:
loginf('Reset rainfall_Daily at midnight. Skip rainfall_daily calculate to prevent overflow value')
self.rain_previous_period = 0
self.last_midnight = self.get_last_midnight(int(dt_wll))
logdbg("Last midnight set is : {}".format(self.last_midnight))
else:
rain = None
# Calculate rain
if rainFall_Daily is not None and rain_multiplier is not None:
if self.rain_previous_period is not None:
if (rainFall_Daily - self.rain_previous_period) < 0:
logerr("rain can't be a negative number. Skip this and set rain to 0")
rain = 0
else:
rain = (rainFall_Daily - self.rain_previous_period) * rain_multiplier

if rain is not None and rainSize is not None and rain > 0:
logdbg("Rain now : {}".format(rain))

if rainSize == 2:
rain = rain / 25.4
if rainSize == 3:
rain = rain / 2.54
else:
rain = None

# Set rainFall_Daily to previous rain
if rainFall_Daily is not None and rainFall_Daily >= 0:
self.rain_previous_period = rainFall_Daily
logdbg("Rainfall_Daily set after calculated : {}".format(self.rain_previous_period))

# Calculate rainRate
if rainRate is not None and rain_multiplier is not None:
Expand All @@ -365,11 +370,6 @@ def calculate_rain(self, dt_wll, rainFall_Daily, rainRate, rainSize):
else:
rainRate = None

# Set rainFall_Daily to previous rain
if rainFall_Daily is not None and rainFall_Daily >= 0:
self.rain_previous_period = rainFall_Daily
logdbg("Rainfall_Daily set after calculated : {}".format(self.rain_previous_period))

return rain, rainRate

# ------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion docs/_config.yml

This file was deleted.

128 changes: 0 additions & 128 deletions docs/index.md

This file was deleted.

0 comments on commit 650411b

Please sign in to comment.