0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
206 stars 58 forks source link

RGBW SMART BULB #213

Open johntous opened 1 year ago

johntous commented 1 year ago

RGBW SMART BULB does not show up in homekit and seems to not be supported.

johntous commented 1 year ago

TuyaOpenAPI response: {"result":{"access_token":" ","expire_time":7200,"platform_url":"https://openapi.tuyaus.com","refresh_token":" ","uid":""},"success":true,"t":1674253966271,"tid":"5cb4de65991211ed8808b63de06c2cf8"} path = /v1.0/iot-01/associated-users/actions/authorized-login TuyaOpenAPI request: method = get, endpoint = https://openapi.tuyaus.com, path = /v1.0/iot-01/associated-users/devices, params = {"size":100}, body = null, headers = {"t":"1674253966321","client_id":" ","nonce":"5c379140-9912-11ed-89cb-214ba72b3b35","Signature-Headers":"client_id","sign":"","sign_method":"HMAC-SHA256","access_token":" ","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.5.0"} TuyaOpenAPI response: {"result":{"devices":[{"active_time":1674185197,"biz_type":18,"category":"dsd","create_time":1674185197,"icon":"smart/icon/bay1585191439783zhuG/ef2ac0cba9bc74854b2c9073fae8d595.png","id":"eb7b8b9342e6d64ddaocky","ip":"","lat":"30.5447","local_key":"8753eb9987974756","lon":"-84.2386","model":"","name":"RGBW SMART BULB","online":false,"owner_id":"96164320","product_id":"hvjumj3mjsqapl4t","product_name":"RGBW SMART BULB","status":[{"code":"switch_led","value":true},{"code":"work_mode","value":"white"},{"code":"bright_value","value":1000},{"code":"colour_data","value":"{\"h\":0,\"s\":1000,\"v\":1000}"},{"code":"scene_data","value":"{\"scene_num\":1,\"scene_units\":[{\"bright\":200,\"h\":0,\"s\":0,\"temperature\":1000,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}"},{"code":"countdown","value":0}],"sub":false,"time_zone":"-05:00","uid":"","update_time":1674185202,"uuid":"2943175e7ebd0e37"}],"has_more":false,"last_row_key":"BBCF003DEBB31CA9D4C03A0A875C6CB3","total":1},"success":true,"t":1674253966769,"tid":"5cf592e8991211edb5e53abd0ca7b96f"} path = /v1.0/iot-01/associated-users/devices TuyaOpenAPI request: method = get, endpoint = https://openapi.tuyaus.com, path = /v1.0/devices/functions, params = {"device_ids":"eb7b8b9342e6d64ddaocky"}, body = null, headers = {"t":"1674253966832","client_id":" ","nonce":"5c379140-9912-11ed-89cb-214ba72b3b35","Signature-Headers":"client_id","sign":" ","sign_method":"HMAC-SHA256","access_token":" ","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.5.0"} TuyaOpenAPI response: {"result":[{"category":"dsd","devices":["eb7b8b9342e6d64ddaocky"],"functions":[{"code":"switch_led","desc":"switch led","name":"switch led","type":"Boolean","values":"{}"},{"code":"work_mode","desc":"work mode","name":"work mode","type":"Enum","values":"{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"},{"code":"bright_value","desc":"bright value","name":"bright value","type":"Integer","values":"{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"},{"code":"colour_data","desc":"colour data","name":"colour data","type":"Json","values":"{}"},{"code":"scene_data","desc":"scene data","name":"scene data","type":"Json","values":"{}"},{"code":"countdown","desc":"countdown","name":"countdown","type":"Integer","values":"{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"},{"code":"music_data","desc":"music data","name":"music data","type":"Json","values":"{}"},{"code":"control_data","desc":"control data","name":"control data","type":"String","values":"{\"maxlen\":255}"}],"product_id":"hvjumj3mjsqapl4t"}],"success":true,"t":1674253967241,"tid":"5d43f590991211ed8808b63de06c2cf8"} path = /v1.0/devices/functions Adding: RGBW SMART BULB (dsd / eb7b8b9342e6d64ddaocky)

