Check the status of a cistern when SIP zone is active - Printable Version +- SIP (https://nosack.com/sipforum) +-- Forum: SIP (Sustainable Irrigation Platform) (https://nosack.com/sipforum/forumdisplay.php?fid=1) +--- Forum: Writing plugins (https://nosack.com/sipforum/forumdisplay.php?fid=8) +--- Thread: Check the status of a cistern when SIP zone is active (/showthread.php?tid=37) |
Check the status of a cistern when SIP zone is active - tfcb - 2016 May 13 Hi, My sprinkler system uses both cistern and city water. I'd like to use the cistern water until empty and then switch to city water. If the system is running I need to check once per minute to see if the cistern still has water (I already have a way to test this) and turn on the city water if not. I'd also like to ensure that the city water value is closed and cistern pump off if the system isn't running. What are your thoughts on the best way to implement? Thanks, Tim RE: Check the status of a cistern when SIP zone is active - dan - 2016 May 13 An interesting situation. Could you provide a bit more information about your system such as the type of sensor you use to check the cistern level (switch or continuous levell sensor). Do you have a sensor of some sort on the city water side such as a pressure sensor? How many stations are you running? SIP has a signaling system that can be used to run code when a station is on. See the signaling_examples.py file in the plugins directory. Are you familiar with Python programming? RE: Check the status of a cistern when SIP zone is active - tfcb - 2016 May 13 Thanks Dan. > Could you provide a bit more information about your system such as the type of sensor you use to check the cistern level (switch or continuous levell sensor). In the cistern I have a number of float switches. I have a simple REST interface to request the current water level (and in this case I only care about "empty"). >Do you have a sensor of some sort on the city water side such as a pressure sensor? On the city side I have a valve and and a flow sensor. Again, simple REST interface to check the status of the valve and water flow. > How many stations are you running? I am running 15 stations. >SIP has a signaling system that can be used to run code when a station is on. Yes, I've seen the signals in the sample plugins and when running sip.py manually. I see the plugins with a "while True" loop/sleep. Is that a reasonable way to implement? I'm just a bit confused about having my loop only run if a zone is active. I am familiar with Python though not a sw developer by any stretch. THANKS! RE: Check the status of a cistern when SIP zone is active - dan - 2016 May 14 So does your REST code allow to control things or just report status? Just off the top of my head: Using the signaling in SIP you could do something like: def notify_zone_change(name, **kw): running = any(gv.srvals) # gv.srvals shows the state of the zones as a list with 1's for zones that are on an 0's for ones that are off. loop() def loop(): global running while running: your loop code RE: Check the status of a cistern when SIP zone is active - tfcb - 2016 May 15 Thanks Dan. Due to interactions with other systems I've decided to solve this outside of SIP. I am still a bit confused about loop(). In your sketch I didn't have much luck with interaction between notify_zone_change and loop. Even when the zones were all off running appeared to remain true. Best, Tim RE: Check the status of a cistern when SIP zone is active - dan - 2016 May 15 OK cool. Just for the record, here is a tested example plugin that runs a loop while any station is on: Code: # !/usr/bin/env python RE: Check the status of a cistern when SIP zone is active - tfcb - 2016 May 15 Thanks for the example Dan. It worked perfectly for me. |