Skip to content

annabadsi/escapehome

Repository files navigation

EscapeHome

Escape Room game for your own home with Smart Home devices. Create your own scenario with your Smart Home devices to play with your friends at home!

Alexa is used to communicate with the players. An Alexa Skill was created for this purpose. This skill receives instructions via our program, which was deployed on a pythonanywhere server. A Raspberry PI is connected to the Smart Home devices and asks the server for new events. If one occurs, it forwards the steps to the respective Smart Home devices. Previously, ceiling lamps and blinds were connected via KNX, Philips Hue lamps via Zigbee and a box via Modbus. This box serves to lock the room key at the beginning of the game and release it again at the end.

README Table of Contents

Pythonanywhere

We deploy at Pythonanywhere in a free account. That make sometimes some struggle. Steps ToDo:

  1. start new bash console (console > oher: bash)
  2. start the virtualenv, after that you see the `(venv) at the beginning.
    source .virtualenvs/venv/bin/activate
  3. set the pythonanywhere settings
    export DJANGO_SETTINGS_MODULE=escapehome.settings.pythonanywhere
  4. get current data:
    git pull
  5. migrate database - can take a few minutes
    cd EscapeHome/escapehome/
    python manage.py migrate

Installation

You can Setup the Project in two Ways:

  • with Docker
  • with a virtual env

Docker

Navigate to the root folder and just type:

make run

This can take a longer time so grab you a coffee ☕

Local setup

If you do not want to use Docker you have to setup by your own

  1. create a virtual env and active
virtualenv venv --python=python3
. venv/bin/activate
# Your terminal should have (venv) in front
  1. install requirements
pip install -r requirements.txt

Quick start

If you want to use docker type export USE=docker in your terminal

Django always need a Server running so type:

make run

If the makefile is broke you can type in:

docker-compose up -d 

or for your local installation

cd escapehome
python manage.py runserver

enviroment varibales to set the Alexa-Skill id go to the projectfolder (escapehome) and add the var ALEXA_APP_ID_escapehome to the new Alexa-Skill ID at the .env file (if you can not see it remember its a hidden file :D )

Endpoints

  1. GET - api/commands

  2. POST - api/cancel
    Body: {"exit_game": "true", "user": "<user_id>"}

Alexa Skill Management

ASK CLI

Alexa Skills Kit Command Line Interface
https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html

get-skill

ask api get-skill -s amzn1.ask.skill.e5c0051e-6fcc-4c73-9a22-9487ee9b0d29 --stage development > escapehome/escapehome/static/skill.json

update-skill

ask api update-skill -s amzn1.ask.skill.e5c0051e-6fcc-4c73-9a22-9487ee9b0d29 --file escapehome/escapehome/static/skill.json --stage development

get-model

ask api get-model -s amzn1.ask.skill.e5c0051e-6fcc-4c73-9a22-9487ee9b0d29 --stage development -l de-DE > escapehome/escapehome/static/model.json

update-model

ask api update-model -s amzn1.ask.skill.e5c0051e-6fcc-4c73-9a22-9487ee9b0d29 -f escapehome/escapehome/static/model.json -l de-DE --stage development

get-skill-status

ask api get-skill-status -s amzn1.ask.skill.e5c0051e-6fcc-4c73-9a22-9487ee9b0d29

Update Custom Slot Types

Copy Relevant Data from DB to Alexa Slot Types
The first time for authentication: ask init --no-browser

Get data from alexa: (only once at the beginning)

  1. make get-model
  2. make get-skill

Transfer data from Django to Alexa:

  1. make update-model
  2. make skill-status

Working locally with Alexa

set up NGROK

  • download ngrok > https://ngrok.com/download
  • start ./ngrok http 8000
  • copy generated URL
    • in Alexa Developer Console > customize endpoints https://<nummer>.ngrok.io/alexa/, note second checkbox
    • add <nummer>.ngrok.io (without https) to ALLOWED_HOSTS in settings common.py
  • start Django (with or without Docker)

transfer data from the dump

  • python manage.py migrate
  • python manage.py shell
  • Enter the following in the shell
    from django.contrib.contenttypes.models import ContentType
    ContentType.objects.all().delete()
  • python manage.py loaddata db_dump.json

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published