milo526 / homebridge-tuya-web

Hoobs and Homebridge plugin for Tuya devices using Home Assistant Tuya Web Api
MIT License
219 stars 95 forks source link

Fan - Setting RotationSpeed #112

Open CameronSmith93 opened 3 years ago

CameronSmith93 commented 3 years ago

Device type

Stirling FS1-40DCWIFI Pedestal Fan

Device information

{   u'header': {   u'code': u'SUCCESS', u'payloadVersion': 1},
    u'payload': {   u'devices': [   {   u'data': {   u'online': True,
                                                     u'speed': u'3',
                                                     u'speed_level': 15,
                                                     u'state': u'false'},
                                        u'dev_type': u'fan',
                                        u'ha_type': u'fan',
                                        u'icon': u'https://images.tuyaeu.com/smart/icon/bay1589359175993MeEh/159540337782efe7f8e63.jpg',
                                        u'id': u'<redacted>',
                                        u'name': u'FS1-40DCWIFI'}],
                    u'scenes': []}}

Issue

Toggling on/off the fan via HomeKit works correctly. However, when setting any rotation speed, the fan shows a speed of '00' on the physical display and stops rotating.

Setting the rotation speed via the TuyaSmart app works correctly.

Let me know what else I can provide to assist in diagnosing the issue.

milo526 commented 3 years ago

Hey! Thank you for opening an issue.

In your logs you should be able to find some log lines that look something like the following

[device_name] Characteristic.RotationSpeed [SET] xxxx xxxx

Could you please provide me with your log after you set the rotation speed, then I can see what values are being transmitted and see what goes wrong there.

CameronSmith93 commented 3 years ago

Thanks for looking into this! Here are some values I've triggered just now:

[11/6/2020, 10:25:13] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.RotationSpeed - [SET] 24 4
[11/6/2020, 10:25:13] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 1 1
[11/6/2020, 10:25:15] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.RotationSpeed - [SET] 30 5
[11/6/2020, 10:25:15] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 1 1
[11/6/2020, 10:25:17] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 1 1
[11/6/2020, 10:25:17] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.RotationSpeed - [SET] 36 6
[11/6/2020, 10:25:20] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 1 1
[11/6/2020, 10:25:20] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.RotationSpeed - [SET] 24 4
[11/6/2020, 10:25:21] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 1 1
[11/6/2020, 10:25:21] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.RotationSpeed - [SET] 18 3
[11/6/2020, 10:25:28] [TuyaWebPlatform] [FS1-40DCWIFI] Characteristic.Active - [SET] 0 0

Edit: Just for clarification, it's a 15-speed fan.

milo526 commented 3 years ago

I have no clue what the problem is here. It seems like the plugin is sending very reasonable values, I've tried it with my fan and that one works fine.

CameronSmith93 commented 3 years ago

Yes, very strange indeed.

Is there anything that I can provide you with to assist with a diagnosis? Packet or request/response capture of working traffic from the Tuya app?

milo526 commented 3 years ago

I cannot reproduce this issue and at the moment do not have the time to debug this with you sadly.

I would love for somebody to be able to submit a PR for this.

patrickl96 commented 3 years ago

I've got a very similar problem. I've also submitted an issue for this.

BobbyLindsey commented 3 years ago

I have a similar issue with my fan. For my fan, it looks like maybe the speeds are not set by percentage, but simply enumerated. My fan has three speeds. When I set it to the medium speed in the Smart Life app, I see this in the HomeBridge logs:

[05/03/2021, 00:03:28] [TuyaWebPlatform] [Ceiling Fan] Characteristic.Active - [GET] true
[05/03/2021, 00:03:28] [TuyaWebPlatform] [Ceiling Fan] Characteristic.RotationSpeed - [GET] 2
BobbyLindsey commented 3 years ago

Also, on startup, it seems to indicate the number of speeds; three in my case:

[05/03/2021, 00:11:16] [TuyaWebPlatform] [Ceiling Fan] deviceConfig: {
  data: { online: true, state: 'false', speed_level: 3, speed: '2' },
  name: 'Ceiling Fan',
  icon: 'https://images.tuyaus.com/smart/icon/ay1566306500214Y6P2j/15856618854f216b2db9c.png',
  id: 'removed',
  dev_type: 'fan',
  ha_type: 'fan'
}
milo526 commented 3 years ago

I guess there is a rounding error somewhere. I'm strongly contemplating moving away from percentage based device control and instead move back to level based control thus only allowing you to select steps 0 (off), 1, 2, ... up til the max your device supports.

CameronSmith93 commented 3 years ago

I'm inclined to agree with the suggestion of it being a rounding error - incrementing the speed on my 15-speed fan increases the percentage display by 6%, for a max speed displayed of 90% rather than 100%.

Looking forward to level based control if/when you have the time to make the change!

pcm1ke commented 3 years ago

Any word on if/when this change to fan levels, rather than percentages may occur?

Thank you

milo526 commented 2 years ago

No updates at the moment.

wailuen commented 1 year ago

I have many ceiling fan and there many line of this generated in the log. Although, everything seems to be work, is there any I can do to get this off the log?

[homebridge-tuya-platform] This plugin generated a warning from the characteristic 'Rotation Speed': characteristic was supplied illegal value: number 166 exceeded maximum of 100