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

Response Data: ERROR: Timeout polling device #15

Open
rekked81 opened this issue Jan 27, 2021 · 9 comments
Open

Response Data: ERROR: Timeout polling device #15

rekked81 opened this issue Jan 27, 2021 · 9 comments

Comments

@rekked81
Copy link

rekked81 commented Jan 27, 2021

Howdy,

Managed to follow the tutorial successfully to a T. I have the device IDs, I have the keys after creating an account on iot.tuya.com and running tuyapower. Whenever I try test.py:

python3 test.py <ID>192.168.0.XX <KEY> 3.3
TuyaPower (Tuya Power Stats) [0.1.0] tinytuya [1.1.3]

Device <ID> at 192.168.0.XX key <KEY> protocol 3.3:
    Response Data: ERROR: Timeout polling device
    Switch On: False
    NOTE: Timeout polling device

{ "datetime": "2021-01-27T05:49:15Z", "switch": "False", "power": "0", "current": "0", "voltage": "0" }

I can ping the device, I can see the broadcast messages from the IP address on wireshark from a different PC, I have validated the IP address using the MAC address of the lightbulb (also on Smart Home App). Plug is on. Can't seem to find what I'm doing wrong. I'm new to all this (very new to python) and I have run out of troubleshooting options.

Edit: I have tried this method with two plugs that I know are connected, keys and IDs are known.

Thanks in advance,

@rekked81
Copy link
Author

rekked81 commented Jan 27, 2021

I tried running and forcing version 3.1. The following output makes me think there is payload, but for some reason my raspberry is not handling it correctly:

Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
Unexpected status() payload=b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
TuyaPower (Tuya Power Stats) [0.1.0] tinytuya [1.1.3]

Device <ID> at 192.168.0.XX key <KEY> protocol 3.1:
    Response Data: b'\xc1\x08\xed\xe4\x7f(\xdb\x10\x14\xb1`C_\xea2\x8c\x8f1#4\xc3lO\xd6>\x83\xdf:\xaev!\xb4'
    Switch On: False
    NOTE: Missing Power Data

{ "datetime": "2021-01-27T06:41:51Z", "switch": "False", "power": "0", "current": "0", "voltage": "0" }

This is the payload directly from my wireshark capture running concurrently on my PC:

"\xff\xff\xff\xff\xff\xff\x28\x6d\xcd\x2d\x52\xae\x08\x00\x45\x00" \
"\x00\xc8\x71\x8d\x00\x00\xff\x11\x88\xe7\xc0\xa8\x00\x08\xff\xff" \
"\xff\xff\xc0\x03\x1a\x0b\x00\xb4\xad\x00\x00\x00\x55\xaa\x00\x00" \
"\x00\x00\x00\x00\x00\x13\x00\x00\x00\x9c\x00\x00\x00\x00\x23\xd0" \
"\x1e\x5f\xef\x56\x83\x33\x14\xce\xf6\x0f\xb0\x86\xed\x33\xba\xfa" \
"\x13\x90\xff\xbb\x4a\x53\x9c\x86\x40\x9d\x64\xa3\x20\x86\x42\xf0" \
"\x72\x0f\xe9\xf5\xff\xb1\xe3\xf0\xab\xbe\x90\x57\x63\xf1\x6e\x1a" \
"\x27\x8a\xcd\x30\xef\x89\x57\xfc\x82\xb5\x90\x6f\x5e\x09\xe5\x00" \
"\x9c\xa4\xc2\xb6\x94\x0f\xf0\xc5\x0c\x5e\x49\x48\x15\x9f\x02\xda" \
"\x2d\x7b\xf1\x0b\x10\x28\x4b\x52\x70\xbc\x2b\x6f\xd2\x31\x08\x81" \
"\xbf\x05\xc6\x3a\x2b\x2d\x5d\xd6\xce\x60\xd0\xa5\xe4\x69\xf5\x29" \
"\xfe\x4b\x56\x8d\xb6\x6b\xeb\x01\xf6\x71\x88\x81\xcb\xe5\x49\xd7" \
"\xc0\x4d\x4b\xd0\xe8\x55\x43\x2b\x81\x9c\xbf\x44\x52\xf6\x84\x9b" \
"\x15\x9a\x00\x00\xaa\x55"

