make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.07k stars 432 forks source link

"cloud mode" hub appears in the device list but is absent from the hub list #1956

Closed almirus closed 3 weeks ago

almirus commented 1 month ago

Describe the bug Good day! The cloud addition feature is cool, but I don't know if it's a Tuya API error or an integration bug, but the (lamp) hub is in the device list and absent from the hub list. Therefore, I cannot connect the lamps that are connected through this hub; I get the error "Device needs a gateway"

To Reproduce add cloud authorization, try to add a sub-device - the lamp

Additional context image image

{
  "result": {
    "active_time": 1688218045,
    "bind_space_id": "36487050",
    "category": "wg2",
    "create_time": 1688218045,
    "custom_name": "Gateway lamp",
    "icon": "smart/icon/ay1543197764459ckY1a/c2a8259d6d96fe9ed210d73d6c1d7216.png",
    "id": "bf58d929ed58421c07gowp",
    "ip": "91.214.243.174",
    "is_online": true,
    "lat": "55.7259",
    "local_key": "HIDDEN",
    "lon": "37.7482",
    "model": "",
    "name": "Gateway",
    "product_id": "br85qgx86gsavad9",
    "product_name": "PRO X2P",
    "sub": false,
    "time_zone": "+03:00",
    "update_time": 1716793507,
    "uuid": "0680a593f80132a4"
  },
  "success": true,
  "t": 1716795119649,
  "tid": "340d40871bfb11ef80c7da85933c7aab"
}
{
  "result": {
    "model": "{\"modelId\":\"000001zjqq\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":106,\"accessMode\":\"wr\",\"code\":\"RESTORE_DEV\",\"description\":\"\",\"name\":\"RESTORE_DEV\",\"typeSpec\":{\"type\":\"string\",\"maxlen\":255}},{\"abilityId\":107,\"accessMode\":\"rw\",\"code\":\"LENET_ID\",\"description\":\"\",\"name\":\"LENET_ID\",\"typeSpec\":{\"type\":\"string\",\"maxlen\":255}},{\"abilityId\":108,\"accessMode\":\"rw\",\"code\":\"DevInfor\",\"description\":\"\",\"name\":\"设备信息\",\"typeSpec\":{\"type\":\"value\",\"max\":2147483647,\"min\":0,\"scale\":1,\"step\":1,\"unit\":\"\"}},{\"abilityId\":109,\"accessMode\":\"rw\",\"code\":\"SpecialFlag\",\"description\":\"groupeach 打开单控 \\nnone关闭单控\",\"name\":\"功能标志\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"none\",\"groupeach\"]}},{\"abilityId\":110,\"accessMode\":\"wr\",\"code\":\"SRemote\",\"description\":\"\",\"name\":\"直连控制\",\"typeSpec\":{\"type\":\"string\",\"maxlen\":255}},{\"abilityId\":111,\"accessMode\":\"rw\",\"code\":\"btype\",\"description\":\"\",\"name\":\"类型\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"LeShi\",\"DW\",\"GMM\",\"GSD\",\"RE1\",\"RE2\",\"RE3\",\"RE4\"]}}]}]}"
  },
  "success": true,
  "t": 1716795193119,
  "tid": "5fd4c92c1bfb11ef89139a1bd412573b"
}
make-all commented 1 month ago

As noted on #1960, the code was only using the absence of a local key to detect gateways. But some gateways have local functions as well, so they do have local keys. Now a list of known gateway categories has been added, to improve the recognition (in this case wg2, which seems to be the general category for Bluetooth gateways).