rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
3k stars 565 forks source link

Connection to device succeeded but no datapoints found - Avatto S11 #1231

Open k1llerk3ks opened 1 year ago

k1llerk3ks commented 1 year ago

The problem

I am trying to add a AVATTO WiFi RF IR Sender/Receiver. It's the Avatto S11. Receiving/Sending 433Mhz and Infrared. https://de.aliexpress.com/item/1005003402214245.html

LocalKey and DeviceKey are easily extracted, but i can't seem to do anything working with it. Happy to help with any Debugging!

Environment

Steps to reproduce

  1. Get this device
  2. Extract the Codes from an old version of Smart Life at /data/data/com.tuya.smartlife/shared_prefs
  3. import the tuya device in localtuya

Configuration configuration.yaml or config_flow

Nothing added for this device, just imported from localtuya HA menu

DP dump

INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.10.8 (main, Nov  1 2022, 14:18:21) [GCC 12.2.0] on linux
INFO:localtuya:Using pytuya version '10.0.0'
INFO:localtuya:Detecting list of available DPS of device bf3ee99f807947f31duzf4 [192.168.111.64], protocol 3.3.
DEBUG:localtuya.pytuya:[bf3...zf4] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[bf3...zf4] Sending payload: b'{"gwId":"bf3ee99f807947f31duzf4","devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673542888"}'
DEBUG:localtuya.pytuya:[bf3...zf4] Command 10 waiting for sequence number 1
DEBUG:localtuya.pytuya:[bf3...zf4] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=4294256953, crc_good=True)
DEBUG:localtuya.pytuya:[bf3...zf4] Deciphered data = ''
DEBUG:localtuya.pytuya:[bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
AVAILABLE DPS ARE [{}]
INFO:localtuya:COMPLETE response from device bf3ee99f807947f31duzf4 [192.168.111.64].

**** deviceInfo returned OK ****

TuyaDebug (Tuya DPs dump) [1.0.0]

I found this from /data/data/com.tuya.smartlife/shared_prefs

{"1":true,"17":5,"18":291,"19":98,"20":2373,"21":1,"22":1694,"23":23744,"24":116000,"25":180,"26":0,"9":0}

Provide Home Assistant taceback/logs

Try for v3.3:

2023-01-12 17:25:55.445 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending command 10 (device type: type_0a)
2023-01-12 17:25:55.445 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending payload: b'{"gwId":"bf3ee99f807947f31duzf4","devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673540755"}'
2023-01-12 17:25:55.447 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Command 10 waiting for sequence number 1
2023-01-12 17:25:55.556 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=4294256953, crc_good=True)
2023-01-12 17:25:55.558 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Deciphered data = ''
2023-01-12 17:25:55.558 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
2023-01-12 17:25:55.558 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2023-01-12 17:25:55.558 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Closing connection
2023-01-12 17:25:55.561 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Connection lost: None

Try for v3.2:

2023-01-12 17:27:43.272 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending command 10 (device type: type_0d)
2023-01-12 17:27:43.272 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending payload: b'{"devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673540863","dps":{"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null,"9":null,"10":null}}'
2023-01-12 17:27:43.273 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Command 13 waiting for sequence number 1
2023-01-12 17:27:43.384 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Dispatching message CMD 13 TuyaMessage(seqno=1, cmd=13, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=167825565, crc_good=True)
2023-01-12 17:27:43.385 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Deciphered data = ''
2023-01-12 17:27:43.385 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
2023-01-12 17:27:43.385 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending command 10 (device type: type_0d)
2023-01-12 17:27:43.385 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending payload: b'{"devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673540863","dps":{"1":null,"11":null,"12":null,"13":null,"14":null,"15":null,"16":null,"17":null,"18":null,"19":null,"20":null}}'
2023-01-12 17:27:43.386 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Command 13 waiting for sequence number 2
2023-01-12 17:27:43.397 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Dispatching message CMD 13 TuyaMessage(seqno=2, cmd=13, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=902540808, crc_good=True)
2023-01-12 17:27:43.398 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Deciphered data = ''
2023-01-12 17:27:43.398 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
2023-01-12 17:27:43.398 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending command 10 (device type: type_0d)
2023-01-12 17:27:43.398 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending payload: b'{"devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673540863","dps":{"1":null,"21":null,"22":null,"23":null,"24":null,"25":null,"26":null,"27":null,"28":null,"29":null,"30":null}}'
2023-01-12 17:27:43.398 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Command 13 waiting for sequence number 3
2023-01-12 17:27:43.413 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Dispatching message CMD 13 TuyaMessage(seqno=3, cmd=13, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=2522711620, crc_good=True)
2023-01-12 17:27:43.414 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Deciphered data = ''
2023-01-12 17:27:43.414 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
2023-01-12 17:27:43.415 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending command 10 (device type: type_0d)
2023-01-12 17:27:43.415 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Sending payload: b'{"devId":"bf3ee99f807947f31duzf4","uid":"bf3ee99f807947f31duzf4","t":"1673540863","dps":{"1":null,"100":null,"101":null,"102":null,"103":null,"104":null,"105":null,"106":null,"107":null,"108":null,"109":null,"110":null}}'
2023-01-12 17:27:43.415 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Command 13 waiting for sequence number 4
2023-01-12 17:27:43.429 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Dispatching message CMD 13 TuyaMessage(seqno=4, cmd=13, retcode=1, payload=b'u(\xc1a\xfcI\xe4\xd1G\x9c\xd1\xc5\xab\xfe\xc3;\xdfX\x17\x98W;)\x81Qo\xcb\x1f\x1f\xdf\xcb\xbb', crc=1247630114, crc_good=True)
2023-01-12 17:27:43.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Deciphered data = ''
2023-01-12 17:27:43.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] ERROR Invalid JSON Response from Device - 900 - payload: ""
2023-01-12 17:27:43.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Detected dps: {}
2023-01-12 17:27:43.430 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2023-01-12 17:27:43.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Closing connection
2023-01-12 17:27:43.434 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf3...zf4] Connection lost: None

