iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
403 stars 167 forks source link

TreatLife DS03 RotationSpeed is not a number #472

Open jlg89 opened 6 months ago

jlg89 commented 6 months ago

Describe the bug

This doesn't appear to be causing any functional issues, but it's worth noting, and maybe worth fixing if it could potentially cause problems in the future.

I have a couple of TreatLife DS03 combo switches. Currently testing this FanLight config:

{
            "type": "FanLight",
            "name": "Ceiling Fan",
            "id": "<redacted>",
            "key": "<redacted, but what a pain in the butt it is to acquire these!>",
            "manufacturer": "TreatLife",
            "model": "Ceiling Fan Dimmer Switch DS03",
            "dpLight": 9,
            "dpBrightness": 10,
            "useBrightness": true,
            "minBrightness": 100,
            "scaleBrightness": 1000,
            "dpActive": 1,
            "dpRotationSpeed": 2,
            "maxSpeed": 4
}

For some reason the switches (these are firmware v3.3) send the fan speed as text instead of a number. I have confirmed this with tuya-cli. The response looks like this:

{
  '1': true,
  '3': '4',         <---- fan speed is sent as a text string ¯\_( ͠° ͟ʖ ͠°)_/¯
  '9': true,
  '10': 1000,
  '105': 100,
  '106': 'mode1',
  '108': 1
}

This causes an error in the log, since the plugin obviously expects a number instead of text:

[5/25/2024, 8:54:48 AM] [homebridge-tuya] Connected to Ceiling Fan
[5/25/2024, 8:54:48 AM] [homebridge-tuya] Ready to handle Ceiling Fan (FanLight:3.3) with signature {"1":true,"3":"3","9":false,"10":1000,"105":100,"106":"mode1","108":1}
[5/25/2024, 8:54:48 AM] [homebridge-tuya] This plugin generated a warning from the characteristic 'Rotation Speed': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.

Environment

jlg89 commented 6 months ago

Sorry, same as #461

jlg89 commented 6 months ago

Actually, I just noticed that when I define dpActive and dpRotationSpeed, fan speed does not appear properly in HomeKit; it's always 0%. If I eliminate those settings and only define maxSpeed, the fan controls work properly.

Still having issues getting the dimmer control working properly, but that's a different issue.