Tuya WiFi Smart Plug: Difference between revisions
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
* mq.gw.tuyaus.com via MQTT | * mq.gw.tuyaus.com via MQTT | ||
* a1.tuyaus.com via HTTP | * a1.tuyaus.com via HTTP | ||
The localKey seems to change every time the device is reconnected to the cloud. | The localKey seems to change every time the device is reconnected to the cloud. | ||
| Line 18: | Line 16: | ||
The status output from the AWP04L smart plug looks like this. The plug has monitoring features and should return the voltage and amperage (hence the calculated wattage). | The status output from the AWP04L smart plug looks like this. The plug has monitoring features and should return the voltage and amperage (hence the calculated wattage). | ||
{{highlight|lang=text|code= | {{highlight|lang=text|code=<nowiki> | ||
{u'devId': u'02200194dc4f22137d7f', u'dps': { | {u'devId': u'02200194dc4f22137d7f', u'dps': { | ||
u'1': True, outlet status | u'1': True, outlet status | ||
| Line 25: | Line 23: | ||
u'4': 73, amps (0.073 amps) | u'4': 73, amps (0.073 amps) | ||
u'6': 1198 volts | u'6': 1198 volts | ||
}}</nowiki> | |||
}} | }} | ||
<s>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 (?).</s> MQTT must be working, or else these features are disabled: | |||
{{highlight|lang=text|code=<nowiki> | |||
{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}}</nowiki> | |||
}} | }} | ||
== See Also == | == See Also == | ||
* https://github.com/clach04/python-tuya | * https://github.com/clach04/python-tuya | ||
* https://github.com/clach04/python-tuya/wiki | * https://github.com/clach04/python-tuya/wiki | ||
Revision as of 05:43, 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 and amperage (hence the calculated wattage).
{u'devId': u'02200194dc4f22137d7f', u'dps': {
u'1': True, outlet status
u'2': 0, ??
u'5': 56, watts (5.6)
u'4': 73, amps (0.073 amps)
u'6': 1198 volts
}}
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}}