-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development Chat #24
Comments
About the new API. I know that the mobile app wants to support the arduino based version, but I don't want to let that stop us from improving the python version. The current port is largely based on the arduino code. Although this keeps stuff compatible, it is very non-Pythonic. I've already talked to @Dan-in-CA about this. Let me copy some parts of my conversation: If I look at the program from a high level, I would expect something like the following:
On the short term I think I will improve the output layer to make it more abstract and be able to use a "dummy" output that can be used during development. Currently all try catch constructions are a bit tricky. Next I want to have a look at the plug-in system. I'd like to be able to enable and disable plug-ins from the GUI and get rid of the executable bits. The executable bits now also influence the system update plugin because it has to ignore them to prevent conflicts. |
It is a very fair point and in the end, so long a plugin can expose the data in the method the app understands, things will work fine. So I agree, don't let the mobile app hold you back. By the way, some of the issues you mentioned are addressed in firmware 2.1 for Arduino. |
hello, |
Implementing what I've proposed in terms of API only makes sense if there Let's first see just how much traction my proposal gets with the community On Sat, Sep 20, 2014 at 8:01 PM, Martin Pihrt [email protected]
|
@martin: |
I use a service ospy ... despite the fact I have to manually apply the settings tab reboot the system to load changes. I have a pure clone of https://github.com/Rimco/OSPy and update doing locally (or via sms and click update) |
That's weird, I also have a plain OSPy clone running and updating (using webpage) works fine. It starts updating, initiates a service ospy restart and lets the client wait for the page to come back. In less than 30 seconds I get a new plug-in page telling me the program is up-to-date. I've created a new branch in which I'll try to improve the overal structure (without impacting the api yet). I'll also include extra logging facilities to be able to debug these kind of problems more easily. |
That's indeed what I would use and my architectural idea is the same. The system should provide some global logging facility that can also be used by plug-ins. This logging facility should also be able to return the entries per group such that plug-ins can use it as feedback for the user. |
@teodoryantcheff it's almost like you are using my read_program function as the bases 👍 But really thats exactly what my function does and having the firmware do it is obviously a huge help and lowers the barriers to future development. I love what this is shaping up to be. Also, as Dan mentioned, we should get Jonathan in on this conversation since it sounds like he has already started with the development of it. |
@salbahra - You javascript guys really amaze me! I do understand the language itself, DOM, CSS, HTML5 and all related stuff, but still the way you manage to make it all work together seems like dark-black magic to me. High-five to that ! |
@teodoryantcheff Well I am learning as I go but it's a lot of fun! I figured, I was just kidding and only meant it abstracts away a lot of the complicated stuff so the UI can focus on it's purpose. The API is essentially only used by the mobile app now and I already have a good idea if you are willing to incorporate it into your proposed API. Right now, I only support my own plugin in the mobile app. However, if the API allowed, I would be able to manage them in the app and also interact with them (using some sort of agreed format for page formatting). Since I am using jQuery mobile, you could pass a title string and a page content string? |
@salbahra then you'll like the newly added |
Although that might seem a good starting point, all schedules seem to be independent. In our case, we need to be able to combine them intelligently and also predict when they will run. During my conversation with Dan, I also told him I already started implementing such a scheduler before I discovered a Python OSPi existed. Let me copy-paste what I told him: I've also got some designs lying around and I started coding the basics of the back-end. It contained the scheduler similar to what I described earlier. I designed the program as follows: First you have "Schedules". Schedules are defined by specifying the active periods. Schedules can optionally repeat after a certain period (1 day, 1 week, 2 weeks, anything). The scheduler can report the time intervals it want to be active given a date/time range. It can also calculate if it would be active at a given moment in time. I have working implementations of these three parts lying around which I could just copy-paste in the current implementation. My main concern is that this would change the behavior significantly making it incompatible with the arduino implementation (for the mobile app). |
Hi guys, Please let me know what you think of https://github.com/Rimco/OSPy/blob/refactor/options.py and https://github.com/Rimco/OSPy/blob/refactor/stations.py. The options instance (from options import options) provides a simple way to get and set options. The predefined options are used for the core functionality. In addition, any object can be saved by giving it to the save function. A similar load function is also available. I think I'm also going to provide some "on change" callback mechanism to notify parts that are interested in a certain property. You can also use the options instance to save any data persistently. The class makes sure that it will be available whenever the system is restarted. options.test123 = 5 will just work magically;) Next, the stations implementation makes use of this to magically save station properties. These stations can be used as output instances directly. first_output = stations.get(0) ... first_output.activated = True will do everything for you to enable an output for example. Let me know what you think, I'm currently trying to figure out which parts that need to be updated to let them work with these new constructions. That seems to be many. |
Re your first post and the scheduler - The idea that I have -- say we have a program P that states running valve 2 (station 2) for 2 hours starting 15:00 o'clock every day. So the implementation is :
You can see that this architecture is flexible enough to allow all current kinds of scheduling and some additional ones - seasonal schedules, every friday the 13th, "birthday" watering and so on :) . Also the "next" watering cycle is always known. And schedules visualization remains, just as now, an exercise for the UI. Which is where it belongs in my view. Finally, as long as the UI can get the same API from the controller, it does make no difference. What I was thinking about this is that the current API (current json API, urls, endpoints and so on) can be implemented as a "legacy" API on top of whatever new we decide to do in ospy. Will be looking at the new goodies you put up for review shortly, as I have a kid on my hands that needs attention as well :) |
Ok, comments here since I couldn't find a way to comment code in-line. options.py
def __init__(self):
self._values = {}
self._write_timer = None
for info in self.OPTIONS:
self._values[info["key"]] = info["default"]
with open('./data/options.json', 'r') as options_file: # A config file
self._values.update(json.load(options_file))
def __getattr__(self, item):
return self._values[item] since all other case are implicitly taken care of already... i think.
def get_categories(self):
return sorted(list(set([o.get('category', '') for o in self.OPTIONS])))
stations.py
|
Your json loading seems nicer indeed, I've updated it. The getattr should indeed only be called if it is not found, but the first self._values = {} seems to call it already. I tried to do what you say, but I found out that this way we are certain we can't get in any race condition. Furthermore, we prevent saving any internal variable by accident. The setattr is always called, so that certainly needs this construction. I don't know what you mean with "I'd extract the file name to file level or class level "constant"", please elaborate. Your get_categories throws away the order and also makes a "" category. If an option has no category, it should not be displayed (automatically) on the options page. And the order specified in the options list should be returned as-is. I like one-liners, but this one seems not to achieve the goal I had in mind;) I've renamed activated to active, but activate and deactivate seem more logical than on and off to me. I "activate" station 1, I don't "on" station 1. The BaseStation state is not a duplication, it's even the only place where the states are saved. The Station instances query the Stations "factory" what their state is. Why? Because a single station might not be responsible for the state handling. Furthermore, by delegating this question to the proper Stations instance, you could also let it query the real output state instead of some buffered state. At the moment I handle this in the BaseStations to keep the subclasses very simple, they only have to make sure that the self._state is used to set the outputs. |
Thanks :) |
I've made the filepath a constant:) The order was something I didn't think about either in the first place, no problem;) @salbahra Do you mean to push OSPy to OSPi or to push the refactor branch to master? |
I actually deleted the comment since its technically not development topic but to OSPi since that's the repo people are using. |
General ideas are also welcome here;) We should check if the OSPi branch has some functionality we need to port. I think Dan kept it fairly in sync. If possible, we might ask Dan to update OSPi with our contents. Currently he is referring developers to this version. |
Speaking of users -- any idea how big is the userbase of OSPi/y and the arduino variant ? |
Oh, and @Rimco 's changes are quite significant and affecting all of the source. I'd be doing logging otherwise or new API. Now I will have to wait :) |
That's why I'm making my changes in a separate branch. You can use the master branch to make your changes;) Although I may change a lot of things, I'm trying to make it as simple as possible. In the end I could get your parts from master and make them work in the refactor branch. |
Hello everyone, No function any output from shift register. In debug is print: in debug is all ok, but shift register not function. I have a raspberry pi. LCD plugin is really now OK, thanks Rimco |
Seems to be an issue, I think it didn't recognize the RPi properly. Please |
Finally found some time to look at the issues... Done: TODO: In addition, I'd like to have some opinions on the plug-ins. I see we are getting a many plug-ins, which is nice. But, I also see a lot of plug-ins that are completely unrelated to the irrigation system. In addition, many require hardware that is very rare. For example: SSH client: Has nothing to do with OSPy, Webmin could also provide this. I can understand that the current plug-in system is very nice and easy to develop code, but I don't think OSpy is the proper location. Should we keep these plug-ins in the repository under the assumption that others won't enable them anyway, or should we consider (re)moving them? Please let me know what you guys think. |
My 2 cents :
Other than that -- great work, all ! |
Just to chime in regarding the mobile app, I would be open to adding support for OSPy fork of OSPi as long as it's being used (by request). Right now, it's too much time to spend on something that's still in an early stage. I absolutely agree though this looks awesome and love the improvements! |
Hi, all AD plug used for measuring the temperature in the greenhouse:-) a) please remove plugins for the move to a temporary folder: b) I think that plugins do not take up much space and should be delivered in a whole folder OSPy. It is up to the user whether the plugin in settings starts, or let him off. Yes plugins installation support would also be appropriate (in the future it would be easier for the average user to install a plugin to add to OSPy - installation in the folder plugins and plugins template). Also, I think it would be appropriate to introduce some help (all plugins) as well as connect hw and how they work. Thank you all for a great job, I'm excited for the system to "refactor" to start in the spring watering my gardens. MP |
PS: Je jednodušší spravovat všechny funkce z jednoho místa v rámci integrace (pluginů sms, e-mail, webové kamery plugin plugin, pluginy tlak, Vodní plugin .... Dívám se na OSPy jako malý operační systém:-) |
sorry: I look at OSPy as a small operating system:-) |
997f3ca |
Hi Martin, could you tell me what kind of operating system you are running? |
Hi, |
That should be fixed now, see #60. My question was regarding: "Support ospy.service file in setup.py? Did you use the ospy.service file yet? |
Hi, I run installation now and find error and error2 |
I tried to fix all your issues, please let me know if it works:) |
Hi, root@opensprinkler:/home/pi/OSPy#I delete old ospy.sh in etc and check installation... Error is in Removing (old) service first:Web page on the web for plugin is not function... If click on email plugin page redirects to home page |
Just wanted to update you guys on the current developments: |
Thank you, I reported my errors. I do not mean any harm :-) |
I don't mind reported errors, they are my fault anyway;) Issue #72 should be fixed, can you confirm? |
@Rimco - well, damn ! I should have paid proper attention and found this :) Not just leave for "later" investigation.... Stupid me. |
@Rimco - Please add support for i2c tools and SMBus to the installer? (python-SMBus, i2c-tools) |
Hi Rimco, |
Hi all, Plug-ins have now been moved to external repositories. I will only maintain the core plug-ins located at https://github.com/Rimco/OSPy-plugins-core. Please have a look at https://github.com/Rimco/OSPy-plugins-temp for the plug-ins that I don't consider to be a core part. If you "own" one of these plug-ins, move them to a repository of your own and submit a pull-request to add your repository to the list of repositories (in plugins/init.py). @martinpihrt I'll try to have a look at some way to let a plug-in specify what it needs in some way. Problem is that the installation of packages might need user input, so I think it should not happen silently. Rimco |
Hi Rimco, |
Hi Rimco, |
Hi,
I'm planning to extend the update manager to contain this information, but
I wanted to start with a basic version. I already implemented this a while
ago and wanted to push at least something.
I think it is possible to extend the plug-in manager to show this
information and to (automatically) update.
Rimco
|
Ok, |
I did not push it until I was finished;)
|
I understand, thank you |
Hi Rimco, |
This issue should be used as main chat for active contributors. Let me know your ideas and what you want to do. First idea of teodoryantcheff was documented in https://github.com/Rimco/OSPy/wiki/API-idea. Old chat is in #22.
The text was updated successfully, but these errors were encountered: