Skip to content

Commit 3855446

Browse files
committed
Merge branch 'master' of github.com:codetheweb/tuya-device
2 parents 710e78d + 8d56dfe commit 3855446

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

docs/SETUP.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,81 @@ Setup
3939

4040
## Android
4141

42+
43+
### Capture https traffic
44+
4245
Only requires an Android device. Root not required, this captures the stream from the Android application to the Jinvoo/Tuya web servers. It does NOT capture between Android device and remote control device.
4346

4447
1) Remove registration for existing device if present
4548

4649
2) Install "Packet Capture" https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture (follow instructions, install cert, then start capturing, its possibly to use the green triangle/play button with a "1" on it to only capture from the Jinvoo app).
4750

48-
3) Run Jinvoo Smart App to (re-)add device.
51+
3) Run Jinvoo Smart App (https://play.google.com/store/apps/details?id=com.xenon.jinvoo version 1.0.3 known to work) to (re-)add device.
4952

5053
4) Hit stop button back in "Packet Capture" app.
5154

5255
5) review captured packets (first or last large one, 9Kb of 16Kb) use macOS step 11 for guide.
56+
57+
### Extract details from android config file
58+
59+
60+
#### Smart Life App
61+
From https://github.com/codetheweb/tuyapi/issues/5#issuecomment-352932467
62+
63+
If you have a rooted Android phone, you can retrieve the settings from the app (Smart Life) data storage. The keys/configured devices are located at /data/data/com.tuya.smartlife/shared_prefs/dev_data_storage.xml
64+
65+
There's a string in there (the only data) called "tuya_data". You need to html entity decode the string and it contains a JSON string (yes, this is slightly ridiculous). Inside the JSON string are the keys.
66+
67+
#### Jinvoo Smart App
68+
69+
The Jinvoo SMart app is similar to the Smart Life app but has a slightly different location. `/data/data/com.xenon.jinvoo/shared_prefs/gw_storage.xml`. Python script to dump out the information along with useful schema information:
70+
71+
#!/usr/bin/env python
72+
# -*- coding: us-ascii -*-
73+
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
74+
#
75+
76+
import codecs
77+
import os
78+
import json
79+
import xml.etree.ElementTree as ET
80+
81+
try:
82+
# Python 2.6-2.7
83+
from HTMLParser import HTMLParser
84+
except ImportError:
85+
# Python 3
86+
from html.parser import HTMLParser ## FIXME use html.unescape()?
87+
88+
89+
xml_in_filename = 'com.xenon.jinvoo/shared_prefs/gw_storage.xml'
90+
h = open(xml_in_filename, 'r')
91+
xml = h.read()
92+
h.close()
93+
94+
builder = ET.XMLTreeBuilder()
95+
builder.feed(xml)
96+
tree = builder.close()
97+
98+
99+
h = HTMLParser()
100+
for entry in tree.findall('string'):
101+
if entry.get('name') == 'gw_dev':
102+
# found it, need content
103+
config = entry.text
104+
s = h.unescape(config)
105+
config_dict = json.loads(s)
106+
#print(config_dict)
107+
print(len(config_dict))
108+
for device in config_dict:
109+
#print(device)
110+
for key in ['name', 'localKey', 'uuid', 'gwType', 'verSw', 'iconUrl']: # and/or 'gwId', 'devId'
111+
print('%s = %r' % (key, device[key]))
112+
# there is a bunch of interesting meta data about the device
113+
print('schema =\\')
114+
schema = device['devices'][0]['schema'] # NOTE I've only seen single entries
115+
schema = h.unescape(schema)
116+
schema_dict = json.loads(schema)
117+
print(json.dumps(schema_dict, indent=4))
118+
print('')
119+
print(json.dumps(config_dict, indent=4))

0 commit comments

Comments
 (0)