Skip to content

Commit

Permalink
Config flow: check categories when identifying hubs
Browse files Browse the repository at this point in the history
The missing local key was a good sign of a hub, but misses hubs with
local functions, which can also be connected to as devices.
Also check the categories that appear to be gateways/hubs/routers in
https://openapi.tuyaus.com/v1.0/iot-03/device-categories

Discussion #1960
  • Loading branch information
make-all committed May 29, 2024
1 parent 0499eac commit 58db65e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion custom_components/tuya_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@

_LOGGER = logging.getLogger(__name__)

HUB_CATEGORIES = [
"wgsxj",
"lyqwg",
"bywg",
"zigbee",
"wg2",
"dgnzk",
"videohub",
"xnwg",
"qtyycp",
"alexa_yywg",
"gywg",
"cnwg",
]


class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 13
Expand Down Expand Up @@ -336,7 +351,10 @@ async def async_step_choose_device(self, user_input=None):
hub_list.append(SelectOptionDict(value="None", label="None"))
for key in self.__cloud_devices.keys():
hub_entry = self.__cloud_devices[key]
if hub_entry[CONF_LOCAL_KEY] == "":
if (
hub_entry[CONF_LOCAL_KEY] == ""
or hub_entry["category"] in HUB_CATEGORIES
):
hub_list.append(
SelectOptionDict(
value=key,
Expand Down

0 comments on commit 58db65e

Please sign in to comment.