[ { "active_time": 1674166544, "biz_type": 0, "category": "dsd", "create_time": 1674166544, "icon": "smart/icon/bay1585191439783zhuG/ef2ac0cba9bc74854b2c9073fae8d595.png", "id": "eb90ac179771e2e472qfla", "ip": " ", "lat": "", "local_key": "", "lon": "", "model": "", "name": "RGBW SMART BULB", "online": true, "owner_id": " ", "product_id": "hvjumj3mjsqapl4t", "product_name": "RGBW SMART BULB", "status": [ { "code": "bright_value", "value": 1000 }, { "code": "colour_data", "value": "{\"h\":0,\"s\":1000,\"v\":1000}" }, { "code": "countdown", "value": 0 }, { "code": "scene_data", "value": "{\"scene_num\":1,\"scene_units\":[{\"bright\":200,\"h\":0,\"s\":0,\"temperature\":1000,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0} ]}" }, { "code": "switch_led", "value": true }, { "code": "work_mode", "value": "white" } ], "sub": false, "time_zone": "-05:00", "uid": "", "update_time": 1674166544, "uuid": "2943175e7ebd0e37", "schema": [ { "code": "bright_value", "mode": "rw", "type": "Integer", "property": { "min": 10, "max": 1000, "scale": 0, "step": 1 } }, { "code": "colour_data", "mode": "rw", "type": "Json", "property": {} }, { "code": "control_data", "mode": "wo", "type": "String", "property": { "maxlen": 255 } }, { "code": "countdown", "mode": "rw", "type": "Integer", "property": { "unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1 } }, { "code": "music_data", "mode": "wo", "type": "Json", "property": {} }, { "code": "scene_data", "mode": "rw", "type": "Json", "property": {} }, { "code": "switch_led", "mode": "rw", "type": "Boolean", "property": {} }, { "code": "work_mode", "mode": "rw", "type": "Enum", "property": { "range": [ "white", "colour", "scene", "music" ] } } ] } ]

0x5e commented 1 year ago

are you using the old version 1.5.0? please follow the readme to get the latest version.

johntous commented 1 year ago

I'm using @0x5e/homebridge-tuya-platform v1.7.0-beta.22

[21/01/2023, 09:49:54] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] onMessage: topic = cloud/token/in/ protocol = 4 message = { "dataId": "6e703f79-b15d-47ca-9f50-a3376df26e9c", "devId": "eb7b8b9342e6d64ddaocky", "productKey": "hvjumj3mjsqapl4t", "status": [ { "20": false, "code": "switch_led", "t": "1674312594", "value": false } ] } t = 1674312594 [21/01/2023, 09:50:00] [@0x5e/homebridge-tuya-platform] [TuyaOpenMQ] onMessage: topic = cloud/token/in/ protocol = 4 message = { "dataId": "38b310e9-38c7-4fbc-8c27-6dc2a8f1b4bf", "devId": "eb7b8b9342e6d64ddaocky", "productKey": "hvjumj3mjsqapl4t", "status": [ { "20": true, "code": "switch_led", "t": "1674312600", "value": true } ] } t = 1674312600

johntous commented 1 year ago

[ { "active_time": 1674313273, "biz_type": 18, "category": "dsd", "create_time": 1674313273, "icon": "smart/icon/bay1585191439783zhuG/ef2ac0cba9bc74854b2c9073fae8d595.png", "id": " ", "ip": " ", "lat": "", "local_key": " ", "lon": "", "model": "", "name": "RGBW SMART BULB", "online": true, "owner_id": "96164320", "product_id": "hvjumj3mjsqapl4t", "product_name": "RGBW SMART BULB", "status": [ { "code": "bright_value", "value": 1000 }, { "code": "colour_data", "value": "{\"h\":0,\"s\":1000,\"v\":1000}" }, { "code": "countdown", "value": 0 }, { "code": "scene_data", "value": "{\"scene_num\":1,\"scene_units\":[{\"bright\":200,\"h\":0,\"s\":0,\"temperature\":1000,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0} ]}" }, { "code": "switch_led", "value": true }, { "code": "work_mode", "value": "white" } ], "sub": false, "time_zone": "-05:00", "uid": " ", "update_time": 1674313273, "uuid": "2943175e7ebd0e37", "schema": [ { "code": "bright_value", "mode": "rw", "type": "Integer", "property": { "min": 10, "max": 1000, "scale": 0, "step": 1 } }, { "code": "colour_data", "mode": "rw", "type": "Json", "property": {} }, { "code": "control_data", "mode": "wo", "type": "String", "property": { "maxlen": 255 } }, { "code": "countdown", "mode": "rw", "type": "Integer", "property": { "unit": "s", "min": 0, "max": 86400, "scale": 0, "step": 1 } }, { "code": "music_data", "mode": "wo", "type": "Json", "property": {} }, { "code": "scene_data", "mode": "rw", "type": "Json", "property": {} }, { "code": "switch_led", "mode": "rw", "type": "Boolean", "property": {} }, { "code": "work_mode", "mode": "rw", "type": "Enum", "property": { "range": [ "white", "colour", "scene", "music" ] } } ] } ]

0x5e commented 1 year ago

the dsd is an undocumented light product, you can use advanced option to override category to dj (light) as a workaround, I will add support in next version.

johntous commented 1 year ago

It's a color changeable RGB LED as well. how do i give it color control after setting to dj. 1/01/2023, 20:03:01] [@0x5e/homebridge-tuya-platform] Override 'RGBW SMART BULB' category to 'dj' [21/01/2023, 20:03:01] [@0x5e/homebridge-tuya-platform] Restoring existing accessory from cache: RGBW SMART BULB [21/01/2023, 20:03:01] [@0x5e/homebridge-tuya-platform] [RGBW SMART BULB] Light type: C

0x5e commented 1 year ago

Your color schema:

{
"code": "colour_data",
"mode": "rw",
"type": "Json",
"property": {}
}

is missing h,s,v in property.

Here's an normal color schema example:

{
  "code": "colour_data",
  "mode": "rw",
  "type": "Json",
  "property": {
    "h": {
      "min": 1,
      "scale": 0,
      "unit": "",
      "max": 360,
      "step": 1
    },
    "s": {
      "min": 1,
      "scale": 0,
      "unit": "",
      "max": 255,
      "step": 1
    },
    "v": {
      "min": 1,
      "scale": 0,
      "unit": "",
      "max": 255,
      "step": 1
    }
  }
}

Adjust the h,s,v max value of yours and use it into deviceOverrides, clean accessory cache, maybe work.

johntous commented 1 year ago

Not sure I have the config right. am i missing. something

{ "options": { "projectType": "2", "accessId": " ", "accessKey": " ", "countryCode": 1, "username": " ", "password": " ", "appSchema": "smartlife", "deviceOverrides": [ { "id": " ", "category": "df", "schema": [ { "oldCode": "colour_data", "code": "colour_data", "mode": "rw", "type": "Json", "property": { "h": { "min": 1, "scale": 0, "unit": "", "max": 360, "step": 1 }, "s": { "min": 1, "scale": 0, "unit": "", "max": 255, "step": 1 }, "v": { "min": 1, "scale": 0, "unit": "", "max": 255, "step": 1 } } } ] } ] }, "_bridge": { "username": " ", "port": 41833 }, "platform": "TuyaPlatform" }

johntous commented 1 year ago

Screenshot 2023-01-22 092719

0x5e commented 1 year ago

From the status:

{
"code": "colour_data",
"value": "{"h":0,"s":1000,"v":1000}"
}

the max of "s" and "v" is at least 1000, "h" I don't know, need some test.

johntous commented 1 year ago

so is my config wrong? not sure where to set this overrides

0x5e commented 1 year ago

Yes the max of the h/s/v seems wrong. other part of the config is correct.

johntous commented 1 year ago

HomeKit still sees the light only as a white led with dimmer not options to change color. I removed the overrides and updated to v1.7.0-beta.23 and it sees it as a homekit supported device now but now color changing options.

johntous commented 1 year ago

How to make it a rgb\W capable HomeKit device. It’s rgb in smart life but not homekit

johntous commented 1 year ago

LightTypeshould be RGBCW