Git Product home page Git Product logo

sonoff-server's Introduction

Sonoff-Server

PHP based implementation of Sonoff cloud server, running in your own home network. You can control your Sonoff switches without need of changing basic firmware.

Supported devices

In theory all Sonoff devices are supported. But for now, only "Sonoff Basic" will work fine. Please send me LOG file if you want to add support of any other Sonoff device.

Requirements

  1. Linux based server (Raspberry PI or any generic modern Linux)
  2. PHP 7.x (but PHP 5.x should also be ok) with composer dependency manager (https://getcomposer.org/)

Installation

  1. Create directory for Sonoff Server
pi$ mkdir ~/phpSonoff
  1. Install required libs via PHP composer
pi$ cd ~/phpSonoff
pi$ composer require workerman/workerman workerman/channel
  1. Download Sonoff Server software
pi$ git clone https://github.com/vponomarev/Sonoff-Server.git
pi$ mv Sonoff-Server/* .
pi$ rm -rf Sonoff-Server/
  1. Create your own SSL certificates (you can also use self signed from this package)

  2. Edit configuration section in sonoffServer.php file

Running

Run server using:

pi$ php ./sonoffServer.php start -d

WEB GUI can be accessed via:

https://<serverIP>:<configPort>/

WEB GUI example:

API

  1. List of connected devices:
https://<serverIP>:<configPort>/api/get

Returns JSON array with connected devices, example:

[{"apikey":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","deviceid":"10000xxxxx","model":"ITA-GZ1-GL","lastUpdate":2572,"lastSeen":15,"rssi":-67,"state":"off"}]
  1. Update state request:
https://<serverIP>:<configPort>/api/set?apikey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&state=off

Where: apikey - Device API Key state - new state ("on" or "off")

Return JSON array with result:

{"connID":26,"error":0,"state":"off"}

Where: error - error code, 0 is "ok" state - new state

Configuring Sonoff

First, you need to configure your device via eWeLink software (there is also an alternative way, i'll explain it later).

On startup each Sonoff device send HTTPS POST request to configuration server (eu-disp.coolkit.cc). You can reroute this requests into configuration page of Sonoff-Server using your home router.

sonoff-server's People

Contributors

vponomarev avatar

Watchers

James Cloos 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.