The sonas_api.py is a python script to control the remote switch.
To call the switch (when in DIY mode - see below)
python sonos_api.py <IPADDRESS> <deviceID> <ON:OFF:CONF>
The first step is to set the device into DIY Mode allowing you to directly control the device.
https://sonoff.tech/sonoff-diy-developer-documentation-basicr3-rfr3-mini-http-api/
- Power on the Sonoff Mini R2.
- Long press the button on the device for approximately 5 seconds.
- The Wi-Fi LED indicator should change to a cycle of two short flashes and one long flash.
- Release the button.
- Find the Access Point (AP) named "ITead-XXXXXXXX" in your phone or computer's Wi-Fi settings.
- Connect to the AP using the default password: "12345678".
- Accessing the DIY Webpage:
- Open a web browser on your phone or computer.
- Type the IP address http://10.10.7.1/ into the browser's address bar.
- On the DIY webpage, you'll find the Wi-Fi settings.
- Enter your desired Wi-Fi SSID (network name) and password.
- The device will then connect to your Wi-Fi network.
- Once connected to your Wi-Fi, the Sonoff Mini R2 is in DIY mode, allowing you to control it via HTTP commands or integrate it with other home automation platforms.
- You need to find the IP Address of the Device
You need to know the IP Address and Device ID to access the device.
http://192.168.3.180:8081/zeroconf/info
{
"deviceid": "1002431fd5",
"data": {
}
}
Response
{
"seq": 4,
"error": 0,
"data": {
"switch": "off",
"startup": "off",
"pulse": "off",
"pulseWidth": 500,
"ssid": "HUAWEI-WHAKA",
"otaUnlock": false,
"fwVersion": "3.8.0",
"deviceid": "1002431fd5",
"bssid": "88:81:b9:8f:d6:4",
"signalStrength": -55
}
}
http://192.168.3.180:8081/zeroconf/switch
{
"deviceid": "1002431fd5",
"data": {
"switch": "on"
}
}
Response
{
"seq": 3,
"error": 0
}
http://192.168.3.180:8081/zeroconf/switch
{
"deviceid": "1002431fd5",
"data": {
"switch": "off"
}
}
Response
{
"seq": 3,
"error": 0
}