Forum Replies Created

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts

  • dennyfmn
    Participant

    Great! Glad that did the trick!


    dennyfmn
    Participant

    Hi Pierantonio,

    If the readpins.py script correctly reports the state of the door, that verifes that the hardware is hooked up correctly, good!

    After this article was written Dan changed the setmode for the GPIO

    From:
    GPIO.setmode(GPIO.BCM)
    To:
    GPIO.setmode(GPIO.BOARD)

    This has the effect of changing the pin number you need to define in ospi.py.

    Pin 24 in GPIO.setmode(GPIO.BCM) becomes
    Pin 18 in GPIO.setmode(GPIO.BOARD)

    The readpins.py script explicity defines Pin 24 for doorsense in GPIO.setmode(GPIO.BCM), so if that’s the pin you used, it will report correctly.

    Check the setmode command used in the version of ospi.py that you are running. If it is GPIO.BOARD, change the pin definition from 24 to 18.

    Sounds like you are very close. I hope this helps…

    Denny

    in reply to: Get and Display Rain Sensor #25404

    dennyfmn
    Participant

    It’s been several weeks that the rain sensor and code have been in place, and we have had rain on and off, so I thought I would follow up with some data on the Toro wireless rain sensor. The unit seems to be quite reliable. I’m running a cron job every minute on the OSPi machine and logging to a remote system.

    zcat -f `ls -1tr /var/log/ospi*` | grep -i raining
    Sep 16 14:53:02 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Sep 19 11:19:01 ospi GarageDoorRainMonitor.py: Rain state is now Raining
    Sep 20 16:55:01 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Sep 20 16:56:02 ospi GarageDoorRainMonitor.py: Rain state is now Raining
    Sep 20 17:19:02 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Sep 28 12:56:02 ospi GarageDoorRainMonitor.py: Rain state is now Raining
    Sep 29 11:06:02 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Oct 2 22:04:01 ospi GarageDoorRainMonitor.py: Rain state is now Raining
    Oct 8 00:57:02 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Oct 14 22:42:01 ospi GarageDoorRainMonitor.py: Rain state is now Raining
    Oct 17 15:17:02 ospi GarageDoorRainMonitor.py: Rain state is now NotRaining
    Oct 18 03:23:01 ospi GarageDoorRainMonitor.py: Rain state is now Raining

    As you can see the sensor goes on and off, and it’s raining now. I have the unit set at 1/4″ so it’s pretty sensitive.

    For reference, this is the one I’m using.

    http://www.amazon.com/gp/product/B000FBOQ7M/ref=wms_ohs_product?ie=UTF8&psc=1
    Toro 53770 Sprinkler System Timer Wireless Rain Sensor

    in reply to: Python Interval Program update Oct. 4 2013 #25635

    dennyfmn
    Participant

    Hi Dan,

    Yes options.txt looks just like you posted above.

    My sd.json looks like this:


    {"en": 1, "seq": 1, "mnp": 32, "ir": [48], "mas": 0, "htp": 8080, "nst": 8, "rdst": 0, "loc": "Burnsville, MN", "nprogs": 12, "tz": 28, "rs": 0, "tu": "F", "rd": 0, "mton": 0, "lr": "100", "sdt": 0, "rsn": 0, "bsy": 0, "lg": "checked", "wl": 100, "nopts": 13, "pwd": "xxxxxxxxxxx", "urs": 1, "rst": 1, "mm": 0, "mo": [0], "rbt": 0, "mtoff": 0, "ipas": 1, "nbrd": 1}

    Denny

    in reply to: Python Interval Program update Oct. 4 2013 #25633

    dennyfmn
    Participant

    Hi Dan,

    I pulled the update and have a couple of issues.

    I only had two small conflicts one in home.js and one in ospi.py with one line of my code in each that referred to the garage door state.
    I fixed them up and committed.

    The home page now only shows the buttons at the top of the screen and nothing below.

    The Refresh, Stations, Programs, my Toggle Door, and Log buttons all work.

    The Options button only displays the top of the options page down to Show Tooltips. Clicking Show Tooltips does nothing.

    I tried commenting out my one line additions in home.js and ospi.py, but that didn’t change anything.

    Any ideas?

    Thanks,

    Denny

    in reply to: Python Interval Program update Oct. 1 2013 #25628

    dennyfmn
    Participant

    Hi Dan,

    Did a git pull, then fixed up the conflict with my pin number additions for the rain sensing, door sensing, and door control. Merged my changes.
    Git status says
    # On branch master
    # Your branch is ahead of ‘origin/master’ by 5 commits.
    #
    nothing to commit (working directory clean)

    Everything seems to be running fine. Rain is being sensed (it’s been raining here), and I can toggle the door up and down.

    Thanks for the update.

    Denny


    dennyfmn
    Participant

    With some great help from Dan, I now have a button on the home page that will open or close the garage door when clicked.

    Dan has also implemented the per station rain sensor option so that is really cool too. If you look at the screen shot below, you can see that the Deck and Window Boxes stations are still active even though the Lawn stations are off because rain has been detected.

    Here’s how to put a button on the home page and get it to do something when clicked.

    First I wanted a button with a suitable icon that would match the good looking ones on the page. I searched for free 32×32 bit png icons and couldn’t find one that looked like a garage door, but I found one that I could edit to serve. http://www.zoobapps.com has lots of free icons, the one I chose is http://www.zoobapps.com/free_icons/index.php?icon_id=25220&cat_id=

    [attachment=2:2dczcqz9]reloadall-5777.png[/attachment:2dczcqz9]
    I rotated it 270 degrees and edited the tails off the arrows. I did the editing with Windows Paint, but found that neither the Win7 or WinXP version would save the icon with its transparency. I had to use Gimp to restore the transparency to the white backround so that the icon would look like the others. Gimp calls it the alpha layer. Saved the output as svc_updown.png to comply with the naming convention and uploaded it to ../OSPi/static/images/icons.

    [attachment=1:2dczcqz9]svc_updown.png[/attachment:2dczcqz9]
    To get the button to show up on the page, add a line to ../OSPi/static/scripts/java/svc1.8.3/home.js. I put it right after the commented out http://igoogle.wunderground.com line. I’ll show where the link argument is pointing to in just a minute.


    w("");

    So now the home page looks like this:

    [attachment=0:2dczcqz9]ToggleDoorButtonAdded.JPG[/attachment:2dczcqz9]

    Now to get the button to do the action, here’s what gets added to ../OSPi/ospi.py

    Since I have previously added as documented above the pin definition for the door control and had initialized it to be an output, I needed to add a function to raise and lower the output for a short time to activate the relay that simulates a button push for the door. Added to the Functions section:


    # Simulate garage door button push by turning relay on for a short time
    def ToggleDoor():
    GPIO.output(pin_door_control, GPIO.HIGH)
    time.sleep(1)
    GPIO.output(pin_door_control, GPIO.LOW)

    Now to integrate the action into the web page add a url to the bottom of the urls section:


    '/rev', 'show_revision',
    '/tgd', 'toggle_garageDoor', <---- added
    ]

    Notice that ‘tgd’ is the parameter used in home.js where the button is placed on the page and the onclick link defined.

    The last step is to define a class to service the url, added to the bottom of the Classes section:


    class toggle_garageDoor:
    """Open and close garage door"""
    def GET(self):
    ToggleDoor()
    time.sleep(12) # Give the door time to open or close before refreshing the home page
    raise web.seeother('/') # This line refreshes the home page

    Notice that the class name is the same as the one defined in the urls section. The time.sleep(12) is there so that the new state of the door is displayed when the home page is refreshed. When opening, the door clears the “closed” sensor very quickly, but when the door is closing, it takes about 11 seconds to trip the “closed” switch.

    That’s it. Click the button on the home page, the door goes up, click it again, the door goes down. What fun!

    Hopefully you can use this as-is or as a template to get OSPi and Interval to do all kinds of cool things.

    Thanks to Dan for all his help in getting this going! Having him explain the magic of the url and class was the key!

    in reply to: Python interval program update 9/23/13 #25582

    dennyfmn
    Participant

    Hi Dan,

    Thanks so much for adding the per station rain sensor option. That’s great! Plus all the other fixes and updates.

    It took me a while to feel confident to do the “git pull” to bring in your commits and merge them with my local changes for the garage door and rain sensor. I’m new to git. I’ve been reading a really good on-line free book, http://git-scm.com/book, which has helped me quite a bit. http://genomewiki.ucsc.edu/index.php/Resolving_merge_conflicts_in_Git also helped with understanding what I needed to do to fix the conflicts I had in ospi.py and home.js.

    Since the rain sensor is functional now, I wonder if you would consider adding code to ospi.py to define the pin, set up the gpio, read the pin, and poll it.

    Here’s the way I’ve done it, adding to the appropriate sections:


    def getRainState():
    if GPIO.input(pin_rain_sense):
    res2 = 0
    else:
    res2 = 1
    return res2

    pin_rain_sense = 25

    GPIO.setup(pin_rain_sense, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    And inserting a call to get the rain sensor state in the main loop:


    def main_loop(): # Runs in a seperate thread
    """ ***** Main algorithm.***** """
    print 'Starting main loop n'
    last_min = 0
    while True: # infinite loop

    gv.sd=getRainState()

    gv.now = time.time()+((gv.sd/4)-12)*3600 # Current time based on UTC time from the Pi adjusted by the Time Zone setting from options. updated once per second.

    Other folks might choose a different input pin for the rain sensor, but the rest of the code would be there.

    [attachment=1:2ozylmh5]Update-20130926.JPG[/attachment:2ozylmh5]

    [attachment=0:2ozylmh5]StationsRainSensor.JPG[/attachment:2ozylmh5]

    Thanks again!

    Denny

    in reply to: can’t autostart ospi.py…rc.local or init.d #25468

    dennyfmn
    Participant

    The ^M in your error makes me wonder if you somehow added DOS type line endings () to the /etc/init.d/ospy script when you created it. The script needs to have only Linux/Unix type line endings ().

    There is a utility that will convert the line endings for you that is not installed in Raspbian by default. You can install it like this:


    sudo aptitude update
    sudo aptitude install dos2unix

    You may notice there are other updates offered. If you want to keep your whole system up to date do


    sudo aptitude safe-upgrade

    To change the DOS line endings to linux line endings:


    sudo su - root
    cd /etc/init.d
    mv ospi ospi.dos
    dos2unix < ospi.dos > ospi

    Make the script executable


    chmod +x ospi

    Try it


    ./ospy start

    Hope this helps…

    in reply to: Python interval program update 8/25/13 #25451

    dennyfmn
    Participant

    Hi Dan,

    I think that distributing the Interval program via git is a great thing. I’m trying to get my head around the process of keeping current with the master repository, but also maintaining local changes. As you know, I’ve been working on integrating garage door control/monitoring and rain sensor input into Interval.

    I have been manually generating a couple of patch files for ospi.py and home.js, the only two files I’ve changed so far.

    Do you have any suggestions about how to handle keeping current and maintaining local changes using git?

    Thanks!

    Denny

    in reply to: Python interval program update 8/25/13 #25450

    dennyfmn
    Participant

    Dan,

    Thanks for the update, the installation went very smoothly.

    If you have been doing logging you can copy the old log file to the new directory so you don’t loose your history. For my installation it is:


    cp -p /usr/local/OSPi-183.local/static/log/water_log.csv /usr/local/OSPi/static/log/

    Adjust the paths for your local setup.

    in reply to: Get and Display Rain Sensor #25403

    dennyfmn
    Participant

    @mikethechap

    Hi Mike,
    The wireless Toro model I have is just a relay with normally open and normally closed contacts available. No readout or display. It has a sensitivity adjustment from 1/8″ to 1″ of rain. I was testing the web interface coding by manually opening and closing my input line. We haven’t actually had any rain yet here in the Minneapolis area, so I don’t know how it will work in real life. Maybe some rain forecast for later today. I’ll let you know how it works; I currently have the sensitivity set to 1/4″.

    The Hunter rain sensor on my old irrigation controller was a similar design. It has been reliable in sensing rain for quite a few years until last fall when the weather turned cooler. I think the battery in the transmitter is wearing out. The battery on the Hunter unit is not replaceable, they make you buy a whole new unit. The Toro unit uses a standard replaceable battery, that’s why I selected it. I hope I have better luck with sensing than you did 🙂


    @Dan

    Thanks for your note about the placement of the getRainState() call. I’ll move it to the start of the loop.

    Thanks for adding some logic to use the rain sensor. It looks like it would be applied globally at this point. I’ll wait for your next release to update my system with all those changes to make sure they are in the right places.

    I had referred to the idea of “rain sensor per program”, but you’re right, rain sensor input per station would would be a better way to describe it. In my case I have 4 stations for my lawn that I want to obey the rain sensor, and two drip irrigation stations that I do not. One is for window boxes, and the other is for potted plants on the deck. We have to use odd/even for lawn watering in our city, but the window boxes and deck plants get watered every day. They dry out quickly and some are sheltered from the rain. I’d be happy to work with you on getting per station rain sensing working.

    This project has been my first real exposure to Python, so it has been a lot of fun. I’m really impressed with the functionality of the GPIO library. Thanks for all your help!


    dennyfmn
    Participant

    Hi Dan,

    Great idea, I had been thinking about diff/patch too. Yesterday I made a couple of patch files for opsi.py and home.js, so applying my local updates will be a lot easier in the future.

    I’m glad to hear that you are looking at the rain sensor logic. I’ve been looking at the code in ospi.py to try to at least read the input signal and get the state of the rain sensor to show up on the home page. I’m having a hard time figuring out how the code works there.

    Having the rain sensor state be available for control in each program would really be great.

    Denny


    dennyfmn
    Participant

    Hi Kevin,

    I have been manually applying my changes after doing updates. I copy into the new OSPi/data directory the two files that preserve your settings and programs; Dan covers that in his announcement.

    You may want to look at my recent post on how to start/stop opsi.py from /etc/init.d if you plan on fiddling around with the code. This makes it a lot easier to start/stop the program. Otherwise Dan’s instructions are fine for starting it from /etc/rc.local if you are going to boot it and forget it.

    Denny

    in reply to: Starting ospy.py from /etc/init.d #25351

    dennyfmn
    Participant

    Hi Dan,

    Sure, feel free to post it elsewhere. I’m hoping that others will get some use from it.

    Denny


    dennyfmn
    Participant

    Yes, I looked at the external addon capability and didn’t see how it would help much, since there are little chunks of code spread out in several places in ospi.py.

    Glad to hear Dan is working on the program, I hope he adds the rain sensor logic. I’d very much like to see a per-program input from the rain sensor. I need to have my lawn obey the rain sensor, but not the pots on the deck and window boxes.

    When I set up the I/O for the garage door,I arbitrarily picked an input pin for the rain sensor. It could easily be redefined.


    dennyfmn
    Participant

    Thanks for the hardware hookup tip Ray. How do I tell the Interval program where to find the GIO signal?

    in reply to: OSPi 1.2 – ADC – Rain Sensor – Garage Door Control #24809

    dennyfmn
    Participant

    No matter whether the rain sensor input comes from the Raspberry GPIO or the OSPi ADC I was hoping to get a little insight into how to incorporate the rain sensor signal into OSpi.

    Thanks for any tips…

Viewing 18 posts - 1 through 18 (of 18 total)