The system contains some hardware parts:
- OpenWrt rotuer – contains all intellegence implemented with python and MySQL database. It hosts the webserver with user interface.
- USB <=> wireless adaptor – takes packets from USB (it uses usb to uart converter PL2303HX from eBay so for the router it behaves like standard serial port) and sends them to the slave modules and vice-versa receives packets from air and sends them to the router. No more inteligence inside.
- Heating controller – This unit is in the basement connected directly to the heating. It contains two relays for switching on heating and water pump separatelly. It also contains temperature sensor for measuring temperature of water in the warm water container. Also no more inteligence implemented. It just sends temperature of water in a regular time period or when the temperature is changed. The state of output relays is also controlled by wirelless commands.
- User handle – this unit is in the appartment. It shows basic information about the system status (like temperature of water, temperature at home, heating on/off). User can also setup the system from this unit. Unit can switch between the heating programmes (water heating, heating to home, disabled) and also can setup configuration of those programmes (when to heat, when not , maximum temperature and so on).
The router is the brain of whole home automation system and is divided into these parts:
- MySQL database
- The database contains configuration of all heating programmes (water heating/ home heating and so on). There are stored procedures and functions for saying when heating should be turned on or off. Database is the part which makes decisions about heating state.
- There is also table for logging all events from the system like measured temperature from home or water temperature, slave module not responding from-to and so on.
- Python application – The python application is responsible for intercommunication of database the hardware via serial port. It receives data from hardware and store received data into database or it takes data from database and sends them into hardware. The whole application structure will be described later. The code is going to be documented by doxygen.
- Web interface – Whole web interface is written in PHP and it is based on codeigniter framework – url is in external links part. The web interface is bassically the same like the GUI handle module the user can setup whole system configuration and he can see the state of sensors and so on.
Note: the python application is already well documented in the source code by doxygen. Documentation can be easily created from the sources.
The python application consists of these main modules (packages):
- Dispatcher – dynamic loading of user applications on the fly
- Events – Simple event processing queue
- Hardware – communication layer with hardware via virtual serial port
- Logger – advanced TCP logger developer can create new TCP logging handlers via configuration port
- Applications – user modules which are reloaded on the fly by dispatcher, there is no need for application restart when developer makes any changes.
Basic class cooperation diagram
Main purpose of this package is to watch user modules for changes and dynamically adds/reloads them on the fly so there is no need to restart whole application. Just the changed module needs to be instanciated again.
Dispatcher also instanciates hardware class and receives callbacks from the hardware and decodes and distributes these messages to the user modules and vice versa user modules can use dispatcher API to send wireless frames to the wireless slave units.
There is also command table which contains wireless command set which is also fully configurable by user and it is used by user modules and wireless slave modules. The table should be the same in the python application and...Read more »