Tasmato is one of the great alternative Open source firmware for ESP devices (there may be others which i have not explored yet)
If you have flashed the Sonoff then great other wise there are tons of youtube videos explaining about the same process(i have shared in the reference section), mostly you would need a USB to TTL (Serial Converter)
CH340G USB To TTL(Serial) Converter For Arduino Nano Raspberry Pi you could buy it from Robu.in or amazon.in (in India)
Steps
- Flash the device with tasmota firmware( You have to be carefull otherwise you may brick the device)
- Login to the web interface and configure wifi network for the device
- Once you have an ip then you could use curl or postman or similar to access the API’s
API’s
http://<ip>/cm?cmnd=Power%20TOGGLE
http://<ip>/cm?cmnd=Power%20On
http://<ip>/cm?cmnd=Power%20off
http://<ip>/cm?user=admin&password=joker&cmnd=Power%20Toggle
Using curl
curl http://192.168.1.142/cm?cmnd=POWER+TOGGLE
curl -s http://192.168.1.142/cm?cmnd=STATUS+8 | jq
curl http://192.168.1.142/cm?cmnd=POWER+TOGGLE
{“POWER”:”OFF”}curl -s http://192.168.1.142/cm?cmnd=STATUS+8 | jq
{“StatusSNS”: {“Time”: “2021–11–07T14:42:02”}}
SonOff Tasmato Power Operations
http://192.168.1.142/cm?cmnd=Power On
http://192.168.1.142/cm?cmnd=Power Off
Body {"deviceid": "","data": {"switch": "on/off"}}
JavaScript Function Method
http://192.168.1.142/cm?cmnd=Power Toggle
Body
var address="192.168.29.61";
msg.url=address + "/cm?cmnd=Power "+"Toggle";
return msg;
Reference :