Outback Mate3 online monitor: Explanation and source code
After two months working without big problems and little problems corrected I'm going to release source code and explain how to set-up my monitor for Outback Mate3. This software can run in Windows, Mac, Linux and other systems. The only requirement is to have installed and working Python(version 2.7), Apache, MySQL and PHP.
For Windows and Mac OS X you can download XAMPP to get a full working installation of Apache, MySQL and PHP. You can get Pythonfrom the official page. For Linux systems you can install all software directly from your distribution repository.
How software works?
The software is divided in three parts:
- Python script for receive and manage Mate3 datastream.
- PHP scripts for database records and query's.
- HTML/JavaScript webpage for visual representation.
monitormate.py
Gets and process datastream to send status to a webserver. This script can work standalone and show devices status in command line. Use the following options:
python monitomate3.py --help
Usage: monitomate3.py [options] Options: -h, --help show this help message and exit -p PORT, --port=PORT Port to listen -g, --get-status Get all devices status -f, --fxmodifier Doubles voltage and divide current in 230V FX inverters -s, --show-devices Show connected devices to mate3 -c, --continuous Print data continuously -d DEVICE_ADDRESS, --device-address=DEVICE_ADDRESS Show specific device status -i TIME_INTERVAL, --interval=TIME_INTERVAL Time interval between reads in seconds. Use with -c -j, --json Prints json formatted string with all devices status to stdout -n, --datetime Include date and time and send to url. Use with -u. -u URL, --send-json-url=URL Send json via POST to specified url -t TOKEN, --token=TOKEN Include security token and send to url. Use with -u. -r IP_PORT, --repeat-mate=IP_PORT Re-send mate3 datastream to specified ip and port in format IP:PORT
regstatus.php
Gets a json string with devices status and record it in the database.
getstatus.php
Gets data from database an returns a json string.
monitormate.html / monitormate3.js
Visual representation of devices status and history. Works with getstatus.php for history and with matelog for "real time" status.
monitormate3cfg.php Configuration file. Contains database connection parameters, record interval, security token and time zone.
Installation and execution
- Download monitormate3 and extract it.
- Enter to "web" directory and edit monitormate3.cfg.
- Use database.sql to create tables in your MySQL database.
- Copy the "web" directory content to your server.
- Run monitormate3.py with the correct parameters.
Example:
python monitormate3.py -p2700 -u http://www.YOURSERVER.com/regstatus.php -i5 -t YOURTOKEN -c
Go to http://YOURSERVER/monitormate3.html, maybe you have to wait a little depending your record interval. You can send datastream directly to your remote server and run monitormate3.py on it. Time interval on monitormate3.py only affects to "real time". Interval for database record is in monitormate3cfg.php. You can use de -r parameter to resend datastream to other computer or to send to the same using other port and use again the python script to see status in command line. If you find any bug or have a suggestion to improve the software please feel free to post a comment or send an e-mail.
Files:
monitormate3-0.1.zip
- First release
monitormate3-0.2.zip
- Corrected general bugs
- Fixed problems in systems without Flexnet DC
- Fixed crashes in systems with MX controllers when AUX is on
- Fixed bug that makes the last years do not appear