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

Local control of tuya device not working (breezer, category: xfj) #386

Closed mukav closed 1 year ago

mukav commented 1 year ago

Hi, i have tuya device:

    "name": "Royal Clima RCB 150 2",
    "id": "bfef3ec763c8f2d6f9qioz",
    "key": "keykeykeykey",
    "mac": "macmacmac",
    "uuid": "uuiduuid",
    "sn": "snsnsn",
    "category": "xfj",
    "product_name": "",
    "product_id": "qcgxajmb0sdg608j",
    "biz_type": 18,
    "model": "KBIS-120",
    "sub": false,
    ....

I can read device status:

status.py ```python import tinytuya, dev #tinytuya.set_debug(True) d = tinytuya.OutletDevice(dev.DEV_ID, dev.DEV_IP, dev.DEV_KEY) d.set_version(3.3) d.set_socketPersistent(True) print(d.status()) ```
python3 status.py ``` {'dps': {'1': False, '2': 'Air_Supply', '3': 0, '5': False, '11': 100, '12': '1', '13': False, '16': 'cancel', '22': 19, '42': False, '101': 'cancel', '102': 10}} ```

But, i can't set any dps (dps does not change after this) :

set.py ```python import tinytuya, dev tinytuya.set_debug(True) d = tinytuya.OutletDevice(dev.DEV_ID, dev.DEV_IP, dev.DEV_KEY) d.set_version(3.3) d.set_socketPersistent(True) d.turn_on() #d.set_value(1, True) ```
python3 set.py ``` DEBUG:TinyTuya [1.12.9] DEBUG:Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux DEBUG:Using PyCrypto (3, 18, '0') DEBUG:final payload_dict for 'qcgxajmb0sdg608j' ('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 7 payload=b'{"devId":"qcgxajmb0sdg608j","uid":"qcgxajmb0sdg608j","t":"1689234718","dps":{"1":true}}' DEBUG:sending payload DEBUG:payload encrypted=b'000055aa000000010000000700000077332e33000000000000000000000000e08848d38ac40c431642b3e6d231870484893cdf3400894201aaabb63db07ae05e37dcaabad6cd981c0f7087cde326a8648bfb4443c2 46e8490e2ddd2967a4a900165aae8aade30fba5c31a91d5b1229f978ef2187c27726a6be9cfa74c2770c582a0a3e0000aa55' DEBUG:received data=b'000055aa00000001000000070000000c00000000a505a9140000aa55' DEBUG:received null payload (TuyaMessage(seqno=1, cmd=7, retcode=0, payload=b'', crc=2768611604, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 5 ```

I tried to use 'device22', but with this setting device not working.

python -m tinytuya scan ``` TinyTuya (Tuya device scanner) [1.12.9] [Loaded devices.json - 2 devices] Scanning on UDP ports 6666 and 6667 and 7000 for devices for 18 seconds... Royal Clima RCB 150 Product ID = qcgxajmb0sdg608j [Valid Broadcast]: Address = 192.168.1.105 Device ID = bfc9eb8dcfeb037140qgms (len:22) Local Key = ... Version = 3.3 Type = default, MAC = 1c:90:ff:bc:f3:18 Status: {'1': True, '2': 'Air_Supply', '3': 0, '5': False, '11': 99, '12': '2', '13': False, '16': 'cancel', '22': 16, '42': False, '101': 'cancel', '102': 10} Royal Clima RCB 150 2 baby Product ID = qcgxajmb0sdg608j [Valid Broadcast]: Address = 192.168.1.59 Device ID = bfef3ec763c8f2d6f9qioz (len:22) Local Key = ... Version = 3.3 Type = default, MAC = 1c:90:ff:bc:f6:d8 Status: {'1': False, '2': 'Air_Supply', '3': 0, '5': False, '11': 100, '12': '1', '13': False, '16': 'cancel', '22': 19, '42': False, '101': 'cancel', '102': 10} Scan completed in 18.0778 seconds Scan Complete! Found 2 devices. Broadcasted: 2 Versions: 3.3: 2 ```
mukav commented 1 year ago

It is my mistake ( I used product_id instead of device id. Now all ok.

jasonacox commented 1 year ago

Thanks for the follow up @mukav - I'm glad you got it working! I'll close for now but reopen if there is anything more we can do.