As I am likely done developing on this great little relay, I wanted to write a short post regarding how to interact with it. Of course, it was meant to be used with SmartThings, but it does have a web interface and can be used independently.
Connecting it to your wifi
When power is first applied it creates a wifi AP titled “Sonoff.[MAC address]”. This is for ease and convenience of adding it to your home network. After connecting to the access point with the password “configme”, you browse to 192.168.4.1 and connect it to your wifi access point. At that point it should reboot and obtain an ip address from your network.
SmartThings Service Manager SmartApp
The service manager is designed to pick up after the above step is complete. You install the SmartApp and run its “discover” mode. It will find all the Sonoff switches on your network. It will also display the IP address that the switches obtained so you can connect to their web interface if you desire. Connecting to their web interface is an optional step as the service manager will configure the switch to work with your SmartThings hub.
The web interface has the the following pages:
/advanced (advanced configuration)
/control (relay control)
/update (firmware update)
From here you can do some advanced configuration. You can set a static IP address if you would like. You can also configure a password to use for configuration & firmware update, as well as control. If you do setup a control password here, you must input the password into the device within SmartThings. You can also set the Boot Up state from here, although that can also be configured within SmartThings.
There is also a way to graphically control the relay from the web interface. You can turn it on or off with a click of the mouse.
The username for password protection of the config and the control is: “admin”
On the main page of the device, there is a listing of all the JSON endpoints. Here is a listing of their function.
status: This will return a status of the relay (power) and the switches uptime (uptime).
config: This endpoint is intended to be used by the HA system to send configuration parameters to the switch. You can send the HA hub ip address (haip), communication port, (haport) and “power on state” (pos).
on: Turns the relay on.
off: Turns the relay off.
reboot: Reboots the device
info: Returns the firmware version (version), date (date), and the MAC address (mac) of the device.
Updating the firmware is an extremely simple process. You navigate to /update for the switch you are wanting to update, click and select the bin file you downloaded, and hit the “Update” button.
The latest firmware can be found here: https://github.com/erocm123/SmartThingsPublic/tree/master/devicetypes/erocm123/sonoff-wifi-switch.src
You can reset the devices wifi & network configuration settings by holding the switch down on the device for 10 – 20 seconds. You can reset all of the settings on the device (useful if you forget the configuration password) by holding down the switch for 20 – 60 seconds.
Where to Buy
It just so happens that Itead is having a promotional sale on their products. Click through to this link to get some great smart home gear at up to 20 – 30 % off!