Giter Club home page Giter Club logo

iot_webhook_server's Introduction

IOT Webhook Server

This is a small server which can connect to IOT devices behind NAT routers, in order to send webhooks from the internet to your IOT device. It can be integrated with ifttt.com, in order to automatize your home devices using google home, etc. It is intended for Arduino developers who want an easy solution for home automation. The goal is to be lightweight and simple, without many features.

How to use the server?

User Interface

Once you have the server running, the front page will look the following: welcome page

Next, you have to create an account. I recommend to not use one of your real passwords. It is encrypted in the database, however, if you do not use the https functionality (which is harder to set up), your passwords are not encrypted while transferred to the server. Once you created an account and logged in, there will appear a new tab, called profile. Everything you need happens here.

profile page

In the device list, you can see all devices registered. Devices which are currently connected to the server are marked in green. Below, you can add a new device, by using a unique device name. Further below, you can manually test a webhook.

Sending a webhook to the server

Webhooks are send by a HTTP post request to the URL "/api/webhook". They consists of the fields id and message, encoded as application/URL. The id has to be the registration id of you device. The message is the text you want to send, which is send to your IOT device.

Registering a device at the server

To register a device to the server, you need to connect as a websocket client to the URL "/ws". Once connected, send the JSON object

{
    "username":"<<username>>",
    "password": "<<password>>",
    "object": "<<device name>>"
}

to the websocket server. Then, you are registered and will receive the webhooks.

You can find examples in python and for the ESP8266 in the examples folder.

How to setup the server

Compile

To compile the code, you need the rust 1.4 compiler (newer versions or slightly older ones will probably also work). Use the command cargo build --release to compile the code to a binary. The binary will be located in target/release/iot_webhook_server.

Database

Create a SQLite database and run "database_create_tables.sql" on it, to create the database tables needed for the server.

Create environmental variables

You need to provide the location of your database and the website URL as an environmental variable. The easiest way doing this, is by creating a ".env" file. You can use the following template for your variables:

DATABASE_URL=<<SQL database.db>>
SERVER_URL=<<Server URL and Port>>
USE_HTTPS=<<TRUE or FALSE>>
RSA_KEY=<<only needed for https, path to rsa key>>
CERTIFICATE=<<only needed for https, path to certificate>>

DISCLAIMER

Please note: all code in this repo is released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. We disclaim any and all warranties, either express or implied. We do not warrant that the technology will meet your requirements, that the operation thereof will be uninterrupted or error-free, or that any errors will be corrected.

iot_webhook_server's People

Contributors

benjione avatar

Stargazers

Moritz Makowski avatar  avatar Jan Donnermayer avatar David Mildenberger avatar

Watchers

 avatar

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.