OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) rain sensor signaling Reply To: rain sensor signaling

#38096

Dan in CA
Participant

Hi Sean,

You are correct that this signal does not presently exist. It would be useful so I plan to added it.

To make it work you would add something like:

from blinker import signal

rain_sensed = signal('rain')
def signal_rain():
    rain_sensed.send()

near the start of helpers.py (just before the function definitions section).
you could then add the signal_rain() function when setting gv.sg[‘rn’]= 1 as you said but when I tested this it sent the signal once per second.
Adding

if not gv.sd['rs']:
    signal_rain()

will only send one signal when rain is detected.

To use the signal you will also need to have something like:

def do_on_rain(name, **kw):
    print "Rain Sensed"
    #  rain is detected in helpers.py
    # Put your code here to do whatever you want. 
    
rain_sensed = signal('rain')
rain_sensed.connect(do_on_rain) 

Those last 2 lines will trigger your “do_on_rain()” function when the signal is received.

Dan