rospogrigio / localtuya

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

Question: Fan Speed Control for Treatlife Fan Switch #754

Open mdgranger96 opened 2 years ago

mdgranger96 commented 2 years ago

Hi, I have a fan switch from Treatlife that I've integrated but can't seem to control the actual speed level for. Below is the API details ffor this device:

{ "result": { "active_time": 1645162636, "biz_type": 18, "category": "fskg", "create_time": 1645162636, "icon": "smart/icon/ay14906729310721fNjn/a92553379c09ef865681d1c62eb04190.jpg", "id": "eba9374401fc4df222hlrq", "ip": "xx.xx.xx.xx", "lat": "42.0583", "local_key": "xxxxxxxxxxxxxxxx", "lon": "-88.2394", "model": "DS02F(WiFi+Ble)", "name": "Ceiling Fan - Fan Controller", "online": true, "owner_id": "64133492", "product_id": "tqas5nfwomvgvvhf", "product_name": "Ceiling Fan Switch", "status": [ { "code": "switch_fan", "value": true }, { "code": "countdown_fan", "value": 0 }, { "code": "fan_speed_enum", "value": "level_3" }, { "code": "fan_speed", "value": 0 } ], "sub": false, "time_zone": "-06:00", "uid": "az1644908958876Nq6AA", "update_time": 1645315215, "uuid": "9b25ad55cc0f9575" }, "success": true, "t": 1645315392930, "tid": "7edea13c91e011eca71a6aa79cfd95f0" }

Would seem that fan_speed_enum is the value that needs to be modified but I can't figure out a way to get it to take new values from the integration. Would appreciate any help with this as I am rather new to the platform and would like to be able to control fan speed with HA. It is worth noting that the acceptable speed levels for this device are ["level_1","level_2","level_3","level_4"]. Let me know if there's any way to do this currently or if it would need to be added as a future feature for this integration.

mdgranger96 commented 2 years ago

Might be worth noting that this is the exact command I have to enter into the Tuya API device command line in order to change this value manually:

{ "commands": "[{ \"code\": \"fan_speed_enum\",\"value\": \"level_3\" }]" }

wjbridge commented 2 years ago

``So I have the same fan switch and I have been trying to get it to work for 2 hours :). I finally got it to work but you will need the latest version that has not been released yet with these changes https://github.com/rospogrigio/localtuya/pull/542.

  1. The version I have is the master branch 73bc0464bbeb1bce3468de8d511b645baa078ff2.
  2. I was able to get the id and key using the npm utility as described in the wiki.
  3. The config for the Treatlife Fan Switch (4 Speed) is below that works for me. The speed and on / off are working great!

TuyaDebug (Tuya DPs dump) [1.0.0]

Device <DEVICE_ID> at <IP_ADDRESS> key <KEY_ID> protocol 3.3 dev_type type_0a:
    DPS [1] VALUE [False]
    DPS [2] VALUE [0]
    DPS [3] VALUE [level_1]
    DPS [101] VALUE [0]

DP Settings: image

String Settings: image

Hopefully this helps!