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

Cannot connect to Smart IR S06CB3S #554

Open
felipecrs opened this issue Nov 3, 2024 · 9 comments
Open

Cannot connect to Smart IR S06CB3S #554

felipecrs opened this issue Nov 3, 2024 · 9 comments
Labels
tuya_device Support for specific Tuya Devices

Comments

@felipecrs
Copy link

For some reason, TinyTuya cannot connect to this device. When running tinytuya wizard and polling the local devices, it says Error: No IP found. I wonder if anything can be done about it.

Device: https://aliexpress.com/item/1005005119018257.html

image

[
    {
        "name": "Smart IR",
        "id": "ebd240f6998f97981etnct",
        "key": "6r3>d[HIDDEN",
        "mac": "18:de:50:bc:cf:7b",
        "uuid": "5b44c1b6a4382d90",
        "sn": "10012060206DD8",
        "category": "wnykq",
        "product_name": "Smart IR",
        "product_id": "ejv37o6yz9vtxcuo",
        "biz_type": 0,
        "model": "S06CB3S\u4e07\u80fd\u9065\u63a7\u5668",
        "sub": false,
        "icon": "https://images.tuyaus.com/smart/icon/ay1525749833414yotNt/a9f2147012c7571b3bb094216853d2ba.png",
        "mapping": {},
        "ip": "",
        "version": ""
    },
]
@jasonacox
Copy link
Owner

TinyTuya discovers the IP address and version of the devices via UDP broadcasts that these devices make on your network. If your computer is not on the same WiFi or your network is blocking UDP traffic, it will not be able to detect the device. Additionally, if you are running the SmartLife app when running wizard or scan, there are devices that stop broadcasting when the SmartLife app is open. Close and quit the app and try wizard or scan again.

@felipecrs
Copy link
Author

But TinyTuya is able to scan all the other Tuya devices in my network. Also, I'm sure there's no app running.

I can also confirm the device is connected to wifi by looking into my router's ARP. I can confirm it's there by the mac address.

@jasonacox
Copy link
Owner

jasonacox commented Nov 3, 2024

Do you see the IP address assigned to it in your router?

You can also have TinyTuya force scan (IP by IP) using this command line (replace the IP network with yours):

python3 -m tinytuya scan -force 192.168.0.0/24 

@felipecrs
Copy link
Author

Thanks for the hint. I turned off my Home Assistant computer to ensure there was no conflict at all, and scanned again, and now TinyTuya is able to find the device's IP:

Smart IR   Product ID = key54vrth5askhsj  [Valid Broadcast]:     
    Address = 192.168.1.25   Device ID = ebd240f6998f97981etnct (len:22)  Local Key = 6r3>d[HIDDEN  Version = 3.3  Type = default, MAC = 18:de:50:bc:cf:7b
    Polling 192.168.1.25 Failed: Connect Failed

But it isn't able to connect to it yet.

@felipecrs
Copy link
Author

Other devices in the same network seem to work ok:

Garagem de baixo   Product ID = qig0zontbimfi8pn  [Valid Broadcast]:
    Address = 192.168.1.62   Device ID = 11716514c82b960e0849 (len:20)  Local Key = adc39HIDDEN  Version = 3.3  Type = default, MAC = c8:2b:96:0e:08:49
    Status: {'1': False, '101': False}

@jasonacox
Copy link
Owner

Other devices in the same network seem to work ok:

Yes, this seems to be a device specific issue you are having, not really TinyTuya so I flagged this issue as device troubleshooting.

Polling 192.168.1.25 Failed: Connect Failed

Ensure the local key didn't change (if you ever re-pair with a device it resets the key) by running wizard again. You can turn on debug mode to get more info or I would suggest writing a simple python script to just access this one device.

python3 -m tinytuya scan -debug
# Example Usage of TinyTuya
import tinytuya
tinytuya.set_debug(True)

d = tinytuya.Device('DEVICE_ID_HERE', 'IP_ADDRESS_HERE', 'LOCAL_KEY_HERE', version=3.3)
data = d.status() 
print(data)

@felipecrs
Copy link
Author

Thanks a lot for the helpful steps. Here's my script:

# Example Usage of TinyTuya
import tinytuya
tinytuya.set_debug(True)

# smart ir - doesn't work
d = tinytuya.Device('eb54009e7c6d1f6f9dmb4e', '192.168.1.25', '/T}#JK3H8:HIDDEN', version=3.3)
# lights - works
# d = tinytuya.Device('08435372600194fe73d9', '192.168.1.70', 'f10c8aedHIDDEN', version=3.3)

data = d.status()
print(data)

Just to confirm stuff is ok in my network, the snippet above works just fine for the second device and it returns:

{'devId': '08435372600194fe73d9', 'dps': {'1': False, '2': False, '3': False, '4': False, '7': 0, '8': 0, '9': 0, '10': 0, '13': False, '101': False, '102': 'selflock', '103': 5}}

But these are the logs for the smart IR thing:

DEBUG:TinyTuya [1.15.1]

DEBUG:Python 3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0] on linux
DEBUG:Using pyca/cryptography 42.0.5 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'eb54009e7c6d1f6f9dmb4e' ('v3.3'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'devId': '', 'uid': '', 't': ''}}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 13: {'command': {'devId': '', 'uid': '', 't': ''}}, 16: {'command': {'devId': '', 'uid': '', 't': ''}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"gwId":"eb54009e7c6d1f6f9dmb4e","devId":"eb54009e7c6d1f6f9dmb4e","uid":"eb54009e7c6d1f6f9dmb4e","t":"1730681879"}'
DEBUG:socket unable to connect (exception) - retry 1/5
Traceback (most recent call last):
  File "/home/felipecrs/.local/lib/python3.12/site-packages/tinytuya/core.py", line 963, in _get_socket
    self.socket.connect((self.address, self.port))
