- This topic is empty.
August 8, 2013 at 5:18 pm #22590
I’ve written a plugin for MiCasaVerde to control OpenSprinkler http://code.mios.com/trac/mios_opensprinkler.
During testing with other users I’ve found a couple of behavioral differences between OS and OSPi.
http docs : http://rayshobby.net/?page_id=730#httpget
#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
[/list]August 8, 2013 at 6:05 pm #25309
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.August 8, 2013 at 6:45 pm #25310
Dan in CAParticipant
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:
"""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)-1 # station index
b = sid/8 #board index
if nstlst == 1 and gv.sd: # if status is on and manual mode is set
gv.rs[sid] = time.time() # set start time to current time
if nstlst: # if an optional duration time is given
gv.rs[sid] = nstlst
gv.rs[sid] = gv.rs[sid] + nstlst # stop time = start time + duration
gv.rs[sid] = float('inf') # stop time = infinity
gv.rs[sid] = 99 # set program index
gv.ps[sid] = nstlst
if nstlst == 0 and gv.sd: # If status is off
gv.rs[sid] = time.time()
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.
DanAugust 8, 2013 at 6:51 pm #25311
Thanks to you both for the quick responses. OS & OSPi are great products – appreciate the support.August 8, 2013 at 7:45 pm #25312
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.
IngoAugust 8, 2013 at 8:32 pm #25313
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.August 9, 2013 at 5:51 am #25314
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 ‘ospi_addon.py’ extension where I have all my custom code without having to modify the base ‘ospi.py’ program.
- You must be logged in to reply to this topic.