SonoffPost is used to operate Sonoff switches without usin the eWeLink app. Ths allows for manual or automated operation of devices without using the phone. It is a VB6 Windows program with parameters and inputs Standard calling: SonoffPost Deviceid Request EG SonoffPost 10006006f on This will turn the device on. Parameters DeviceId: the eWelink deviceID [from Settings in the eWelink app]. Request [optional]: can be: on, off, info or omitted on: turn the device on off: turn the device off info: return a file, SonoffPost.log with device details if omitted it checks the status of the device Return code: 0: the device is off 1: the device is on 5: there is an error 10: the device is not responding When switching on and off the program checks that the action succeeded and returns the current state, if it failed it returns 5 Note: Sonoff Basic R3 is a 4 state device. it can be used to detect if a circuit to which it is attached is on or off, as well as detecting devices it feeds are on or off. EG SonoffPost 10006006f This will return error code 10 if the device is powered off, eg all devices on its circuit are off If it returns 1 or 0 then the circuit to which it is attached is active. The 1 or 0 indicates also the state of the output of the Sonoff is on or off, for any devices attached to it. inputs a tokens.txt file [sample included] must reside in the folder of SonoffPost.exe This contains the tokens needed for access and can be created the first time with the following procedure. Obtaining the AT and RT tokens These tokens authenticate the program with the eWeLink cloud and are stored in tokens.txt in the same folder as the executable. They need to be obtained once initially, or again if the file is lost. Requirements: A PC with Firefox or Chrome browser Your eWeLink account email and password Steps: Open Firefox and press F12 to open Developer Tools Click the Network tab Right click in the network request list and enable Persist Logs (Firefox) or tick Preserve Log (Chrome) Navigate to web.ewelink.cc and log in with your eWeLink account In the Network tab filter box type login Click the login request that appears — it will be a POST to something like eu-apia.coolkit.cc Click the Response tab In the response JSON find and copy the values for "at" and "rt" — they are long hexadecimal strings Create tokens.txt in the same folder as the executable with exactly this content: at=paste_at_value_here rt=paste_rt_value_here Notes: The at token expires after approximately 30 days but is refreshed automatically by the program — you should never need to repeat this process The rt token is also automatically refreshed each time at is refreshed The only reason to repeat this process is if tokens.txt is deleted or both tokens have expired due to the program not being run for an extended period Tokens are specific to your eWeLink account and cover all devices on that account All actions are performed via Cloud API which means the device remains fully controllable by all normal means in addition to the program. It also means that the eWeLink will parallel the requested states. A status check (omitting the Request parameter) will return code 10 if the device has no power, effectively confirming whether the circuit it is connected to is active or not. This SonoffPost version is for EU users but may work elsewhere using something different to eu-apia.coolkit.cc Useful links: http://web.ewelink.cc