OSError: [Errno 113] No route to host
DEBUG:socket unable to connect (exception) - retry 2/5
Traceback (most recent call last):
  File "/home/felipecrs/.local/lib/python3.12/site-packages/tinytuya/core.py", line 963, in _get_socket
    self.socket.connect((self.address, self.port))
OSError: [Errno 113] No route to host
DEBUG:socket unable to connect (exception) - retry 3/5
Traceback (most recent call last):
  File "/home/felipecrs/.local/lib/python3.12/site-packages/tinytuya/core.py", line 963, in _get_socket
    self.socket.connect((self.address, self.port))
OSError: [Errno 113] No route to host
DEBUG:socket unable to connect (exception) - retry 4/5
Traceback (most recent call last):
  File "/home/felipecrs/.local/lib/python3.12/site-packages/tinytuya/core.py", line 963, in _get_socket
    self.socket.connect((self.address, self.port))
OSError: [Errno 113] No route to host
DEBUG:socket unable to connect (exception) - retry 5/5
Traceback (most recent call last):
  File "/home/felipecrs/.local/lib/python3.12/site-packages/tinytuya/core.py", line 963, in _get_socket
    self.socket.connect((self.address, self.port))
OSError: [Errno 113] No route to host
DEBUG:ERROR Network Error: Unable to Connect - 901 - payload: null
DEBUG:status() received data={'Error': 'Network Error: Unable to Connect', 'Err': '901', 'Payload': None}
{'Error': 'Network Error: Unable to Connect', 'Err': '901', 'Payload': None}

I am completely sure the IP address is correct, but for some reason "No route to host".

Ensure the local key didn't change (if you ever re-pair with a device it resets the key) by running wizard again.

I was running through the wizard at all times, so the key didn't change. But I actually tried resetting the device, which indeed changed the key, which I got again through the wizard (which correctly found the IP address of the device - I also added a static lease for it in my browser).

Crazy stuff. Is this the first time you hear of a device acting like this?

@felipecrs
Copy link
Author

Oh. I had an idea. Maybe the device doesn't keep connected to Wi-Fi all the time for some reason (it is not battery powered).

So, I decided to give it a shot power cycling the device and trying to connect to it during its "initialization". It actually yielded some stuff:

DEBUG:TinyTuya [1.15.1]

