Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using moisture sensors to control programs
#11
Okay thanks, I'll look into it and do some minimal validation to avoid having to look at the logs too often.

I was thinking about the moisture control plugin and realised that it currently only does half the job i.e. suppressing schedules if the station is too wet. 

I was wondering if I could cover the other case as well, "what if the station is too dry?".

For each station I would add an additional two attributes, a too dry threshold and a program. If the current moisture reading for a station is below the too dry threshold then the program would be triggered. I looked at helpers.run_program but that calls stop_stations, not exactly what I want and also a program could cover more than one station so I'm guess using programs is not the way to go.

Instead of a program attribute I would use MM:SS and trigger the station to run once for this. Would this be a sensible way to go and would the node_red.run_once be the correct code to do this? Can I add from node_red import run_once in my plugin?
Reply
#12
(2024 Jan 20, 10:15 PM)cdesouza Wrote: Instead of a program attribute I would use MM:SS and trigger the station to run once for this. Would this be a sensible way to go and would the node_red.run_once be the correct code to do this? Can I add from node_red import run_once in my plugin?
Because node_red is a plugin it is not guaranteed to exist on all SIP installations. It would probably be best to copy the code in to your program.

Dan
<p><br></p>
Reply
#13
I have been working with these moisture sensors for about 2 years:
https://www.irrometer.com/sensors.html#wm

The strategy I have been using is to check the moisture in a zone every 15 minutes and when the moisture level drops below a set point (depending on the crop) irrigation is started for a brief period.

I am using drip irrigation for vegetables and this may not be the best for lawns with sprinkler irrigation.

Dan
<p><br></p>
Reply
#14
(2024 Jan 21, 04:17 PM)dan Wrote:
(2024 Jan 20, 10:15 PM)cdesouza Wrote: Instead of a program attribute I would use MM:SS and trigger the station to run once for this. Would this be a sensible way to go and would the node_red.run_once be the correct code to do this? Can I add from node_red import run_once in my plugin?
Because node_red is a plugin it is not guaranteed to exist on all SIP installations. It would probably be best to copy the code in to your program.

Dan

I found two implementations of Run Once, one in the node_red plugin and the other in webpages.py. They are slightly different. If I copy the cope I would be creating a third one. 

Would it not be better to consolidate the code in a helper function?
Reply
#15
(2024 Jan 22, 06:32 AM)cdesouza Wrote:
(2024 Jan 21, 04:17 PM)dan Wrote:
(2024 Jan 20, 10:15 PM)cdesouza Wrote: Instead of a program attribute I would use MM:SS and trigger the station to run once for this. Would this be a sensible way to go and would the node_red.run_once be the correct code to do this? Can I add from node_red import run_once in my plugin?
Because node_red is a plugin it is not guaranteed to exist on all SIP installations. It would probably be best to copy the code in to your program.

Dan

I found two implementations of Run Once, one in the node_red plugin and the other in webpages.py. They are slightly different. If I copy the cope I would be creating a third one. 

Would it not be better to consolidate the code in a helper function?
Agreed.
I will work on it.
<p><br></p>
Reply
#16
That would be great as it is the last piece of code missing for my moisture sensor plugins.

Let me know if you need help with testing.
Reply
#17
Help with testing would be appreciated.

I added a new branch named run-once.
It has the run_once() code moved from webpages.py to helpers.py.
You should be able to just run
Code:
git checkout run-once
on the command line to get the new code.

There is also a new feature in helpers.stop_stations that logs stations that have been stopped early. That allowed the simplification of the run_once code.

The run_once code in the node-red program has quite a few differences an has been renamed to nr_run_once.
I am still working on refactoring the node-red code to use the helpers code.
<p><br></p>
Reply
#18
Thanks you for the quick turnaround, I'll take a look over the weekend.
Reply
#19
I'm currently a bit confused about the number of stations and boards.

There are two variables 
  • gv.nbrd =number of board 
  • gv.nst =  number of stations 

and there are various variables where the length is the number of stations.
 
There is also code such as the following (from the proto plugin)
Code:
          $for bid in range(0,gv.sd['nbrd']):
            $for s in range(0,8):
              $ sid = (bid * 8) + s;
              $ s_sid = str(sid);

There are also boards with 1, 2 4, 8 and 16 channels.

As far as I can tell the above code will only work for a multiple of boards with 8 channels.

Will, for example, the length of gv.rs give me the number of stations  regardless of the number and type of boards?
  • 8 channel board = 8 stations
  • 2 channel board = 2 stations
  • 8 channel board + 2 channel board = 10 stations
Reply
#20
*** Edit *** - I ran more tests on the run-once branch and this time also checked the logs. 

Compared to the tests I ran on the main branch (see (much) further down) it looks like you have fixed some bugs along the way and the home page now exhibits what I believe to be the  correct behavior. There are however still missing entries on the log page.

Version: 2024-01-24 / git status: Your branch is up to date with 'origin/run-once'
Run Once / Concurrent Mode / Run once
1) Trigger one station 1min  - Runs for 1 mins. - Log entry for 1 min
2) Trigger two stations, each 1 min - Both run concurrently for 1 min - Log for each station for 1 min
3) Trigger one station 1 min, trigger same station before end for 1 min - Station timer reset to 1 min and runs for 1 min - Missing log for first trigger, log for second trigger
4) Trigger two stations 1 mins, trigger first station before end for 1 min – Second station continues to run for 1 min, first station timer reset to 1 min - Missing log entry for first trigger on first station. Log entry for second trigger on first station and trigger on second station.
5) Trigger one station 1 mins, trigger second station before end for 1 min - First station continues to run for 1 min,  second station runs for 1 mins - Log entries for each station for 1 min
6) Trigger two stations 1 mins, trigger third station before end for 1 min- First two stations each continue to run for 1 min, third station runs for 1 min - Log entries for each station for 1 min

