OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) HTML API differences beteen OpenSprinkler and OSPi

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #22590


    I’ve written a plugin for MiCasaVerde to control OpenSprinkler

    During testing with other users I’ve found a couple of behavioral differences between OS and OSPi.

    http docs :

    #1 OPSi will run a single station even when not in Manual mode. e.g. http::///sn1=1&t=0 works in Auto mode.
    — Note this poses a potential issue for folks using password security. A password is required to shift mode (Auto to Manual); but is not required to activate a single station. Hence, it’s possible to turn on/off stations without a password.

    #2 OPSi throws an exception if a single station is activated via http::///sn1=1 and the &t=0 param is not supplied.

    #3 OPSi returns html tags in response to http://x.x.x.x/sn0
    OPSi :







    I also ran into these issues when developing my web app and got around them using a couple of methods.

    In regard to the t=0, I always send that for OSPi or the OpenSprinkler.

    For the tag I parse it out using regex (actually I parse the digits in):

    preg_match("/d+/", get_from_os("/sn0"), $data);

    Also for the password problem, I personally limit the firmware to LAN only. And let my web app handle security/etc on the Internet.

    Hope this helps!

    Update: By the way, not sure if you are aware but the API used to be vastly different but a lot of work has gone in to bridge the gap. Dan has been instrumental in all of this and at this point we are fairly close. If you want to fix the t=0 discrepancy you can submit a patch to Dan and he might incorporate it into the main code. I personally haven’t found this to be a huge problem since I don’t plan on using the timer feature of manual mode. I prefer run-once in that scenario.


    Dan in CA


    I took a look and what was going on and made a couple of changes to the Interval program. The fixes will be in the next update but if you want to make the changes now, they are:
    issues #1 an #2.
    replace the set_station class (~line 642) with:

    class set_station:
    """turn a station (valve/zone) on=1 or off=0 in manual mode."""
    def GET(self, nst, t=None): # nst = station number, status, optional duration
    nstlst = [int(i) for i in re.split('=|&t=', nst)]
    if len(nstlst) == 2:
    sid = int(nstlst[0])-1 # station index
    b = sid/8 #board index
    if nstlst[1] == 1 and # if status is on and manual mode is set[sid][0] = time.time() # set start time to current time
    if nstlst[2]: # if an optional duration time is given[sid][2] = nstlst[2][sid][1] =[sid][0] + nstlst[2] # stop time = start time + duration
    else:[sid][1] = float('inf') # stop time = infinity[sid][3] = 99 # set program index[sid][1] = nstlst[2]
    if nstlst[1] == 0 and # If status is off[sid][1] = time.time()
    raise web.seeother('/')

    Issue #3:
    Int the Get_Station class (~line 628), comment out or delete the following line:

    status = 'n'

    Modify the ine after that to change += to just =:

    status = ''.join(str(x) for x in gv.srvals)

    The doctype line was originally added to make the program work with webkit browsers such as Chrome. I just tested this in chrome and it is working as expected.




    Thanks to you both for the quick responses. OS & OSPi are great products – appreciate the support.



    Please don’t remove the DOCTYPE statement as this is the only way I can differentiate between OS and OSPi. Rather let the Client handle the formatting differences because the output is read via HTML Browser and you should actually always format the text accordingly. The fact that a browser can display normal text is just a bonus.




    Ingo – are there other differences between OS and OSPi that I need to handle in my code?

    FWIW – The doctype being present is fine for my code as it now parses the response correctly for both formats.



    Not as far as I can tell. Dan did a pretty good job of emulating the OS Micro so it’s pretty straight forward. Just keep in mind the functions not implemented at the moment like HTTP port, Location etc. The best thing about OSPi is the fact that he introduced the ‘’ extension where I have all my custom code without having to modify the base ‘’ program.


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

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) HTML API differences beteen OpenSprinkler and OSPi