Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable discover timeout #470

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config-example.MD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The configuration parameters to enable your devices would need to be added to `p
/* The block you need to enable this plugin */
{
"platform": "TuyaLan",
"discoverTimeout": 60000,
"devices": [
/* The block you need for each device */
{
Expand All @@ -33,11 +34,14 @@ The configuration parameters to enable your devices would need to be added to `p
...
}
```
#### Parameters
#### Device parameters
* `name` (required) is anything you'd like to use to identify this device. You can always change the name from within the Home app.
* `type` (required) is a case-insensitive identifier that lets the plugin know how to handle your device. Find your device `type` on the [Supported Device Type List](https://github.com/iRayanKhan/homebridge-tuya/wiki/Supported-Device-Types) page.
* `manufacturer` and `model` are anything you like; the purpose of them is to help you identify the device.
* `id` (required) and `key` (required) are parameters for your device. If you don't have them, follow the steps found on the [Setup Instructions](https://github.com/iRayanKgan/homebridge-tuya/wiki/Setup-Instructions) page.
* `ip` needs to be added **_only_** if you face discovery issues. See [Common Problems](https://github.com/iRayanKhan/homebridge-tuya/wiki/Common-Problems) for more details.

> To find out which `id` belongs to which device, open the Tuya Smart app and check the `Device Information` by tapping the configuration icon of your devices; it is almost always a tiny icon on the top-right.

#### Other parameters
* `discoverTimeout` (optional) is the time period (millisecond) the plugin should spend for device auto-discovery. If unspecified, the default value is 60000.
8 changes: 8 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"schema": {
"type": "object",
"properties": {
"discoverTimeout": {
"title": "Device IP auto-discovery timeout",
"type": "integer",
"minimum": 0,
"placeholder": "Timeout (millisecond) for device IP address discovery",
"default": 60000,
"required": false
},
"devices": {
"type": "array",
"orderable": false,
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const OilDiffuserAccessory = require('./lib/OilDiffuserAccessory');

const PLUGIN_NAME = 'homebridge-tuya';
const PLATFORM_NAME = 'TuyaLan';
const DEFAULT_DISCOVER_TIMEOUT = 60000;

const CLASS_DEF = {
outlet: OutletAccessory,
Expand Down Expand Up @@ -152,7 +153,7 @@ class TuyaLan {
this.log.warn('Failed to discover %s (%s) in time but will keep looking.', devices[deviceId].name, deviceId);
}
});
}, 60000);
}, this.config.discoverTimeout ?? DEFAULT_DISCOVER_TIMEOUT);
}

registerPlatformAccessories(platformAccessories) {
Expand Down