Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2020.12-1 #25

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.