The idea was to have a private, locally hosted server to manage all of your own Sonoff devices.
- Before running the server you have to provide certificate for HTTPS. It doesn't have to be a valid certificate, you can create your own self-signed and it would be good enough for Sonoff devices to connect. You can do it via following commands
openssl req -x509 -newkey rsa:2048 -keyout certs/keytmp.pem -out certs/cert.pem -days 365
openssl rsa -in certs/keytmp.pem -out certs/key.pem
- Install all dependencies
npm i
- Put the SonOff/Wemos device in AP mode (press and hold button for 5s)
- Find the device and connect to it (SSID: ITEAD-10000xxxxx Password: 12345678)
- Add route if necessary
sudo route change 0.0.0.0 mask 0.0.0.0 10.10.7.1
- (optional) use httpie to read device info
http http://10.10.7.1/device
. - use httpie to send local WiFi settings to device
http POST http://10.10.7.1/ap version:=4 ssid=[YOUR NETWORK SSID] password=[YOUR NETWORK PASSWORD] serverName=[IP OF YOUR SERVER] port=8080
The device will automatically drop out of AP mode and tries to connect to WiFi and server.
npm run start
- /devices => list off all devices that are currently known to the server.
- /devices/:deviceId => shows the status of the device
- /devices/:deviceId/on => turns the device "on"
- /devices/:deviceId/off => turns the device "off"
This project is based on information from following articles: