dbudwin / RoboHome-Web

RoboHome-Web is the codebase that represents the frontend of the RoboHome project. The web interface provides a way to create users, add and manage devices, and an additional way to control devices. :robot: :house_with_garden:
GNU General Public License v3.0
9 stars 17 forks source link
amazon-echo home-automation laravel mqtt mysql php

Slack Build Status Code Climate Coverage Status

RoboHome-Web

What Is RoboHome-Web?

This repo is one of a few repos that make up the whole project. RoboHome-Web is the codebase that represents the frontend of the RoboHome project. The web interface provides a way to create users, add and manage devices, and an additional way to control devices. RoboHome-Web is primarily built using PHP with Laravel for MVC and routing, MySQL for the database, and Bootstrap for layout and basic mobile support.

What Is the RoboHome Project?

RoboHome is a SaaS tool that also integrates with Amazon's Echo to enable control of semi-connected devices (think IR, and RF) in your house over wifi! This is done using an MQTT pub-sub network to send messages between the website or Echo to a microcontroller like the ESP8266 which has various transmitters hooked up to it (like IR and RF transmitters) to send signals to these devices. This can be used to control RF outlets with lights plugged into them, or to turn on your TV and change channels for instance.

Developing RoboHome-Web

Requirements :white_check_mark:

  1. Web server with PHP 7.1.3 or greater with MySQL
  2. SSL/TLS cert available for Free with Let's Encrypt. Note, we must use slightly less secure ciphers than the max due to hardware limitations of the ESP8266 which will need to talk to the RoboHome-Web API over HTTPS to gather information about devices. If set up correctly, by entering your website in SSL Lab's SSL Server Test, you should still get an "A" rating. To get the appropiate ciphers for your server visit Cipherli.st and click "Yes, give me a ciphersuite that works with legacy / old software."
  3. MQTT broker for pub-sub. I personally use CloudMQTT. This service is used to send messages from a web service to a microcontroller.
  4. Composer dependency manager for PHP

Configuring :wrench:

  1. Rename .env.example to .env and populate the information needed to connect to your MQTT broker and MySQL database (under DB_CONNECTION).
  2. Run composer install from the root folder to download and install third-party PHP dependencies.
  3. Run php artisan key:generate from the root folder. This will populate the APP_KEY field in the .env file.
  4. Run php artisan migrate from the root folder. This will setup the database using the connection settings defined in the .env file.
  5. Run php artisan passport:install from the root folder and save the output to a safe location. The output will be needed later to help configure 3rd parties (like Amazon) to authenticate with RoboHome.
  6. Run php artisan serve from the root folder to start the website. This command will print to the terminal the local URL where you can visit the website in your browser.

Docker :whale2:

This project uses Docker Compose to help easily emulate a test environment for rapid development and testing. This container has the PHP, MySQL, and phpMyAdmin services.

  1. Start Docker and execute ./StartDockerAndRunTests.sh. This will create a backup of the .env file, download and start all the containers, configure Laravel, run all the tests, and then restore the .env file.
    • Once running, visit http://localhost to view the website. To access phpMyAdmin, navigate to http://localhost:8183 and login with the following credentials; username: root, password: password (these credentials come from .env.docker if you want to change them).
    • This is a good step to execute before contributing code.
  2. To run custom commands inside the container running Laravel, pass the command to web.sh like ./web.sh composer install.

Contributing

How To Contribute :gift:

Contributions are always welcome! Please fork this repo and open a pull request from a new branch with your code or feel free to make an issue. All pull requests will need to be reviewed and pass automated checks. If feedback is given on a pull request, please submit updates to the original pull request in the form of fixup! commits which will later be squashed before the pull request is merged.

For more information, consult the contributing guidelines.

This repo supports the principles of Bob Martin's Clean Code.

Notes :notebook: