Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best method to postpone program
#1
Hi!

I have just installed SIP and sold the old Hunter controller. We live by a small river not far from the sea. Depending on the current in the river and the wind at sea we sometimes have fresh water and sometimes saltwater in the river. 

As our well for the irrigation is not giving enough water I decided to take water for the irrigation from the river. But using saltwater for irrigation is not good at all, don’t ask me how I know... Therefore I bought an electrical conductivity meter and I have written a plugin for SIP to check the salinity level of the water in the river. 

The plugin acts more or less as a rain sensor for now. It’s stops the running programs and reports rain sensed to the main SIP program. This is not optimal as what I really want to do is to postpone the program 24 hours and try to run the next night. Is there a way to do this? Optimally I would just let the programs to run every third night, postponing if salt is detected. 

My second question is about getting information about the next scheduled programs start time. To prolong the life of this expensive probe the plugin is only checking the salinity level 15 minutes before the program starts and goes to sleep when the program is finished. This is right now hard coded into the plugin, which is not a very elegant solution. Is there a way to get information about the start time of the next program before it starts? The sensor needs some time to calibrate itself before getting correct readings. Also I don’t want salt water in the system if possible.

Thank you for any input!
Reply
#2
Hi Johan,

You have a very interesting situation. First off, congratulations on writing a plugin!

There is a file in the SIP folder named gv_reference.txt which lists the variables SIP uses with a brief description of each.

You can set a 24 hr delay for programs by setting the gv.sd[u"rd"] variable (rain delay) to 24.

As far as getting the start time for the next program, there are a couple of things to check:
SIP stores the irrigation schedules in the file SIP/data/programData.json. That may be a good place to start. The start times are in minutes past midnight. You can calculate minutes past midnight with for example:


Code:
time_now = time.localtime()
min_past_midnight = (time_now.tm_hour * 60) + time_now.tm_min


When SIP starts, it loads the programData file into the variable gv.pd.

When a program is scheduled to run the start time is stored in the variable gv.rs

I hope this is helpful.
Let me know if you have further questions. I really enjoy helping out with unique applications like yours.

Dan
<p><br></p>
Reply
#3
I forgot to mention that the blinker module included with SIP broadcasts a signal when a program is scheduled.
That signal can be used to run a function in a plugin. See the signaling_examples.py file in the plugins folder.

I have not tested this idea but you may be able to use the stations_scheduled signal to run a function that would add to the start and stop times in  gv.rs to delay the program long enough to run your conductivity measurement.
<p><br></p>
Reply
#4
(2020 Jun 05, 03:05 PM)dan Wrote: I forgot to mention that the blinker module included with SIP broadcasts a signal when a program is scheduled.
That signal can be used to run a function in a plugin. See the signaling_examples.py file in the plugins folder.

I have not tested this idea but you may be able to use the stations_scheduled signal to run a function that would add to the start and stop times in  gv.rs to delay the program long enough to run your conductivity measurement.

Hi Dan,

Thank you for your suggestions. The problem with the rain delay is that the programs scheduled to run during the rain delay are being cancelled during the rain delay and then they will run at next scheduled start time. Am I right? I just want the program to run the next night instead. 

An alternative for me would be to schedule the program every night. If there is salt in the water I will just add a rain delay of a couple of hours. Then the program will be run the next night if possible. Upon a successful program run I can add a rain delay of say 68 hours. Then there will be no program run the next two nights. 

Johan
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)