0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
222 stars 67 forks source link

Please add support for Wify Scene Switch #144

Open hotbird1970 opened 1 year ago

hotbird1970 commented 1 year ago

Scene switch Wify has 2 buttons with 2 programable scenes for each button "single click" and "long press". Tuya app does not provide "double click".

Device details are { "result": { "category": "wxkg", "functions": [], "status": [ { "code": "switch_mode1", "lang_config": { "click": "Single Click", "double_click": "", "press": "Long Press" }, "name": "Switch 1", "type": "Enum", "values": "{\"range\":[\"click\",\"press\"]}" }, { "code": "switch_mode2", "lang_config": { "click": "Single Click", "double_click": "Double Click", "press": "Long Press" }, "name": "Switch 2", "type": "Enum", "values": "{\"range\":[\"click\",\"press\"]}" }, { "code": "battery_percentage", "lang_config": { "unit": "%" }, "name": "Battery", "type": "Integer", "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}" } ] }, "success": true,

0x5e commented 1 year ago

wxkg is already supported in #136 , have you tried the latest beta version?

0x5e commented 1 year ago

the product name is a bit confusing, wxkg actually is wireless switch, represents a physical stateless button. It can't be controlled in the homekit app, but can be used as a trigger to do some automation (requires home hub).

hotbird1970 commented 1 year ago

Thank you. I updated to the latest version and the stateless switch is now exposed to homekit.

Possible bug - while activating a scene all scenes seem to get activated, it seems to be looping through and triggering all buttons with the click of any buttons.

Automations configured to trigger with single click button 1 get triggered when button 2 is pressed, along with automations configured for button 2

The switch is exposed as a single switch and only one automation is possible, instead of 4

0x5e commented 1 year ago

Do you have any logs during these problems happened? Maybe related to https://github.com/0x5e/homebridge-tuya-platform/issues/125#issuecomment-1342043783 if you can see some warnings about "Message received with wrong order".

About the last issue I have no idea now... switch_mode1 and switch_mode2 should be created with two buttons in one accessory, can you take a picture of your switch's setting page?

hotbird1970 commented 1 year ago

Thank you. Below is the log file, please let me know if this helps

[2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Message received with wrong order. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] LastMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] CurrentMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Fallback to use API fetching the latest device status. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenAPI] Request: method = get endpoint = https://openapi.tuyaus.com path = /v1.0/iot-03/devices/xxx/status query = undefined headers = { "t": "xxx", "client_id": "xxx", "nonce": "xxx", "Signature-Headers": "client_id", "sign": "xxx", "sign_method": "HMAC-SHA256", "access_token": "xxx", "lang": "en", "dev_lang": "javascript", "dev_channel": "homebridge", "devVersion": "1.7.0-beta.5" } body = null [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] onMessage: topic = cloud/token/in/xxx protocol = 4 message = { "dataId": "xxx", "devId": "xxx", "productKey": "xxx", "status": [ { "1": true, "code": "switch_led_1", "t": "xxx", "value": true } ] } [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] onMessage: topic = cloud/token/in/xxx protocol = 4 message = { "dataId": "xxx", "devId": "xxx", "productKey": "xxx", "status": [ { "1": true, "code": "switch", "t": "xxx", "value": true } ] } [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Message received with wrong order. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] LastMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] CurrentMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Fallback to use API fetching the latest device status. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenAPI] Request: method = get endpoint = https://openapi.tuyaus.com path = /v1.0/iot-03/devices/xxx/status query = undefined headers = { "t": "xxx", "client_id": "xxx", "nonce": "xxx", "Signature-Headers": "client_id", "sign": "xxx", "sign_method": "HMAC-SHA256", "access_token": "xxx", "lang": "en", "dev_lang": "javascript", "dev_channel": "homebridge", "devVersion": "1.7.0-beta.5" } body = null [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] onMessage: topic = cloud/token/in/xxx protocol = 4 message = { "dataId": "xxx", "devId": "xxx", "productKey": "xxx", "status": [ { "1": true, "code": "switch", "t": "xxx", "value": true }, { "2": 0, "code": "countdown_1", "t": "xxx", "value": 0 } ] } [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Message received with wrong order. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] LastMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] CurrentMessage: dataId = xxx, t = xxx [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] Fallback to use API fetching the latest device status. [2022-12-12, 10:16:37 p.m.] [@0x5e/homebridge-tuya-platform] [TuyaOpenAPI] Request: method = get endpoint = https://openapi.tuyaus.com path = /v1.0/iot-03/devices/xxx/status query = undefined headers = { "t": "xxx", "client_id": "xxx", "nonce": "xxx", "Signature-Headers": "client_id", "sign": "xxx", "sign_method": "HMAC-SHA256", "access_token": "xxx", "lang": "en", "dev_lang": "javascript", "dev_channel": "homebridge",

0x5e commented 1 year ago

Are they the same device? From the log, the code switch and switch_led_1 didn't contained in your wxkg's schema list [switch_mode1, switch_mode2, battery_percentage]

hotbird1970 commented 1 year ago

I have a few tuya devices and this one might have got included in the log while i was copying and pasting Sorry about that

0x5e commented 1 year ago

Ok, does the problem still exist? You can see "readme - troubleshooting" to get all device info list json, which maybe much complete than find it through debug logs.

hotbird1970 commented 1 year ago

I updated to the latest beta and the problem still exists. I am currently using the switch with only one click and it works well. I had already posted the device information before so am not sure what more to provide. I am happy that at-least one click works which is very useful, Thank you. After updating to the latest beta, 2 of my dimmers do not report the correct brightness in homekit. I can turn the switch on and off but am unable to set the brightness level (which was working previously) So something changed in the beta version.

This switch is made by Topgreener below is the device information { "result": { "active_time": 1637283827, "category": "dj", "category_name": "Light Source", "create_time": XX, "gateway_id": "", "icon": "smart/icon/XX", "id": "XX", "ip": "XX", "lat": "XX", "local_key": "XX", "lon": "XX", "model": "TWF500D", "name": "Second floor", "online": true, "owner_id": "XX", "product_id": "XX", "product_name": "DimmerSwitch", "sub": false, "time_zone": "-05:00", "update_time": 1666481568, "uuid": "XX" }, "success": true, "t": XX, "tid": "XX"

0x5e commented 1 year ago

I need mqtt log to see why the second button didn't work, please see the updated readme: https://github.com/0x5e/homebridge-tuya-platform#3-collecting-logs

During collecting the log, please don't operate other device, and operate scene switch (button 1 and button 2, short press and long press) physically, and there should have some logs. This's important for me to diagnosis.

The dimmer's code didn't changed during 1.7.0 beta versions. Is it related to #32 ? If not, please create a new issue. And your information is missing status and schema property, I suggest get device info from local json file: https://github.com/0x5e/homebridge-tuya-platform#1-get-device-information And also, I need the mqtt log during you setting the brightness level physically.

Thanks for the feedback!