jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
879 stars 159 forks source link

Returning none #360

Closed Dhruveshp closed 1 year ago

Dhruveshp commented 1 year ago

I am trying get_status and it always returns None.

Updated latest version Python 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information.

import tinytuya print(tinytuya.version) 1.12.8

import tinytuya

deviceID = 'xxxxxxxxxxxxxxx' ipAddress = "10.0.0.9" local_key = "xxxxxxxxxxxxxx"

d = tinytuya.OutletDevice(deviceID, ipAddress, local_key, 'device22') d.set_version(3.3) d.set_dpsUsed({"1": None}) data = d.status()

print('Dictionary %r' % data)

jasonacox commented 1 year ago

Do you get anything with:

python3 -m tinytuya scan

Also, I recommend you try using without specifying device22 and turning on debug:

import tinytuya

tinytuya.set_debug(True)

d = tinytuya.OutletDevice(
      dev_id=DEVICEID,
      address=DEVICEIP,
      local_key=DEVICEKEY,
      version=3.3)
print(d)

print(" > Fetch Status < ")
data = d.status()
print(data)
jasonacox commented 1 year ago

Thanks @Dhruveshp

Can you run the wizard to get the local key file (devices.json)? It would be interesting to see the DPS values this device supports.

python -m tinytuya wizard

I may also suggest try having it determine the DPS values:

import tinytuya

tinytuya.set_debug(True)

d = tinytuya.OutletDevice(
      dev_id=DEVICEID,
      address=DEVICEIP,
      local_key=DEVICEKEY,
      version=3.3)
print(d)

print(d.detect_available_dps())

print(" > Fetch Status < ")
data = d.status()
print(data)
Dhruveshp commented 1 year ago

I am able to set the value to RGB value after running the wizard.

Thank you for your support @jasonacox