Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues with Weather-Based Water Level
#1
Went ahead and updated to v 4 and have issues with the weather based water level plugin.  Went ahead and chose US units and got the following error in syslog

Jan 19 14:33:42 piutility sip[13625]: b'Weather-based water level encountered error:\nTraceback (most recent call last):\n  File "/home/pi/SIP/plugins/weather_level_adj.py", line 156, in run\n    int(options[u"daily_irrigation"])\nValueError: invalid literal for int() with base 10: \'0.0\'\n

Seems to be an error in the code... The line is calling out int instead of float.

I updated the code to process the value as a float and now the error is cleared.  However issues abound.. Wink

I went ahead to update the Daily Irrigation value and it will not take a non-integer value and record it to the weather_level_adj.json.  It will record if I set it as an integer value (e.g. 1) however when I go back into the settings it does not pick the value back up in the program plugin page.  Also, the data shown seems to be a little odd with water needed shown at -1.

I'll see if I can try and figure out the rest of the issues but figured I'd post it here in case anyone else is experiencing similar issues.
Reply
#2
I see the same things. Thanks for posting.

The fix for the daily use value not showing properly is to change line 7 of weather_level_adj.html from

Code:
rainPerDay = round(float(m_vals["daily_irrigation"]) / 25.4, 1)
 to

Code:
rainPerDay = round(float(m_vals["daily_irrigation"]), 1)
or even to:
Code:
rainPerDay = m_vals["daily_irrigation"]


It is re-converting the value to inches (from inches)

Edit:
Also change lin 195 in weather_level_adj.py
to:
Code:
safe_float(options[u"daily_irrigation"]), u"in"
removing the "to_in" function call.

Dan
<p><br></p>
Reply
#3
(2020 Jan 20, 12:16 AM)dan,Thanks for the help.  I still don\t think things are all fixed though...Current temperature: Wrote: 33.9deg.F

________________________________

Daily irrigation:

0.1in

Total rainfall:

0.0in

Water needed(6days):

-1.0in

________________________________

Irrigation needed:

0.0in

Weather Adjustment:
0.0%

We've had rain recently... Not sure why Water needed would be -1 in either.  Maybe it's fine but something seems a little fishy.

Dan
------------------------------------------------------------------------------------------------------------------------------------------
danI see the same things. Thanks for posting.

The fix for the daily use value not showing properly is to change line 7 of weather_level_adj.html from

Code:
rainPerDay = round(float(m_vals["daily_irrigation"]) / 25.4, 1)
 to

Code:
rainPerDay = round(float(m_vals["daily_irrigation"]), 1)
or even to:
Code:
rainPerDay = m_vals["daily_irrigation"]


It is re-converting the value to inches (from inches)

Edit:
Also change lin 195 in weather_level_adj.py
to:
Code:
safe_float(options[u"daily_irrigation"]), u"in"
removing the "to_in" function call.

Dan
Reply
#4
I am rethinking the fixes.

The code is designed for the values to be in SI (metric) units internally and when US units are selected to convert just before they are displayed.

I will do some work on this and get back to you as soon as there is a better solution.

Dan
<p><br></p>
Reply
#5
(2020 Jan 21, 03:39 PM)dan,I didn\t really see that...  To me it appeared as though things didn't quite line up like that.  What you describe seems like a perfectly logical way to do it.  This however would require the settings to be written as SI units... Pretty much the only difference in the config saved would be the SI/US preference.  The page load would look at the config SI/US flag and then either directly put the data or convert it based on the flag.  Vice Versa when saving changes.Changing the preference would force a refresh of the page - go ahead and flush any changes... just reload the valuesDan dan Wrote: I am rethinking the fixes.

The code is designed for the values to be in SI (metric) units internally and when US units are selected to convert just before they are displayed.

I will do some work on this and get back to you as soon as there is a better solution.

Dan
Reply
#6
So I did a little bit more digging and testing.  At least a portion of the problem is that the daily irrigation value does not get converted back to mm before it gets saved to the json whereas the temperature cutoff does get converted back to degC before being saved to the json file.

Not sure why the daily irrigation value isn't being converted to mm before saving as it looks like it should do it in the code...  Confused
Reply
#7
(2020 Jan 23, 05:20 AM)danny_aka_rudy Wrote: So I did a little bit more digging and testing.  At least a portion of the problem is that the daily irrigation value does not get converted back to mm before it gets saved to the json whereas the temperature cutoff does get converted back to degC before being saved to the json file.

Not sure why the daily irrigation value isn't being converted to mm before saving as it looks like it should do it in the code...  Confused

Well.. after closer testing and a good nights sleep it looks like it is being converted correctly to the json file.  Huh

It is however still not displaying correctly in the status section for anything but temp though.  This is kickin my bum.  looks like it should work
Reply
#8
Try changing line ~397 from len_in = round(safe_float(len_mm) // 25.4, 1) to
Code:
len_in = round(safe_float(len_mm) / 25.4, 1)
The "//" division is returning an int. The "/" division returns a float ("true division")

Note: this is only true under Python3.

Edit:
another way to fix this is to use multiplication:

Code:
len_in = round(safe_float(len_mm) * 0.03937, 1)
1 / 25.4 = 0.03937 This will work under both Python 2 & 3.

Dan
<p><br></p>
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)