jasonacox / tinytuya

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

could it be possibly to issue reset to cleaner robot ? #437

Open gfanini opened 6 months ago

gfanini commented 6 months ago

could it be possibly to issue reset to cleaner robot with tuya protocol 3.3 ? it is ikohs S15 :

snapshot.json

{
    "timestamp": 1702763927.5987241,
    "devices": [
        {
            "id": "bfb63ee0a1bff588ee0uw9",
            "ip": "192.168.1.74",
            "active": 2,
            "encrypt": true,
            "productKey": "rsyse6okboceueag",
            "name": "",
            "key": "",
            "mac": "",
            "ability": 0,
            "token": "",
            "wf_cfg": "",
            "dev_type": "default",
            "origin": "broadcast",
            "ver": "3.3"
        }
    ]
}

thank you for possible clues for say "factory reset" that it's acting strangely.

jasonacox commented 6 months ago

What DPS values did you get from it when you ran the wizard (python -m tinytuya wizard)? I recommend looking at each of those and use the iot.tuya.com portal to investigate them. You can then manipulate those values with tinytuya's set_value(index, value, nowait) function.

gfanini commented 6 months ago

I registered on iot.tuya.com portal as individual developer, is it free of charge ?

what should I use here, I tried to put the key from python -m tinytuya scan
"devices": [ { "id": "bfb63ee0a1bff588ee0uw9", "ip": "192.168.1.74", "active": 2, "encrypt": true, "productKey": "rsyse6okboceueag", "name": "", "key": "", "mac": "", "ability": 0, "token": "", "wf_cfg": "", "dev_type": "default", "origin": "broadcast", "ver": "3.3" }

binary@ECLLAP12:/mnt/c/Users/gfanini$ python3 -m tinytuya wizard TinyTuya Setup Wizard [1.13.1]

Enter API Key from tuya.com: rsyse6okboceueag
Enter API Secret from tuya.com:

what would be the "api secret" ? also here there seems to be a method to enumerate the "DP" is it data points https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

jasonacox commented 6 months ago

When you set up your free trial account, they will give you an API key and secrete. Follow the instructions here: https://github.com/jasonacox/tinytuya#setup-wizard---getting-local-keys

A PDF version is here, which might help: https://github.com/jasonacox/tinytuya/files/12836816/Tuya.IoT.API.Setup.v2.pdf

image
gfanini commented 6 months ago

I enclose what DPs it extracted, there seem to be numbers 1-18 but no clue anything to reset the device somehow ... Polling local devices... [Netbot S15 ] 192.168.1.74 - [Off] - DPS: {'1': False, '4': 'foward', '5': '0', '6': 50, '16': 0, '17': 0, '18': 0, '101': 'low_step'} devices.json

possibly there would be "hidden" debug/development ones ? https://github.com/rospogrigio/localtuya/issues/1188

this is the list from the iot website image

how could I read or set a value in this DP

Code:water_step Function Name:Scrub mode Data Transfer Type:Send & report Data Type:Enum Remarks:water_step

jasonacox commented 6 months ago

Here is a small code sample of how you would set DP values:

# Connect to Device
d = tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY)
d.set_version(3.3)

# Show status of device
data = d.status()
print('\nCurrent Status: %r' % data)

# Change DPS 18 as example
d.set_value(18, 1) 

# Show status of device
data = d.status()
print('\nCurrent Status: %r' % data)