Posts: 652
Threads: 18
Joined: Aug 2015
Reputation:
22
Greetings Gianluca,
This is a great suggestion. Can you provide some further information?
Some web links or especially some Python code wuld be helpful.
Dan
Posts: 2
Threads: 1
Joined: May 2021
Reputation:
0
Dan,
The weather_level_adj plugin already gathers the local sunrise time in the API response json as sys.sunrise.
Of course the use of sunrise time is advantageous in setting the irrigation start time as it allows the irrigation to be applied at the optimal time to avoid evaporation (before sunrise) and before need (after sunrise).
Ideally, the start time Add a New Program / Edit Program #X page(s) would have an associated check box adjacent to the start time field to allow the start time to be defined relative to the sunrise time instead of absolute local time.
The check box on the web page should only be available when the weather_level_adj (or standalone sunrise) plugin is enabled.
When that check box is selected, the start time should represent the start time relative to sunrise.
The relative start time should be able to be specified as positive or negative time (i.e., time before (negative values) or time after (positive values) sunrise).
The calculated start time should be reflected in the irrigation schedule on the home page.
The only algorithmic issue encountered with this method is calculation and display of scheduled start times in the future since the openweather API does not provide forecast date (including sunrise time) but only historical data. Scrolling though the irrigation schedule on the SIP home page for days after TODAY could use today's sunrise time as an approximation for the program start times for each day. Alternatively, instead of using the openweather API, the sunrise-sunset.org API allows specifying a future date.
I might try to prototype up a working model using either the proto or weather_level_adj plugin as a starting point.
I think the data gathering portion of code in the python module should be fairly strait forward. I'll have a little more effort on the integration with the existing Add a New Program / Edit Program #X side of the equation. I'll save the Home Page schedule display module modifications, if needed, for last.
Can you think of anything I need to be aware of in this attempt that I haven't outlined above?
Ronnie
Posts: 652
Threads: 18
Joined: Aug 2015
Reputation:
22
Here are some thoughts on a sunrise based plugin.
SIP includes the blinker module which broadcasts signals when certain events occur. One such signal is broadcast just past midnight, i.e. when a new day begins. That signal can be used by a plugin to calculate sunrise time for that day.
Irrigation program data is stored in SIP/data/programData.json and also kept in memory in the variable gv.pd. The data in memory is in a Python list of dictionaries.
The data for each irrigation program includes the following elements that would be useful for adjusting the program according to sunrise time:
start_min - The start time for the program in minutes past midnight
duration_secs - The amount if time in seconds the program is scheduled to run. When SIP is set for individual durations a list of durations, one for each station in the program, is included.
end_min - The time in minutes past midnight that the program run will be finished. This takes into account the duration or sum of durations in the case of individual durations.
If the goal is to have irrigation completed before sunrise, the end_min value and sunrise time (in minutes past midnight) could be used to calculate a time offset that could then be applied to the start_min value in gv.pd.
Adding a checkbox to the program page in SIP's UI would be problematic. It would require not only modifying the page but also how the newly added setting is handled when the program is saved.
It would be better to keep all plugin related settings on the plugin's setup page. The setup page could display a list of programs with a check box for each to enable sunrise time adjustments. This data could be stored in a file specific to that plugin.
When a new day begins the plugin could adjust the start times for the programs that have the adjustment option enabled.
As far as modifying the timeline display on the SIP home page goes, the display would automatically show the modified start time for the current day. If a user moves to a future date it would be difficult to have the sunrise time for the future date calculated without extensive modification to the JavaScript code. Also, when moving one or two days ahead the difference in sunrise time is only one minute per day or in some cases there is no difference. An hour on the timeline display is only about 30 pixels wide (Or less depending on the device it is being viewed on.) this means that a one minute difference in time would translate to 0.5px which would not make a noticeable difference on the display.
Dan
<p><br></p>