DEBUG:Python 3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0] on linux
DEBUG:Using pyca/cryptography 42.0.5 for crypto, GCM is supported
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'eb54009e7c6d1f6f9dmb4e' ('v3.3'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'devId': '', 'uid': '', 't': ''}}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 13: {'command': {'devId': '', 'uid': '', 't': ''}}, 16: {'command': {'devId': '', 'uid': '', 't': ''}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"gwId":"eb54009e7c6d1f6f9dmb4e","devId":"eb54009e7c6d1f6f9dmb4e","uid":"eb54009e7c6d1f6f9dmb4e","t":"1730682869"}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000010000000a0000008834bcb05fe0ff49dc94cb0a11df01abffa80f607492b8a677d9a0891fe2d94a98fc4ba24f1833c54cc348ffbcdeff5a5f9c4fa12948a8555b25b0a61dbf0f3f497070d71d1cab38037db5ced4f172c02fa80f607492b8a677d9a0891fe2d94a987d0f68d7f4cd54bd1463c6eec23bb0e8d8471b4a9283b97c7290a3030a671ffa5b5876a30000aa55'
DEBUG:received data=b'000055aa000000010000000a0000002c00000001a790e1241bee36e1905a797e2151773b6e4155c65f1a2979cace893dfb2d90d5b798f53e0000aa55'
DEBUG:received message=TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\xa7\x90\xe1$\x1b\xee6\xe1\x90Zy~!Qw;nAU\xc6_\x1a)y\xca\xce\x89=\xfb-\x90\xd5', crc=3080254782, crc_good=True, prefix=21930, iv=None)
DEBUG:raw unpacked message = TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\xa7\x90\xe1$\x1b\xee6\xe1\x90Zy~!Qw;nAU\xc6_\x1a)y\xca\xce\x89=\xfb-\x90\xd5', crc=3080254782, crc_good=True, prefix=21930, iv=None)
DEBUG:decode payload=b'\xa7\x90\xe1$\x1b\xee6\xe1\x90Zy~!Qw;nAU\xc6_\x1a)y\xca\xce\x89=\xfb-\x90\xd5'
DEBUG:decrypting=b'\xa7\x90\xe1$\x1b\xee6\xe1\x90Zy~!Qw;nAU\xc6_\x1a)y\xca\xce\x89=\xfb-\x90\xd5'
DEBUG:decrypted 3.x payload='json obj data unvalid'
DEBUG:payload type = <class 'str'>
DEBUG:'data unvalid' error detected: switching to dev_type 'device22'
DEBUG:_decode_payload() failed!
DEBUG:Device22 detected and updated (default -> device22) - Update payload and try again
DEBUG:ERROR Device22 Detected: Retry Command - 908 - payload: null
DEBUG:status() received data={'Error': 'Device22 Detected: Retry Command', 'Err': '908', 'Payload': None}
DEBUG:status() rebuilding payload for device22
DEBUG:final payload_dict for 'eb54009e7c6d1f6f9dmb4e' ('v3.3'/'device22'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'devId': '', 'uid': '', 't': ''}}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {'devId': '', 'uid': '', 't': ''}, 'command_override': 13}, 13: {'command': {'devId': '', 'uid': '', 't': ''}}, 16: {'command': {'devId': '', 'uid': '', 't': ''}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"devId":"eb54009e7c6d1f6f9dmb4e","uid":"eb54009e7c6d1f6f9dmb4e","t":"1730682869","dps":{"1":null}}'
DEBUG:sending payload
DEBUG:payload encrypted=b'000055aa000000020000000d00000087332e330000000000000000000000007a95d94da3a1dfe48cfc3660e02f40f29c4fa12948a8555b25b0a61dbf0f3f497070d71d1cab38037db5ced4f172c02fa80f607492b8a677d9a0891fe2d94a987d0f68d7f4cd54bd1463c6eec23bb0e8a7cad035a8fc8200cb5c607aa0017899b26f46217e06ca26ff83dd9afe3df09ddc54f7520000aa55'
DEBUG:received data=b'000055aa000000020000000d0000000c000000008de14f440000aa55'
DEBUG:received null payload (TuyaMessage(seqno=2, cmd=13, retcode=0, payload=b'', crc=2380353348, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 5
None

@felipecrs
Copy link
Author

@make-all helped me realize that when I put the device into learning mode (through the app), the script above do return some dp:

{'dps': {'201': '{"control":"study"}'}, 't': 12}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tuya_device Support for specific Tuya Devices
Projects
None yet
Development

No branches or pull requests

2 participants