Hi Devs,
I'm in the process of adding my range of Tuya devices into Home Assistant for the first time, which has been fairly painful.
I'd like to suggest a few improvements to the device discovery and workflow that I think would help new users and new devices get started quickly.
Tuya recently introduced a new free subscription tier and "Smart Home Basic" Service API. This appears to be intended to replace the developer subscription, and no longer needs to be renewed every 6 months.
Goal:
Simpify on-boarding new Tuya WiFi & Zigbee devices to Home Assistant with Local Control (e.g. via LocalTuya and TuyaLocal).
AND
Retain existing Tuya Cloud integration so current automations and integrations are not disturbed.
Suggested Psuedo-Logic:
1: Pull a list of all Device IDs in the home from the APIs.
2: Match any Device ID's from the Broadcast pings, if available.
3: If the IP is matched, allow the user to add the device.
4: If the IP is not matched, allow the user to enter an IP address manually, then add the device.
Prompt the user to confirm the discovered parameters (or edit as needed), then add the device to Home Assistant with all the parameters pre-filled.
Assumptions:
Devices are online and already paired with Tuya Smart Home app
"Smart Home Basic" Service API > HOME MANAGEMENT > Query user family listQuery Home List. Based on the user ID, query the list of homes where the specified user belongs.
GET EU/v1.0/users/{uid}/homes
RESULTS
Will return an array of all the homes that the user is part of.
The result will usually only be a single array, but good logic would ask the user to confirm, or select their home from a list.
VALUES WANTED
Extract and store the _homeid value from the selected home.
Note: home_id = owner_id returned from other APIs.
Discover all devices in the home
"Smart Home Basic" Service API > HOME MANAGEMENT > Query devices in HomeBased on the home ID, query a list of devices in the specified home.
GET EU/v1.0/homes/{home_id}/devices
RESULTS
Will return an array of all the Devices in the selected home.
Discovery Info
The "IP" value will show the Public WAN IP address of the home router, not the private LAN address of the Tuya WiFi device, so this (alone) can't be used for auto discovery.
However, all devices will send a UDP 6667 broadcast ping, which carries the IP Address and Device ID as a payload.
Unfortunately, the UDP broadcast will only work if HASS is on the same VLAN as the device. Many users run IOT devices on a separate subnet.
By combining both the broadcast and the API results, we can have a high confidence that the devices information will be as full-featured as possible.
Hi Devs, I'm in the process of adding my range of Tuya devices into Home Assistant for the first time, which has been fairly painful.
I'd like to suggest a few improvements to the device discovery and workflow that I think would help new users and new devices get started quickly.
Tuya recently introduced a new free subscription tier and "Smart Home Basic" Service API. This appears to be intended to replace the developer subscription, and no longer needs to be renewed every 6 months.
Goal:
Suggested Psuedo-Logic:
1: Pull a list of all Device IDs in the home from the APIs. 2: Match any Device ID's from the Broadcast pings, if available. 3: If the IP is matched, allow the user to add the device. 4: If the IP is not matched, allow the user to enter an IP address manually, then add the device.
Assumptions:
Need:
API DETAILS
Discover the HOME (location) Info
"Smart Home Basic" Service API > HOME MANAGEMENT > Query user family list
Query Home List. Based on the user ID, query the list of homes where the specified user belongs.
GET EU/v1.0/users/{uid}/homes
RESULTS Will return an array of all the homes that the user is part of. The result will usually only be a single array, but good logic would ask the user to confirm, or select their home from a list.
VALUES WANTED Extract and store the _homeid value from the selected home.
Note: home_id = owner_id returned from other APIs.
Discover all devices in the home
"Smart Home Basic" Service API > HOME MANAGEMENT > Query devices in Home
Based on the home ID, query a list of devices in the specified home.
GET EU/v1.0/homes/{home_id}/devices
RESULTS Will return an array of all the Devices in the selected home.
VALUES WANTED "id" (Device ID) "local_key" "model" "name" (Friendly Name) "owner_id" "product_id" "product_name"
Discovery Info The "IP" value will show the Public WAN IP address of the home router, not the private LAN address of the Tuya WiFi device, so this (alone) can't be used for auto discovery.
However, all devices will send a UDP 6667 broadcast ping, which carries the IP Address and Device ID as a payload.
Unfortunately, the UDP broadcast will only work if HASS is on the same VLAN as the device. Many users run IOT devices on a separate subnet.
By combining both the broadcast and the API results, we can have a high confidence that the devices information will be as full-featured as possible.
All feedback welcome.