Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check the status of a cistern when SIP zone is active
#1
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
Reply
#2
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?
Reply
#3
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!
Reply
#4
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
Reply
#5
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
Reply
#6
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
#  This example plugin runs a loop function while any station is on.

from blinker import signal
import gv
from time import sleep
import thread

running = False

def loop():
   global running
   while running:
       print "station running"
       print gv.srvals
       sleep(1)

### any station on ###
def check_running(name, **kw):
   global running
   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.
   if running:
       thread.start_new_thread(loop, ())

zones = signal('zone_change')
zones.connect(check_running)

if __name__ == '__main__':
   pass
Reply
#7
Thanks for the example Dan. It worked perfectly for me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)