7) Trigger one station 1 min, trigger same station after 10 secs for 30 secs - Station timer reset to 30 secs and runs for 30 secs - Missing log for first trigger, log for second trigger
8) Trigger two stations 1 min, trigger first station after 10 secs for 30 secs – Second station continues to run for 1 min, first station timer reset to 30 secs - Missing log entry for first trigger on first station. Log entry for seconds trigger on first station and trigger on second station.
9) Trigger one station 1 mins, trigger second station after 10 secs for 30 secs - First station continues to run for 1 min,  second station runs for 30 secs - Log entries for first and second station
10) Trigger two stations 1 mins, trigger third station after 10 secs for 30 secs- First two stations each continue to run for 1 min, third station runs for 30 secs - Log entries for each station

11) Run 1 min program on station , trigger run once on same station before end for 1 min. Station timer reset to 1 min and runs for 1 min. Missing log for first trigger, log to second trigger
12) Run 1 min program on two stations, trigger run once on first station before end for 1 min – Second station continues to run for 1 min, first station timer reset to 1 min - Missing log entry for first trigger on first station. Log entry for second trigger on first station and trigger on second station.
13) Run 1 min program on station, trigger run once on second station before end for 1 min - First station continues to run for 1 min,  second station runs for 1 mins - Log entries for each station for 1 min
14) Run 1 min program on two stations, trigger once third station before end for 1 min- First two stations each continue to run for 1 min, third station runs for 1 min - Log entries for each station for 1 min
15) Run 1 min program on one station, trigger run once on same station after 10 secs for 30 secs - Station timer reset to 30 secs and runs for 30 secs - Missing log for first trigger, log for second trigger
16) Run 1 min program on two stations, trigger run once on first station after 10 secs for 30 secs – Second station continues to run for 1 min, first station timer reset to 30 secs - Missing log entry for first trigger on first station. Log entry for seconds trigger on first station and trigger on second station.
17) Run 1 min program on one station, trigger second station after 10 secs for 30 secs - First station continues to run for 1 min,  second station runs for 30 secs - Log entries for first and second station
18) Run 1 min program on two stations, trigger run once on third station after 10 secs for 30 secs- First two stations each continue to run for 1 min, third station runs for 30 secs - Log entries for each station


Run Once / Sequential Mode / Run once
1) Trigger one station 1min  - Runs for 1 mins. - Log entry for 1 min
2) Trigger two stations, each 1 min - Stations run sequentially each for 1 min - Log for each station for 1 min
3) Trigger one station 1 min, trigger same station before end for 1 min - Station timer reset to 1 min and runs for 1 min - Log entry for first trigger for partial run, log entry for second trigger for 1 min
4) Trigger two stations 1 mins, trigger first station before end for 1 min – Second station is cancelled, first station timer reset to 1 min - Missing log entry for second station, log entry for first trigger on first station for partial run, log entry for second trigger on first station for 1 min.
5) Trigger one station 1 mins, trigger second station before end for 1 min - First station is cancelled,  second station runs for 1 mins - Log entries for each station
6) Trigger two stations 1 mins, trigger third station before end for 1 min- First two stations are cancelled, third station runs for 1 min - Log entries for first station and third station

7) Trigger one station 1 min, trigger same station after 10 secs for 30 secs - Station timer reset to 30 secs and runs for 30 secs - Log entry for first and second trigger
8) Trigger two stations 30 secs, trigger first station after 10 secs for 30 secs – Second station is csancelled, first station timer reset to 30 secs - Log entry for first station partial run trigger and second trigger.
9) Trigger one station 1 mins, trigger second station after 10 secs for 30 secs - First station is cancelled,  second station runs for 30 secs - Log entries for first station partial run and second station
10) Trigger two stations 1 mins, trigger third station after 10 secs for 30 secs- First two stations are cancelled, third station runs for 30 secs - Log entry for first station partial run, log entry for third station 



Version: 2024-01-18 / Main branch
Run Once / Concurrent Mode
1) Run once for one station 4mins  - Runs for 4 mins
2) Run once for two stations, each 4 mins - Both run concurrently for 4 mins
3) Run once for one station 4 mins, another run once on same station before end - Station overridden by second run once
4) Run once for two stations 4 mins, another run once on first station before end - Both stations set to OFF
5) Run once for one station 4 mins, another run once on second station before end - First station cancelled, second station runs for 4 mins
6) Run once for two stations 4 mins, another run once on third station before end - First two stations cancelled, thirst stations runs for 4 mins
Run Once / Sequential Mode
1) Run once for one station 4mins  - Runs for 4 mins
2) Run once for two stations, each 4 mins - Stations run sequentially, each  for 4 mins
3) Run once for one station 4 mins, another run once on same station before end - Station overridden by second run once
4) Run once for two stations 4 mins, another run once on first station before end - First station overridden by second run once, second station cancelled
5) Run once for one station 4 mins, another run once on second station before end - First station cancelled, second station runs for 4 mins
6) Run once for two stations 4 mins, another run once on third station before end - First two stations cancelled, thirst stations runs for 4 mins
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)