Additional information

rospogrigio commented 1 year ago

Maybe you should try 3.4?

k1llerk3ks commented 1 year ago

I also tried that, i can add the log for it, too. TinyTuya got me Version 3.3 tho

Unknown v3.3 Device   Product ID = keym4vvjhx4sd9kk  [Valid payload]:
    Address = 192.168.111.64,  Device ID = bf3ee99f807947f31duzf4, Local Key = ,  Version = 3.3, MAC = 
    No Stats for 192.168.111.64: DEVICE KEY required to poll for status

Is it even possible to use a RF/IR Gateway with Localtuya? I'd actually prefer to have it a custom Firmware which enables MQTT access, but i think, that's not available either currently.

rospogrigio commented 1 year ago

I really don't know mate, never tried these devices. If you can provide a working situation (such as with tinytuya) maybe I can check if we can make it work with localtuya but currently it does not support RF/IR gateways, sorry.

k1llerk3ks commented 1 year ago

If i find any suitable Solution, i am happy to provide it here! Thanks for your immediate help! (And thanks for localtuya, it's amazing \o/ )

Oglaf commented 1 year ago

Hi @k1llerk3ks, it looks like your device might be running tuya protocol 3.5, install/update tinytuya to version 1.10.1, run the wizard and then a scan and check if it retrieves the DPs.

k1llerk3ks commented 1 year ago

Hey @Oglaf , thanks for your comment! I've updated my tinytuya, and ran the wizard before a scan, and received this:

python -m tinytuya -h
TinyTuya [1.10.1]

Wizard:

Polling local devices...
    [Infrarot-HF-Fernbedienung] 192.168.111.64     - No Response

(it showed DPS for my power switch, which already works nice, but No Response for my problem-device.)

i ran a scan after the wizard, and got again only the DPS for my already working device.

Scanning on UDP ports 6666 and 6667 and 7000 for devices for 18 seconds...

Smart Plug 2   Product ID = <productid>  [Valid Broadcast]:
    Address = 192.168.111.61   Device ID =<deviceid> (len:20)  Local Key = <localkey>  Version = 3.3  Type = default, MAC = <mac>
    Status: {'1': True, '9': 0, '18': 225, '19': 112, '20': 2378, '21': 1, '22': 1694, '23': 23744, '24': 116000, '25': 180}
Infrarot-HF-Fernbedienung   Product ID = <productid>  [Valid Broadcast]:
    Address = 192.168.111.64   Device ID = <id> (len:22)  Local Key = <localkey>  Version = 3.3  Type = default, MAC = <mac>
    Polling 192.168.111.64 Failed: No response
Scan completed in 18.0866 seconds                 

Scan Complete!  Found 2 devices.
Broadcasted: 2
Versions: 3.3: 2

seems, like it doesn't work, - regarding protocol 3.5, can it still be possible to be 3.5 or is it v3.3, after tinytuya told me, it's 3.3?

Oglaf commented 1 year ago

No, the latest version shows correctly when it 3.5 protocol. If it doesn't work tinytuya it will not work with localtuya

On Smart Life app, if you run Check device network on your device, does it work? After running tinytuya wizard, it generates a file called devices.json, your Avatto S11 appears on the list?

You could also try increasing the number of scans to increase timeout, but I have never seen it work: python -m tinytuya scan 120