SDNick484 / rectec_status

Scripts to talk to RecTec pellet smokers with WiFi controllers
Apache License 2.0
29 stars 4 forks source link

New Chipsets? #4

Open hpnotiqballin opened 4 years ago

hpnotiqballin commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Awesome, looking forward to new work. I did some testing using PyTuya (made a dev acct, went that route) and the new chip wouldn't connect with my laptop CLI. Not sure what exactly I'm missing.

On Sat, Mar 21, 2020, 9:03 PM SDNick484 notifications@github.com wrote:

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).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SDNick484/rectec_status/issues/4#issuecomment-602129972, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALML34NNGCYZMOPB37CE263RIVPVLANCNFSM4LD645UQ .

SDNick484 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

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

hpnotiqballin commented 4 years ago

Yep, one min - for some reason my ubiquiti gateway decided to take a dump so now I have to remap 3 separate subnets with kids screaming for their tv streamers back...

On Thu, Mar 26, 2020, 7:11 PM SDNick484 notifications@github.com wrote:

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

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SDNick484/rectec_status/issues/4#issuecomment-604733150, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALML34JAKEDV3Z6YRHI2QWDRJPOKBANCNFSM4LD645UQ .

SDNick484 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

Unfortunately not. I wasnt able to get anything through the tuya registration method and haven't gotten the chance to try again

On Fri, Apr 3, 2020, 5:00 PM SDNick484 notifications@github.com wrote:

@hpnotiqballin https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SDNick484/rectec_status/issues/4#issuecomment-608655580, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALML34IRKNCJFYE3SN77HY3RKZE6HANCNFSM4LD645UQ .