tuya / tuya-homebridge

Homebridge custom plugin for controlling Powered by Tuya (PBT) devices in HomeKit. This plugin is officially maintained by the Tuya Developer Team.
MIT License
345 stars 178 forks source link

Fan control is difficult to use #313

Closed Mbuckley0 closed 1 year ago

Mbuckley0 commented 1 year ago

Describe the bug I have this smart switch with a light and fan control on it https://www.bunnings.com.au/deta-grid-connect-smart-fan-speed-controller-with-touch-light-switch_p0098815. I have managed to connect this with tuya and homebridge and the light switch works great but I am having some issues with the fan switch. The fan only has 3 speeds but the home app is showing the fan control as a slider and if I turn on the fan using the slider and then slide it to 0% the fan doesn't turn off.

Expected behavior The fan accessory should have an on/off switch as well as 3 preset speeds if possible.

Screenshots IMG_9B2723BDEE55-1

**Device info

TuyaOpenAPI request: method = get, endpoint = https://openapi.tuyaeu.com, path = /v1.0/iot-01/associated-users/devices, params = {"size":100}, body = null, headers = {"t":"1666740126625","client_id":"*****","nonce":"d6191920-54bb-11ed-b940-8f5130bcfd91","Signature-Headers":"client_id","sign":"037C033679F4FEED2C96445BCFB6AF25D0F049AE723896D5FC4BED565753210C","sign_method":"HMAC-SHA256","access_token":"******","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.5.0"}
TuyaOpenAPI response: {"result":{"devices":[{"active_time":1666582093,"biz_type":0,"category":"fs","create_time":1616450263,"icon":"smart/icon/ay1536534747810ekKBj/1565058689ed6aa6cfa1e.png","id":"60808183ecfabc7c7e33","ip":"118.209.224.197","lat":"","local_key":"002483ff9a6b36fc","lon":"","model":"","name":"Fan Switch 6914HA","online":true,"owner_id":"69048719","product_id":"kykcqnig6mhf354c","product_name":"Fan Switch 6914HA","status":[{"code":"switch","value":false},{"code":"fan_speed","value":"3"},{"code":"light","value":false}],"sub":false,"time_zone":"+10:00","uid":"eu16665817397889TpUC","update_time":1666582093,"uuid":"60808183ecfabc7c7e33"}],"has_more":false,"last_row_key":"ECFD8CB94454EABBDA4B9BB887EF6BD9","total":1},"success":true,"t":1666740127846,"tid":"d7f9261d54bb11ed8b9d9ee482573564"} path = /v1.0/iot-01/associated-users/devices
TuyaOpenAPI request: method = get, endpoint = https://openapi.tuyaeu.com, path = /v1.0/devices/functions, params = {"device_ids":"60808183ecfabc7c7e33"}, body = null, headers = {"t":"1666740128032","client_id":"****","nonce":"d6191920-54bb-11ed-b940-8f5130bcfd91","Signature-Headers":"client_id","sign":"3F08DD2D82395399EAE31E4981CEC7B072FDF85EA7216BAE859CCD3F7F960B93","sign_method":"HMAC-SHA256","access_token":"*****","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.5.0"}
TuyaOpenAPI response: {"result":[{"category":"fs","devices":["60808183ecfabc7c7e33"],"functions":[{"code":"light","desc":"light","name":"light","type":"Boolean","values":"{}"},{"code":"fan_speed","desc":"fan speed","name":"fan speed","type":"Enum","values":"{\"range\":[\"1\",\"2\",\"3\"]}"},{"code":"switch","desc":"switch","name":"switch","type":"Boolean","values":"{}"}],"product_id":"kykcqnig6mhf354c"}],"success":true,"t":1666740129168,"tid":"d8cd580754bb11edb3dbe68f1605df98"} path = /v1.0/devices/functions
Adding: Fan Switch 6914HA (fs / 60808183ecfabc7c7e33)
Existing Accessory found Fan Switch 6914HA  60808183ecfabc7c7e33 a9365536-9731-44fd-8004-043032a4549a
TuyaOpenAPI request: method = post, endpoint = https://openapi.tuyaeu.com, path = /v1.0/iot-03/open-hub/access-config, params = null, body = {"uid":"eu16665817397889TpUC","link_id":"d63f65d0-54bb-11ed-b940-8f5130bcfd91","link_type":"mqtt","topics":"device","msg_encrypted_version":"1.0"}, headers = {"t":"1666740129360","client_id":"*****","nonce":"d6191920-54bb-11ed-b940-8f5130bcfd91","Signature-Headers":"client_id","sign":"CD132AE539A2015F971368CCB909585E76D36D214DBB045C362F67AC75B49B3A","sign_method":"HMAC-SHA256","access_token":"*****","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.5.0"}
TuyaOpenAPI response: {"result":{"client_id":"cloud_082841c49f1fb34d20e2da5ea5ef177f","expire_time":7200,"password":"******","sink_topic":{"device":"cloud/token/out/{device_id}"},"source_topic":{"device":"cloud/token/in/3427cb64932f65efcddd03e1645fa2a4"},"url":"ssl://m1.tuyaeu.com:8883","username":"cloud_3427cb64932f65efcddd03e1645fa2a4"},"success":true,"t":1666740130514,"tid":"d99a127654bb11ed89edfe1b67a66e75"} path = /v1.0/iot-03/open-hub/access-config
github-actions[bot] commented 1 year ago

Thank you for your feedback, we will solve this issue soon

0x5e commented 1 year ago

We can set minStep for accessory then 3-level fan can only slide to 0%, 25%, 50%, 75%, 100%. If use switch instead of slider, there will be 3 switch with relations, if one on then others should automatically off, such logic make code more complicated maybe. Please try 0x5e#37 if it solves your problem.

Mbuckley0 commented 1 year ago

@0x5e How do I configure the minStep for the accessory? The on/off functionality seems to be working better with this change.

0x5e commented 1 year ago

The code will configure it self, no need to configure manually. @Mbuckley0

github-actions[bot] commented 1 year ago

Stale issue. we will close the issue soon. If this issue has not been resolved, please update the issue and contact us in time.