Tasmato API’s for Sonoff devices

Nataraj
2 min readFeb 18, 2022

Tasmato is one of the great alternative Open source firmware for ESP devices (there may be others which i have not explored yet)

Tasmota

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)

CH340G USB to TTL (Serial) Convertor

Steps

  1. Flash the device with tasmota firmware( You have to be carefull otherwise you may brick the device)
  2. Login to the web interface and configure wifi network for the device
  3. 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 :

https://www.youtube.com/watch?v=9fkYBWvwn4A

https://www.youtube.com/watch?v=Xn1PmBLFHIM

--

--