By Rahim Khoja
The Atomik Controller manages automated and smart lights. Initially The Atomik Controller will manage Mi-Light brand lights and Remotes, but it will expand to other Atomik and third party smart devices. The goal is to create a drop in replacement for the Mi-Light wifi bridge, that expands the zone and device limitations, while providing a more robust home lighting controller. The Atomik controller currently includes a Web GUI for system management, a Nrf24l01+ 2.4 GHz transceiver for listening and transmitting, Mi-Light RF RGB remote compatibility, a Mi-Light Smartphone server emulator that allows use of the Mi-Light Smartphone app as a remote, an API for 3rd party integration, and a task scheduling system to control light zones.
Hopefully in the future the Atomik Controller will add blue tooth connectivity, additional devices from a variety of manufacturers, Zigbee compatibility, Z-Wave compatibility, OpenHAB compatibility, a simple light io scripting interface, a fully documented API for 3rd party compatibility, and other types of devices and sensors.
Settings Screen
The Atomik API accepts JSON Commands on Port 4200 of the Atomik Controller to control the Atomik lighting Zones. Atomik API Remotes are setup, and applied to Zones from within the Atomik Controller web administration GUI. Atomik Api Remotes only have two types of commands, List and Issue. List will accept JSON that contains a valid username and password and return a JSON list of all the available zones and their current settings to the user. Issue will accept JSON that contains a valid username and password along with zone light settings, then it will update the light settings and return a JSON list of all the available zones along with the updates zone information from the Issued command. If command is not accepted or invalid credentials are passed to the Atomik API, an error JSON is returned.
All Commands are posted to 'http://192.168.1.100:4200/atomik' ( or the IP Address of the controller )
Here are some example commands:
List Command - JSON Request Example:
{"Command":"List","User":"rahimk","Password":"password"}
List Command - JSON Response:
{
{ "ZoneName":"Bedroom", "Configuration":{ "Channel":"0", "Status":"1", "ColorMode":"0", "Brightness":"100", "Color":"198", "WhiteTemp":"2700" }}
{ "ZoneName":"Living Room", "Configuration":{ "Channel":"1", "Status":"1", "ColorMode":"1", "Brightness":"100", "Color":"0", "WhiteTemp":"2700" }}
{ "ZoneName":"Hallway", "Configuration":{ "Channel":"2", "Status":"0", "ColorMode":"1", "Brightness":"100", "Color":"0", "WhiteTemp":"6500" }}
}
Issue Command - JSON Request Example:
{"Command":"Issue","User":"rahimk","Password":"password","Configuration":{"Channel":"1","Status":"1","Brightness":"65","ColorMode":"1","Color":"215","WhiteTemp":"6500"}}
Issue Command - JSON Response:
{
{"ZoneName":"Bedroom", "Configuration":{"Channel":"0", "Status":"1", "ColorMode":"0", "Brightness":"96", "Color":"221", "WhiteTemp":"6500"}}
{"ZoneName":"Living Room", "Configuration":{"Channel":"1", "Status":"1", "ColorMode":"1", "Brightness":"68", "Color":"215", "WhiteTemp":"6500"}}
{"ZoneName":"Hallway", "Configuration":{"Channel":"2", "Status":"1", "ColorMode":"1", "Brightness":"18", "Color":"215", "WhiteTemp":"6500"}}
}
Invalid Request - JSON Error Response Example:
{"Error": "Invalid Username or Password"}
Notes on Atomik JSON Requests and Response:
WhiteTemp can be any integer between 2700 ( Warm White ) and 6500 ( Cold White ).
Testing the API with cURL:
curl -H "Content-Type: application/json" -X POST -d '{"Command":"Issue","User":"rahimk","Password":"password","Configuration":{"Channel":"2","Status":"1","Brightness":"10","ColorMode":"1","Color":"215","WhiteTemp":"6500"}}' http://192.168.1.100:4200/atomik
curl -H "Content-Type: application/json" -X POST -d '{"Command":"List","User":"rahimk","Password":"password"}' http://192.168.1.100:4200/atomik
Required Hardware:
A Web Browser
Hardware Setup:
Quick Install Instructions:
Restart the Emulator, Transceiver, and API from the settings page after first boot
Full System Install Instructions:
Coming Soon! (or when I get around to it)
Most Important CPP files have compile instruction on line 1
SSH Credentials (pi/raspberry)
MariaDB Credentials (root/raspberry)
Operating System:
Raspbian (jessie)
Software Dependencies:
RF24 Driver ( https://tmrh20.github.io/RF24/RPi.html )
Node.js 4.0+ ( https://nodejs.org/en/download/ )
Nginx
PHP
LibCurl
JSONCPP
MariaDB (MySQL Fork) - Cuz we all love Microseconds
G++
MySQL C++ Connector
https://github.com/pmoscetta/authometion-milight - Pietro Moscetta
https://github.com/henryk/openmili - henryk
http://torsten-traenkner.de/wissen/smarthome/ (In German, Can't Actually Read Anything But The Code) - ?
https://github.com/bakkerr/openmilight_pi - Roy Bakker
https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol - Henryk Plötz
https://gist.github.com/jpawlowski/5359556 - Julian Pawlowski
THIS SOFTWARE IS PROVIDED BY ATOMIK (Rahim Khoja) AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ATOMIK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Since I am extremely lazy I am not going to offer any support. Well maybe every once-n-a while. It really depends on my mood.
That being said, time was spent documenting each command in the scripts. This should allow the scripts to be easily understood and modified if needed.
Many Bothans died getting this Mi-Light Bulb Controller to you, honor them by sending me some Crypto. ;)
ETH Mainnet: 0x1F4EABD7495E4B3D1D4F6dac07f953eCb28fD798
BNB Chain: 0x1F4EABD7495E4B3D1D4F6dac07f953eCb28fD798
Released under the GNU General Public License v2