Tuya WiFi Smart Plug: Difference between revisions
| Line 19: | Line 19: | ||
{u'devId': u'02200194dc4f22137d7f', u'dps': { | {u'devId': u'02200194dc4f22137d7f', u'dps': { | ||
u'1': True, outlet status | u'1': True, outlet status | ||
u'2': 0, | u'2': 0, timer, decrements by 5, in seconds | ||
u'5': 56, watts (5.6) | u'5': 56, watts (5.6) | ||
u'4': 73, amps (0.073 amps) | u'4': 73, amps (0.073 amps) | ||
Revision as of 05:53, 5 December 2018
To talk to the device, you need 3 things:
- The device IP address
- UUID / Device ID
- localKey
You can get this by sniffing the traffic the Android app makes with a SSL Capture app. When adding a new plug, some of the requests should contain something about a 'localKey'. One of the requests should also return all devices as well as their corresponding localKey from their server.
Self Hosted
It looks like the plug currently talks with
- mq.gw.tuyaus.com via MQTT
- a1.tuyaus.com via HTTP
The localKey seems to change every time the device is reconnected to the cloud.
tuya python
The status output from the AWP04L smart plug looks like this. The plug has monitoring features and should return the voltage, amps, and watts.
{u'devId': u'02200194dc4f22137d7f', u'dps': {
u'1': True, outlet status
u'2': 0, timer, decrements by 5, in seconds
u'5': 56, watts (5.6)
u'4': 73, amps (0.073 amps)
u'6': 1198 volts
}}
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0, u'5': 187, u'4': 176, u'6': 1190}}
I don't understand why amps * volts != watts...
You will probably still need to allow it to connect to the cloud once. If you don't let it completely connect, some features like voltage/wattage are disabled from the output (?). MQTT must be working, or else these features are disabled:
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0}}
>>> x.status()
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0}}
>>> x.status()
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0}}
>>> x.status()
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0, u'5': 0, u'4': 0, u'6': 1184}}
>>> x.status()
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0, u'5': 0, u'4': 0, u'6': 1184}}
>>> x.status()
{u'devId': u'02200194dc4f22135606', u'dps': {u'1': True, u'2': 0, u'5': 0, u'4': 0, u'6': 1184}}