@jasonacox
Copy link
Owner

It looks like this is a 3.3 device. Can you see if you can see the device with this:

python -m tinytuya scan

Also, is the Device ID 20 or 22 characters long? There are some 22 character devices that require an extra setting:

import tinytuya

a = tinytuya.OutletDevice('here_is_my_key', '192.168.1.9', 'secret_key_here', 'device22')
a.set_version(3.3)
a.set_dpsUsed({"1": None})
data =  a.status()
print(data)

@rekked81
Copy link
Author

Thanks for the swift reply! I got the following readout:

pi@testpi:~/tuyapower $ python3 test_tinytuya.py
{'dps': {'1': True}, 't': 1611806957}

The IDs have indeed 22 characters. How can I account for this on tuyapower? I see no calls to tinytuya on the test scripts.

@rekked81
Copy link
Author

Found the method on init.py. Switched it as suggested and now it seems to be receiving something:

Device <ID> at 192.168.0.XX key <KEY> protocol 3.3:
    Response Data: {'dps': {'1': True}, 't': 1611807747}
    Switch On: True
    NOTE: Power data unavailable

{ "datetime": "2021-01-28T04:22:28Z", "switch": "True", "power": "0", "current": "0", "voltage": "0" }

It says power data unavailable... I'm wondering if there is anything else I'm missing, I'm going over the documentation right now to see what else I might have skipped. Smart Life does read the power values from these plugs.

@jasonacox
Copy link
Owner

Ok, provided the plug does have energy monitoring (you see wattage etc in the SmartLife app), try sending all of the DPS values you need for that power data:

import tinytuya

a = tinytuya.OutletDevice('here_is_my_key', '192.168.1.9', 'secret_key_here', 'device22')
a.set_version(3.3)
a.set_dpsUsed({'1': None, '2': None, '4': None, '5': None, '6': None})
data =  a.status()
print(data)

Fair warning: Unfortunately I don't have any of these device22 variants so I haven't had an opportunity to do much testing or add enough error handling to work with these non-standard (maybe?) devices. I clearly need to add something for tuyapower to better handle these.

@rekked81
Copy link
Author

Progress! I see the voltage. We're on the right track:

{ "datetime": "2021-01-28T06:03:28Z", "switch": "True", "power": "0.0", "current": "0.0", "voltage": "121.3" }

I'm going to play with the values a bit to see if I can get more values out of the vector and interpret them.

@jasonacox
Copy link
Owner

Ah! Your device may use DSP 18, 19, and 20:

a.set_dpsUsed({'1': None, '2': None, '4': None, '5': None, '6': None,'18': None, '19': None, '20': None})

@rekked81
Copy link
Author

I tried a few different Data Point codes and got a bunch of numbers that I couldn’t make sense of. However, I noticed that the 0’s in codes 5 and 6 match what I’m getting on the app, regardless of whether power is being consumed. I have one of the plugs with my washer and both the app and tinytuya are giving me 0. I tried with a plug that I hadn’t been messing with- accurate values.

I read somewhere that flooding a device with bad requests or using the wrong key can cause the device to malfunction? I’ll try resetting the old device, re-adding it to tuya and deriving new keys to see if that helps.

@jasonacox
Copy link
Owner

That's somewhat good news. It could be a defective device or just in a bad state. A power cycle would be enough to reset the state. You shouldn't need to add it to Tuya again. Now, one thing to keep in mind is that the devices cannot handle more than one thing connecting to them at a time. You can't have the app open and run tinytuya and expect them to work. I suggest power cycling the device. It sound like the first successful code snip above would work for either device.

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

2 participants