Tuya wifi light switch SM-SW102U

Hi Everyone,

I have just bought a 2 gang light switch from Aliexpress (https://bit.ly/2qirAM8). It’s model number is SM-SW102U.

Blockquote https://fccid.io/2AJ5F-SM-PW701U/Letter/Model-Differences-Description-3200194/ is documentation from Xenon to the FCC declaring “models SM-PW701U, SM-PW702, SM-SW801, SM-SW102, SM-S0301, SM-PZ701, SM-PZ702, SW-SZ801, SM-SZ202, and SM-SZ301 contain identical circuitry”.

I thought that I would easily get this up and running using the existing Tuya work that has been done. https://github.com/sean6541/tuya-homeassistant / GitHub - clach04/python-tuya: Python interface to ESP8266MOD WiFi smart devices from Shenzhen Xenon. NOTE I'm not using any devices with this library so I can't test :-(

Unfortunately, the tuya protocol on this switch seems to be slightly different. I have used WireShark whilst registering the device and the packets are different. See below:

POST /gw.json?a=s.gw.token.get&gwId=01200950ecfabc795eb3&other={“token”:“7wBxo260”,“region”:“AZ”,“tlinkStat”:{“configure”:“smartconfig”,“time”:6,“source”:“station”,“path”:“multicast”}}&t=7&v=3.0&sign=cd5c887908064c32c8f8185ac32ffbf5 HTTP/1.1

POST /gw.json?a=s.gw.dev.pk.active&gwId=01200950ecfabc795eb3&other={“token”:“7wBxo260”}&t=1523597921&v=3.0&sign=84da2c27ddbf551ec2f0938c0790c7d6 HTTP/1.1 (application/x-www-form-urlencoded)

POST /gw.json?a=s.gw.update&gwId=01200950ecfabc795eb3&t=1523598924&v=2.0&sign=01468796fe75f6b66f2e5a8e67533349 HTTP/1.1 (application/x-www-form-urlencoded)

POST /gw.json?a=atop.online.debug.log&gwId=01200950ecfabc795eb3&t=1523578928&sign=56d0cf5a79efac8fc4fde30f7a4740e5 HTTP/1.1 (application/x-www-form-urlencoded)strong text

POST /gw.json?a=s.gw.dev.timer.count&gwId=01200950ecfabc795eb3&t=1523578939&sign=dc95e227bbd7bd6ca5036e1c68cd99f4 HTTP/1.1 (application/x-www-form-urlencoded)

The code to implement https://github.com/sean6541/tuya-homeassistant looks like the below:

switch:

  • platform: tuya
    host: xxx.xxx.xxx.xxx
    local_key: xxxxxxxxxxxxxxxx
    device_id: xxxxxxxxxxxxxxxxxxxx
    switches:
    switch1:
    friendly_name: Switch 1
    id: 1
    switch2:
    friendly_name: Switch 2
    id: 2
    switch3:
    friendly_name: Switch 3
    id: 3
    switch4:
    friendly_name: Switch 4
    id: 4

I now know the host, device_id, but cannot seem to identify to the local_key from what I have from WireShark.

Has anyone got one of these working? Or could make some suggestions it would be greatly appreciated!

Fastrax

im also struggling to find the local key, iv tried all the different apps (three of then) a custom apk i found on github, port forwarded etc… Even a specific version of one of the apps but nothing.

iv done a bit of research on this and stil struggling, your packets return alot more than mine do! Most of them are empty. Iv just read that you can only connect with one device/app at a time. So might be worth uninstalling all the default apps

Im using a plug socket.

I have gone through the same thing! I have tried all three apps Jinvoo, eFamilyCloud and Tuya.

Mine is a wall light switch. I’ve had a further play today but still not working.

05-19 20:46:39.707 17272 28787 I ReactNativeJS: Running application “TYRCTApp” with appParams: {“initialProps”:{“devInfo”:{“isShare”:false,“panelConfig”:{“bic”:“[{"code":"timer","selected":true}]”},“isLocalOnline”:true,“bv”:“5.12”,“verSw”:“1.2.0”,“isOnline”:true,“uiPhase”:“release”,“isVDevice”:false,“dps”:{“1”:false,“2”:false},“schema”:{“1”:{“type”:“obj”,“name”:“Wall Switch 1”,“mode”:“rw”,“code”:“switch_1”,“id”:“1”,“schemaType”:“bool”,“iconname”:null,“property”:“{"type":"bool"}”},“2”:{“type”:“obj”,“name”:“Õ╝ÇÕà│2”,“mode”:“rw”,“code”:“switch_2”,“id”:“2”,“schemaType”:“bool”,“iconname”:null,“property”:“{"type":"bool"}”}},“productId”:“At6C3S6JYzp4ez1T”,“nodeId”:“”,“ability”:0,“ui”:“00000001xx_1.2.3”,“uiConfig”:{},“gwId”:“01200950ecfabc875eb3”,“networkType”:“WIFI”,“t”:1526719598,“icon”:“https://images.tuyacn.com/smart/icon/1478860503_0.jpeg",“name”:"Wall Switch “,“uiId”:“00000001xx”,“pcc”:””,“isUniversalPanel”:false,“devId”:“01200950ecfabc875eb3”}},“rootTag”:1}. DEV === false, development-level warning are OFF, performance optimizations are ON

Running adb logcat and having my phone in developer mode, it has provided the above. Still none the closer… unless “t” is a token?

Possibly, but the token will change with each session! It can be done mate, we’ll just have to wait for the experts to pipe up tho!

You could try digging around on the device. It should be stored there somewhere if it’s able to communicate with the device. Here’s what I did for an older version https://github.com/codetheweb/tuyapi/issues/5#issuecomment-352932467

That thread also has some other useful notes

Yeh seen that.

I’m using an old app and literally just went through most files in the installed apk using file es and didn’t find it.

Found the developers email address tho… Ha

If you’re rooted I’d just do a grep -rni from the root filesystem (/) for the gwId since you have that and the key is probably stored in the same place. Which app are you using?

Are these ESP8266 based? If so, it just seems easier to flash them?

I’m not rooted, Iv used all three aswell.

Jinvoo, eFamilyCloud and Tuya

I finally finally got it working. It was using the earlier version of the Jinvoo app provided here:

https://github.com/clach04/python-tuya/wiki/bin/Jinvoo%20Smart%201.0.3.apk

I used ADB logcat, and there she was for the first time. The infamous localkey. Lights are all up and running! Hurray!

Adb logcat?

What instructions did you follow mate?

i have set up adm loggin via my phone now and just ran adb locat whilst running the older 1.03 jinvoo app.

i can see stuff around Tuya and my device id, i just cant find the local id!

BOOOM!

Removed the device, started again and iv found it!!

For info

My config isnt working in HA now… haha

heres what iv tried, i can see the switch in ha but its not doing anything… have you still got the app on your phone, or did you uninstall it?

switch sub:
  - platform: tuya
    name: subwoofer
    host: 192.168.0.55
    local_key: 
    device_id: 
    switches:
      subwoofer:
        id: 1
switch tuys:
  - platform: tuya
    name: tuya test
    host: '192.168.0.55'
    local_key: ' '
    device_id: ' '
    id: 1

Fixed it. I’d forgotten to remove one of the many apps I’d installed trying to get the key

1 Like

These don’t have any visible headers for a serial connection inside (my Voion was glued together) and I haven’t seen anyone develop a way to hijack OTA firmware update

Not as easy as the Sonoff ones