SmartPlug Help File
This is the Help "file" for the Python Application whose main page is: *Python Control of Smart Plugs - OpenCircuits
Help file for smart plug application ( Ver4 )
Works with multiple smartplugs Provides on off functions from a graphical user interface ( gui ) Highly configurable Supports graphing of data Supports csv output of data Saves data to a sql lite database that you can use any way you wish
First Use of the SmartPlug Application
The application is set up with a default database, but it need some information on your devices.
How to Use the Parameter File
You need a text editor sutible for .py files to manage the parameter file ( parameters.py ) This includes most text editors. I particurlay like:
You can also use the editor that comes in many python development enviroments, the simples of which may be Idle. But there are many many others. If you are reading this you probably have some experience.
A couple of gotchas to watch out for. * Python cares about capitalization, use the capitalization indicated in the default files and the example code. * Python also cares a lot about how lines are indented. Do not change the indentation from the sample files, and always indent using spaces ( not tabs. most text editors will use spaces automatically for .py files, even if you use the tab key )
First time editing of the parameters.py file
Use your chosen text editor to open the file parameters
specify in parameters.py with
self.ex_editor = r"D:\apps\Notepad++\notepad++.exe" # use r" or the backslashes will not work, or you can use forward slashes insterd they may be wrong but they work.
Working With Database Files
- Create a directory for your data and database -- application comes with defaults
- Run database definition routine button wf1
You need to name a database, application will default You also need your sample file input, start with the one from the step above. look at output.......
* The edit functions work only after you have configured parameters.py for your systems text editor
<Edit Log> >Open the application python log file using the system editor specified in parameters.py file <Edit Parms> >Open the application parameters.py file using the system editor, after the file has been modified
the system can be quickly restarted using the Restart button.
<Restart> >Quickly restarts the system after the parameters.py file is changed or any time you want to restart the system
from its current defaults
Watch the console for error messages and in particular look for modules that may be missing ( I do not provide these, pip or conda should install them )
Work Flow Overview
Just a bit of theory the may be helpful - Some Definitions
These encode data in a structured and efficiently searchable format. It also easily select subsets of data and can sort those results. There are lots of different kinds, but one fairly standard one is a SQL or relational database.
The file ( or one of the files ) where database information is kept. We are using sqllite, which keeps a whole database in one file. This makes it very easy to move and/or backup a database.
Table, Record, Column
in a SQL data base data is stored in Tables ( many tables may be put in one database ). A table consists of records ( also called rows. ) Each row is information about some "thing". For example if the "thing" is a person a record might contain the person's first name, last name, date of birth.... The table is much like a spread sheet with the information on each person in a row. Each of the items ( first name, last name, date of birth.... ) is called a column.
SQL - Structured Query Language
This is the language used by relational databases. Typically the system generated the required SQL and runs it. The user interface often shows the SQL which is quite a bit easier to read than it is to write. It may give you useful feedback on what the system is doing.