Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Chipsets? #4

Open
hpnotiqballin opened this issue Mar 9, 2020 · 18 comments
Open

New Chipsets? #4

hpnotiqballin opened this issue Mar 9, 2020 · 18 comments

Comments

@hpnotiqballin
Copy link

You still working this at all? It would appear that the new chipsets still use Tuya, but have had some tweaks done. Your script doesn't do any of the discovery on my grill, and I just ran a PCAP on the device while using - it still broadcasts to port 6667, but app control is now going to/from 35.161.158.54:8886 using TLSv1.2. I cannot seem to get ahold of any of the IDs I need to get this working again, or the encryption keys, and I don't have alot of experience with how Tuya operates.

@SDNick484
Copy link
Owner

Hey, sorry for the delayed response. Yes, I recently took this up again. If you're seeing TLS traffic on port 6667, you definitely have a newer chip. The good news is that pytuya is compatible with it (you just need to specify version 3.3). The discover_devices script won't work for it, and I unfortunately don't have a newer device to try to test and update it. Anyways, you may want to check the other Issue on this project around HomeAssistant integratio as at least one of the folks there has your chipset. We also confirmed there that the tuyapi method of linking and connecting works too.

If you have an Android device, I'll be posting steps on the Wiki around extracting device ID and key from the application (note: will require root on the device).

@hpnotiqballin
Copy link
Author

hpnotiqballin commented Mar 22, 2020 via email

@SDNick484
Copy link
Owner

@hpnotiqballin, can you try seeing if this script from the tuya-convert project allows you to see traffic? It's a more refined version of the discover_devices.py that I include and it seems to support devices on the newer firmware. I needed to install the python Cryptodome module to run it.

I've also discovered that wireless UDP multicast can be problematic. My new laptop for example can't see those packets (still debugging why) when on WiFi. Switching to a wired link solves this for me.

@hpnotiqballin
Copy link
Author

That appears to have worked. Output (values masked by me):
Listening for Tuya broadcast on UDP 6666
Listening for encrypted Tuya broadcast on UDP 6667
192.168.3.129 {"ip":"192.168.3.129","gwId":"xxxxxxx","active":2,"ability":0,"mode":0,"encrypt":true,"productKey":"xxxxxxxxx","version":"3.3"}

@hpnotiqballin
Copy link
Author

I just tried plugging the gwId and productKey from that output into your rectec_status script and it runs for about 5secs before giving a socket timeout error.

Traceback (most recent call last):
File "/home/dane/rectec_status/rectec_state.py", line 6, in
data = d.status()
File "/home/dane/.local/lib/python3.6/site-packages/pytuya/init.py", line 281, in status
data = self._send_receive(payload)
File "/home/dane/.local/lib/python3.6/site-packages/pytuya/init.py", line 179, in _send_receive
data = s.recv(1024)
socket.timeout: timed out

@SDNick484
Copy link
Owner

From the output above you'll want your ip and the gwID. The productKey isn't the key from my script; I'm not 100% sure what it's use for, but I do see a couple devices on my network have the same one. The actual key is the one you'd need to extract from the Rectec app. If you're just interested in checking the temperatures, you don't need it.

Now a secondary issue is we need to figure out how to specify to use the newer pytuya code since you're on 3.3 firmware. Let me try a couple things. I found out I have some other Tuya devices on 3.3 that I didn't know about. It's not a Rectec, but I should be able to use it for some testing.

@SDNick484
Copy link
Owner

Could you try running the following (required Node and tuya-cli which is available in npm):
tuya-cli get --ip <your_ID> --id <your_gwID> --key aaaaaaaaaaaaaaaa --protocol-version 3.3 -a

For the key, the value doesn't matter, just the length.

@hpnotiqballin
Copy link
Author

hpnotiqballin commented Mar 26, 2020 via email

@SDNick484
Copy link
Owner

Ha, yeah, I know the feeling. I had updated my router to a more recent OpenWRT build yesterday to set up udpxy and it was a race against the clock before my kids woke up.

@hpnotiqballin
Copy link
Author

Ran it, returned an error within the tuya-cli code:
/usr/local/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/create.js:101
got.paginate = async function* (url, options) {
^

SyntaxError: Unexpected token *
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/index.js:7:18)

@hpnotiqballin
Copy link
Author

As far as interests go, control would be great - but I would also happily settle for being able to pull temperatures. The app sucks, and I would love to automate alarms within my Alexa ecosystem (through my Hubitat, which is rather simple once I can get something pulling temps periodically and reporting them locally)

@SDNick484
Copy link
Owner

okay, one more thing to try, this requires tuyapi (npm install codetheweb/tuyapi):

const TuyAPI = require('tuyapi');

const device = new TuyAPI({
  ip: '<IP>',
  id: '<gwID>',
  key: 'aaaaaaaaaaaaaaaa',
  version: 3.3});

(async () => {
  await device.find();

  await device.connect();

  let status = await device.get({
    schema: true
  });

  console.log('Current status:');
  console.log(status);

  device.disconnect();
})();

@SDNick484
Copy link
Owner

If this fails, then I suspect you'll need to extract the key either using the steps I provide on the wiki from the Android app or by registering a tuya account (note: you won't be able to use the Rectec app if you go this route although you can swap back if needed but that resets the key).

How do you like Hubitat? I'm currently on the Smartthings ecosystem and have started playing around with HomeAssistant (see other thread), but the Hubitat sounds very promising.

@hpnotiqballin
Copy link
Author

No dice, it outputs a jibberish string of wingdings. Also, I tried to capture the key before (via making a dev acct with Tuya), but that didn't work at all (just sat there spinning).

Regarding Hubitat, I absolutely love it. I switched from SmartThings about 6mts ago, and I haven't looked back. There's a bit of a learning curve, but it is so much more capable than SmartThings and offers a TON more functionality (including an open API, which is a ton of fun to play with).

I made a BLE scanner for it with a Pi, that now accurately and reliably (and locally) detects my vehicles coming and going, and performs actions based on that.

@SDNick484
Copy link
Owner

I suggest perhaps retrying the Tuya account registration process. I know they were having problems earlier in the year, but it deinitely worked for me as well as @impala454 who has a model on the newer Tuya firmware that's encrypted. Otherwise, the Android route works but requires a rooted device. Might be doable in an Android emulator, but I haven't tried yet.

@impala454
Copy link

Hi @hpnotiqballin , as @SDNick484 I have the newer firmware and the registering a tuya account thing did work for me. I incorporated my grill into node red and documented the process I took here: https://gitlab.com/cclaunch/rectec-node-red .

@SDNick484
Copy link
Owner

@hpnotiqballin Have you been able to get your localkey (either from the Rectec app or registering)? If so, I can post a build that I think will support either 3.1 (old firmware protocol) or 3.3 (new TLS one). Unfortunately on the newer one, you need the key for any functionality whereas on the older one, you only needed it to change state, not monitor.

@hpnotiqballin
Copy link
Author

hpnotiqballin commented Apr 3, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants