Code Monkey home page Code Monkey logo

envirohome_simulator's Introduction

envirohome_simulator {#mainpage}

This is the simulator module for Envirohome. Envirohome is a smart home system to allow you to control all of your smart devices in a easy to use and attractive interface.

Usage

To build this project:

  1. From project root directory run - $ docker-compose build

To run this project:

  1. From project root directory run (Full app) - $ docker-compose up -d

Optional (Only db and web): $ docker-compose up -d --no-deps db && docker-compose up -d --no-deps web

For testing the mobile app standalone, navigate to services/frontend/mobile/ and run: $ yarn start (This may be easier depending on your comfort with docker) Otherwise acces the docker-compose logs ($ docker-compose logs -f) and scan the expo QR code from your device

  1. In browser navigate to: http://localhost:5000/ or http://127.0.0.1:5000/

Backend Requirements:

Docker and docker-compose must be installed

  1. Install docker - navigate to your Operating System and follow instructions
  2. Install docker-compose - Same as above, find OS and follow instructions

Frontend Requirements:

Either run docker-compose as in backend, or to run the frontend mobile app standalone:

  1. Install node -
  2. Install expo CLI - $ npm install -g expo-cli
  3. Install yarn - $ npm install yarn

Once you have yarn installed use "yarn add <package name>" for all new package isntallations.

API routes:

/login - Method: [POST] parses JSON:- username, password

/register - Method: [POST] parses JSON:- username, email, password

/api/floorplan - Method [GET] returns floorplan.png image

/api/devices - Method [GET] returns JSON:- devicename, deviceroom, devicestatus

Useful commands:

Custom CLI command:

Example of running custom CLI command create_db (look inside services/web/manage.py): $ docker-compose exec web python manage.py create_db Run seed_db to populate db (both create_db and seed_db are managed by entrypoint.sh) $ docker-compose exec web python manage.py seed_db

Some postgres stuff:

// shell command to open connection to db
$ docker-compose exec db psql --username=envirohome_db --dbname=envirohome_db_dev

psql (12.0)
Type "help" for help.

// List databases
envirohome_db_dev=# \l
                                        List of databases
      Name       |    Owner    | Encoding |  Collate   |   Ctype    |      Access privileges
-----------------+-------------+----------+------------+------------+-----------------------------
 envirohome_db_dev | envirohome_db | UTF8     | en_US.utf8 | en_US.utf8 |
 postgres        | envirohome_db | UTF8     | en_US.utf8 | en_US.utf8 |
 template0       | envirohome_db | UTF8     | en_US.utf8 | en_US.utf8 | =c/envirohome_db             +
                 |             |          |            |            | envirohome_db=CTc/envirohome_db
 template1       | envirohome_db | UTF8     | en_US.utf8 | en_US.utf8 | =c/envirohome_db             +
                 |             |          |            |            | envirohome_db=CTc/envirohome_db
(4 rows)

// Select database
envirohome_db_dev=# \c envirohome_db_dev
You are now connected to database "envirohome_db_dev" as user "envirohome_db".

// View database relations
envirohome_db_dev=# \dt
          List of relations
 Schema | Name | Type  |    Owner
--------+------+-------+-------------
 public | user | table | envirohome_db
(1 row)

// Run basic sql here (for testing only)
envirohome_db_dev=# select * from users;
 id | username |         email          |    password_hash    | active
----+----------+------------------------+---------------------+--------
  1 | admin    | [email protected] | totally a real hash | t
(1 row)

// Quit database
envirohome_db_dev=# \q

Contributing

Comments

To add comments so that they can be read by the documentation tool Doxygen, use the following format (Python):


			## @package pyexample
			#  Documentation for this module.
			#
			#  More details.

			## Documentation for a function.
			#
			#  More details.
			def func():
				pass

			## Documentation for a class.
			#
			#  More details.
			class PyClass:

				## The constructor.
				def __init__(self):
					self._memVar = 0;

				## Documentation for a method.
				#  @param self The object pointer.
				def PyMethod(self):
					pass

				## A class variable.
				classVar = 0;

				## @var _memVar
				#  a member variable

Special commands can be used within comment blocks to automatically document certain areas of code. Use a backslash () for these special commands.

For example:

			## @package init.py
			#
			# \brief     briefly describe the file / method / class, etc
			# \details   add further details here
			# \author    Tannick Rose
			# \version   version number
			# \date      2020
			# \bug       
			# \copyright MIT License.
			#

To contribute to this project:

  1. Clone the repo locally
  2. Commit your code to a separate branch
  3. Open a pull request.

Frequently Asked Questions and Troubleshooting

See our troubleshooting guide to find answers to some common questions about the project, as well as some ideas to troubleshoot any problems.

Support

Major versions of this project are supported for six months from the date of release. The table below outlines the end of support dates for all major versions, and the last minor version for each version.

Major Version Last Minor Version End of Support Date
1 1.0 N/A

If you are opening an issue for this project, please mention the version which the issue relates to.

License

Developed under the MIT License.

Copyright (c) 2020 Tanich Rose

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

envirohome_simulator's People

Contributors

friedforfun avatar callum-stewart avatar harris-adnan avatar

Watchers

 avatar Ryan avatar

envirohome_simulator's Issues

Validate Route URL

Validate Route, make sure device, ect exists in db before attempting to return it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.