enable/disable programs via a plugin - Printable Version +- SIP (https://nosack.com/sipforum) +-- Forum: SIP (Sustainable Irrigation Platform) (https://nosack.com/sipforum/forumdisplay.php?fid=1) +--- Forum: Plugin questions (https://nosack.com/sipforum/forumdisplay.php?fid=6) +--- Thread: enable/disable programs via a plugin (/showthread.php?tid=308) |
enable/disable programs via a plugin - tutqiunnh - 2023 Jun 11 Dan, Still hacking away on my weewx weather station plug in prototype. I've been scanning the code to understand how the enable/disable program works. The HTTP method is useful and SF for my shell script implementation. However, as I'm implementing the plugin I can't see a variable or list that handles program enables. I see that urls.py and webpages.py is the way the the HTTP method accesses the programData.json file to handle enable/disable. Also I see that gv.pd is the load of program data into sip.py for use executing programs. Here is my higher level reasoning, I have programs setup to handle my lawn sections, and programs for my veggy garden drip and another program for shrub drips. I use a monthly data json file to enable watering for the three program types. I use lawn as the system enable/disable and programs are always enabled since lawn has the largest window in months (system off in the cold/rainy months). Once system enabled for lawn, I want to enable/disable veggy garden and shrubs programs based on the growing/hot dry months of the year (May,Jun,July,Aug...) Any thoughts on the best way for a plugin to modify the programData.json? Should I use: u"/ep" variable to "fake" a GET request via the plugin? or just use: gv.pd[pid]["enabled"] = int(["1/0"]) jsave(gv.pd, "programData") in the plugin? I have messed around a bit and programData seems to be a dict, which I have not handled yet in python. Seems that a for loop can find the index of an item in the dict and then I can change then enabled entry in that item. Thanks, Bryan RE: enable/disable programs via a plugin - dan - 2023 Jun 11 You are on the right track. The program data in Python is a dict. Once you have the index of the program that you want to disable/enable you just need to set the "enabled" item to 0 for disabled or 1 for enabled. The index of a program in the dict is the program number -1. For example to disable program 2 you would use something like: Code: gv.pd[1]["enabled"] = 0 |