OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) rain sensor signaling

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38091

    seanmjones
    Participant

    I don’t yet have a rain sensor, so I am trying to feel this out by digging through the code…

    I would like to send a signal when the rain sensor detects rain. Am I correct that this doesn’t exist in the code as of 5/6/15 19:00? (SHA 293ac17f39c789b778f12e85bbe5e7a26646f31e)

    Do I just need to:
    rain_sense = signal(‘rain_sense’)
    in helpers.py;

    then in helpers.check_rain() do:
    rain_sense.send()
    when setting gv.sd[‘rs’] = 1?

    Does that make sense? Is it that simple or am I missing something?

    Thanks,
    Sean

    #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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) rain sensor signaling