Giter Site home page Giter Site logo

jeedom-push-forward's Introduction

jeedom-push-forward

This project is made to receive Push requests made by Jeedom and forward them to an external API.

It's and must be "agnostic". It receive values from a source (Jeedom) forward them in GET or POST to another API.

Jeedom centralize every modules dedicated to the domotic part. It provide a way to push it's events to an URL.

In order to not lose requests during a network cut or when the external API is broken, the script store the request and send them again when the API answer is ok.

This script was initially developed for Jeedom v4.0.25 with PHP 7.3.9.

Jeedom

First you have to set a "global" push url. This URL must be "internal" to avoid network issues and should point to the www/forward.php script.

To get an "internal" URL we need to setup a new apache2 vhost.

This is an example used on a Jeedom v4.

Listen 8080

<Directory /home/www-data/jeedom-push-forward/www>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

<VirtualHost *:8080>
        DocumentRoot /home/www-data/jeedom-push-forward/www
        ErrorLog /home/www-data/jeedom-push-forward/www/logs/http.error
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

The push URL will be something like http://localhost:8080/forward.php?...

More informations on the Push URL : https://jeedom.github.io/core/fr_FR/administration#tocAnchor-1-9-2

Settings

Use must update the forward.php file to complete the [PUT_YOUR_API_URL_HERE] and if the script must call it in GET or POST.

// Put here the URL of the API on which this script must forward the Jeedom call.
define('API_URL', '[PUT_YOUR_API_URL_HERE]');

// Put here the HTTP verb used to forward the call
// Must be POST or GET
define('API_METHOD', 'POST');

You can add an HASMAC verification for you API. In that case your API will need to share a secret with this script and you will have to set it in API_TOKEN constant.

If you complete this constant the script will add two headers with each request :

  1. X-Request-Timestamp, with the current timestamp (Will allow the API to prevent request replay).
  2. X-Request-Sign, which will allow the API to validate the request.

The signature is an hmac token, created from the string auth:[TIMESTAMP]:[URL] crypted with API_TOKEN.

Debug

If you set a &debug=1 parameter in your URL, the script will log debug informations for the request.

Last info

I made this script for an internal project. It was not designed to be shared so some part of the code could seems useless here. I have some improvment idea but not a lot of time to work on them. Feel free to ask if you want some other things.

jeedom-push-forward's People

Contributors

mwoodgit 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.