Skip to content

Requests

Éric Massé edited this page Jan 30, 2018 · 7 revisions

Devices are controlled by MQTT. Use Wireshark to log it, you can set a filter for just MQTT.

Just to explain more of how this works, when you attempt to login you are given:

  • a token
  • A RSA public key
  • An exponent for this key.

You construct the RSA key given and use it to encrypt the MD5(all 128 bits encoded as hex) of your password. This is then padded and then sent on to the server (along with the token). If the login details are correct, you get returned a session ID for use in other mobile requests. Worth noting is the "ecode" and the "p10001" thing that are returned along with the session ID, which you need to login to the MQTT server.

After you login, you should make a call to "tuya.m.device.my.list" to get a list of devices, their uuids and local keys. With this, you can then connect to their MQTT server to issue commands. MQTT login details are of the form:

  • Username: pThing+"_"+appKey+"mb"+sessionID+md5(md5(appKey)+ecode)[8:24]
  • Password: MD5(MD5(appSecret)+ecode)[8:24]