jasonacox/tuyapower

ERROR: Incomplete response

Opened this issue · 1 comments

My plug can't quite be read by tuyapower. I think I have the info necessary for my purpose, but I thought I would share what I have anyway.

When running tuyapower.devicePrint(), I get this output:
ERROR: Incomplete response

TuyaPower (Tuya Power Stats) [0.0.25] tinytuya

Device bf3941f72d7e45f9a805hw at 192.168.1.113 key 8dd38d7f9323a97b protocol 3.3
:
    Switch On: False
    Power (W): -99.000000
    Current (mA): -99.000000
    Voltage (V): -99.000000
    Projected usage (kWh):  Day: -2.376000  Week: -16.632000  Month: -72.072000

Running tuyapower.deviceRaw() return no further insight: it returns None.

However, based on what I found in #15 I tried the following script:

a = tinytuya.OutletDevice(PLUGID, PLUGIP, PLUGKEY, 'device22')
a.set_version(3.3)
a.set_dpsUsed({'1': None, '18': None, '19': None, '20': None})
data =  a.status()
print(data)

Now, the response contains all the required info, but formatted in a rather different way:

{
    'dps':  {
        '1': True,     // Switched on
        '18': 494,     // 494 mA
        '19': 995,     // 99.5 W
        '20': 2428     // 242.8 V
     },
     't': 1618440938   // unix timestamp for the moment of the request
}

(newlines and comments added by me)

Thanks for the feedback and detailed investigation. Can you tell me what version of tinytuya you are using?

python -m tinytuya version

I added additional logic starting in tinytuya 1.2.x that tries to auto-detect the device22 condition.

The data you are getting looks good. That is the raw JSON output from the device that TinyTuya polls. TuyaPower simply uses this to display the values in a different format. As you figured out, DPS 19 and 20 return integer values with the least significant value being a floating point (you must divide by 10).