Skip to content

Commit

Permalink
Add option to suppress connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff committed Jan 29, 2022
1 parent f9ba9f2 commit 9ad3ea7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,38 @@ Configure the plugin so that it knows where to connect to your PC(s) running the
**Configuration Fields:**
* `platform` (string) - Tells Homebridge to use this plugin. Must be set to `OpenRgbPlatform`
* `name` (string) - A name to label this plugin
* `discoveryInterval` (integer) - How often (in seconds) to check if new devices are available to connect to. Defaults to 60 seconds
* `preserveDisconnected` (boolean) - Set this to `true` to have the plugin keep devices that are disconnected from their server. By default, devices that are not connected when their server is queried are removed from HomeKit, which may mess up your scenes if you have devices such as peripherals which are not always connected to your PC
* `servers` (array) - Each object represents a computer running the OpenRGB SDK server that this plugin should attempt to connect to
* `name` (string) - A name for this server
* `host` (string) - The IP address (e.g. 10.0.0.2) or hostname (e.g. my-computer.local) that the OpenRGB SDK Server is running on
* `port` (integer) - The port number that the OpenRGB SDK Server is set to run on. OpenRGB defaults to using port 6742
* `discoveryInterval` (integer) - How often (in seconds) to check if new devices are available to connect to. Defaults to 60 seconds
* `preserveDisconnected` (boolean) - Set this to `true` to have the plugin keep devices that are disconnected from their server. By default, devices that are not connected when their server is queried are removed from HomeKit, which may mess up your scenes if you have devices such as peripherals which are not always connected to your PC
* `suppressConnectionErrors` (boolean) - Set this to `true` to hide log messages about errors connecting to your PC

Typically, a computer's IP address will change periodically, so I recommend using your PC's hostname to configure this plugin's `host` field. On Windows, you can run the `hostname` command from the command line to view your PC's name. Your hostname will then be that name, lowercase, with `.local` appended to the end. Alternatively, you could configure your router to reserve a specific IP address for your PC and use that in the `host` field.

**Example Configuration:**

{
"platforms": [
"platforms": [
{
"platform": "OpenRgbPlatform",
"name": "OpenRGB",
"servers": [
{
"name": "John's Computer",
"host": "johns-computer.local",
"port": 6742
},
{
"platform": "OpenRgbPlatform",
"name": "OpenRGB",
"discoveryInterval": 60,
"preserveDisconnected": false,
"servers": [
{
"name": "John's Computer",
"host": "johns-computer.local",
"port": 6742
},
{
"name": "Jane's Computer",
"host": "janes-computer.local",
"port": 6742
}
]
"name": "Jane's Computer",
"host": "janes-computer.local",
"port": 6742
}
]
],
"discoveryInterval": 60,
"preserveDisconnected": false,
"suppressConnectionErrors": false
}
]
}
35 changes: 21 additions & 14 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@
"default": "OpenRGB",
"description": "A name to label this plugin"
},
"discoveryInterval": {
"title": "Discovery Interval",
"type": "integer",
"required": true,
"default": 60,
"description": "How often (in seconds) to check if new devices are available to connect to"
},
"preserveDisconnected": {
"title": "Preserve Disconnected Devices",
"type": "boolean",
"required": false,
"default": false,
"description": "Enable this to have the plugin keep devices that are disconnected from their server. By default, devices that are not connected when their server is queried are removed from HomeKit, which may mess up your scenes if you have devices such as peripherals which are not always connected to your PC"
},
"servers": {
"title": "Computers Running the OpenRGB SDK Server",
"type": "array",
Expand Down Expand Up @@ -56,6 +42,27 @@
}
}
}
},
"discoveryInterval": {
"title": "Discovery Interval",
"type": "integer",
"required": true,
"default": 60,
"description": "How often (in seconds) to check if new devices are available to connect to"
},
"preserveDisconnected": {
"title": "Preserve Disconnected Devices",
"type": "boolean",
"required": false,
"default": false,
"description": "Enable this to have the plugin keep devices that are disconnected from their server. By default, devices that are not connected when their server is queried are removed from HomeKit, which may mess up your scenes if you have devices such as peripherals which are not always connected to your PC"
},
"suppressConnectionErrors": {
"title": "Suppress Connection Errors",
"type": "boolean",
"required": false,
"default": false,
"description": "Enable this to hide log messages about errors connecting to your PC"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ export class OpenRgbPlatform implements DynamicPlatformPlugin {
try {
await Promise.race([client.connect(), timeout()]);
} catch (err) {
this.log.warn(`Unable to connect to OpenRGB SDK server at ${serverHost}:${serverPort}`);
const logType = this.config.suppressConnectionErrors === true ? 'debug' : 'warn';
this.log[logType](`Unable to connect to OpenRGB SDK server at ${serverHost}:${serverPort}`);
return 1;
}

Expand Down

0 comments on commit 9ad3ea7

Please sign in to comment.