Using Wemo Smart Switches to retrieve the data such as the state of the appliance, current drained by the appliance, dates the appliance was one for, etc. and storing it in a MySQL database. These data will then be used to generate plots. mysql_plot specifically plots the current drained by the appliance vs. time.
wemo_table: Retrieves all available appliances using Wemo Switch and generates table in MySQL
wemo_data: Retrieves all information such as state, currentpower, total on time, etc. and stores it into the respective tables in MySQL real-time.
wemo_plot: Retrieves the data and plots currentpower vs. time
For the first time a plot is generated, you will obtain a plot from the beginning to end of the dataset. If you run wemo_data multiple times (eg. running code on different days) notice that in the table generated in mysql, IND_[SWITCH_NAME] there are two columns of interest: mysql_index and python_index. mysql_index fetches the data index corresponding to that particular day, and by setting start_index = cursorObject.fetchall()[python_index][0] (line 477), you can plot starting from that data. All is explained starting from line(436)in wemo_plot.
MAKE_PLOT(X,Y): This plots the currentpower vs. time from the original set of data. This may not be optimal if one wants to minimize the amount of data sets for optimizing memory space.
PLOT_FINALDATA_SMOOTHING(X,Y): This plots the currentpower vs. time first smoothing out the original data set. The maximum value is then stored using argmax which will be a reference point to be connected. This will reduce the amount of dataset although if one wants to keep the currentpower drained by the appliance as is, then it may not be optimal.
PLOT_FINALDATA(X,Y): This plots the currentpower vs. time first storing the point where currentpower = 0[W]. It will neglect all the other points with 0[W] until there is a change in current - this interval will then be stored. It is the same plot as MAKE_PLOT(X,Y) reducing the amount of unnecessary data.
- Python Version 3 or higher
- A database named, 'DATA' in MySQL
Modules:
- Numpy
- Scipy
- Ouimeaux
Note: All modules are commented and explained within the python files. The two python files, socket and pywsgi have been modified to reduce the errors that conflict between Py2 and Py3. These errors do not affect any process generated by the wemo python files and only show up once when run on wemo_data.py
- Not able to detect any device:
Make sure when you install ouimeaux, it is installed with the right server. You can achieve this by running: pip install ouimeaux[server]. If this does not fix any issue, then reset your device using http://www.belkin.com/us/support-article?articleNum=123734 and install again. By running the command, 'wemo list' in terminal, you will be able to detect the wemo devices.