Skip to content

Commit

Permalink
Add _Settings_ dialogue for Homebridge UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ebaauw committed Aug 11, 2023
1 parent f61f675 commit 4cfcb17
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 3 deletions.
106 changes: 106 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"pluginAlias": "Hue2",
"pluginType": "platform",
"singular": true,
"customUi": false,
"headerDisplay": "Homebridge plugin for gen-2 Hue bridge",
"footerDisplay": "For a detailed description, see the [wiki](https://github.com/ebaauw/homebridge-hue2/wiki/Configuration).",
"schema": {
"type": "object",
"properties": {
"name": {
"description": "Plugin name as displayed in the Homebridge log.",
"type": "string",
"required": true,
"default": "deCONZ"
},
"hosts": {
"title": "Bridges",
"type": "array",
"items": {
"type": "string"
}
},
"noResponse": {
"description": "Report unreachable lights as <i>No Response</i> in HomeKit.",
"type": "boolean"
},
"parallelRequests": {
"description": "The number of ansynchronous requests Homebridge deCONZ sends in parallel to a deCONZ gateway. Default: 10.",
"type": "integer",
"minimum": 1,
"maximum": 30
},
"stealth": {
"description": "Stealth mode: don't make any calls to the Internet. Default: false.",
"type": "boolean"
},
"timeout": {
"description": "The timeout in seconds to wait for a response from a deCONZ gateway. Default: 5.",
"type": "integer",
"minimum": 1,
"maximum": 30
},
"waitTimePut": {
"description": "The time, in milliseconds, to wait after sending a PUT request, before sending the next PUT request. Default: 50.",
"type": "integer",
"minimum": 0,
"maximum": 50
},
"waitTimePutGroup": {
"description": "The time, in milliseconds, to wait after sending a PUT request to a group, before sending the next PUT request. Default: 1000.",
"type": "integer",
"minimum": 0,
"maximum": 1000
},
"waitTimeResend": {
"description": "The time, in milliseconds, to wait before resending a request after an ECONNRESET or http status 503 error. Default: 300.",
"type": "integer",
"minimum": 100,
"maximum": 1000
},
"waitTimeReset": {
"description": "The timeout in milliseconds, to wait before resetting a characteristic value. Default: 500.",
"type": "integer",
"minimum": 10,
"maximum": 2000
},
"waitTimeUpdate": {
"description": "The time, in milliseconds, to wait for a change from HomeKit to another characteristic for the same light or group, before updating the deCONZ gateway. Default: 100.",
"type": "integer",
"minimum": 0,
"maximum": 500
}
}
},
"layout": [
"name",
{
"key": "hosts",
"type": "array",
"items": {
"title": "Bridge",
"description": "Hostname of the Hue bridge. Leave empty to discover bridges.",
"type": "string"
}
},
{
"type": "fieldset",
"expandable": true,
"title": "Advanced Settings",
"description": "Don't change these, unless you understand what you're doing.",
"items": [
"forceHttp",
"noResponse",
"parallelRequests",
"stealth",
"timeout",
"waitTimePut",
"waitTimePutGroup",
"waitTimeResend",
"waitTimeReset",
"waitTimeUpdate"
]
}
]
}
29 changes: 26 additions & 3 deletions lib/Hue2Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ class Hue2Platform extends homebridgeLib.Platform {

parseConfigJson (configJson) {
this.config = {
hosts: []
hosts: [],
noResponse: false,
parallelRequests: 10,
stealth: false,
timeout: 5,
waitTimePut: 50,
waitTimePutGroup: 1000,
waitTimeResend: 300,
waitTimeReset: 500,
waitTimeUpdate: 100
}
const optionParser = new homebridgeLib.OptionParser(this.config, true)
optionParser
Expand All @@ -31,12 +40,26 @@ class Hue2Platform extends homebridgeLib.Platform {
})
.stringKey('name')
.stringKey('platform')
.stringKey('host')
.arrayKey('hosts')
.boolKey('noResponse')
.intKey('parallelRequests', 1, 30)
.boolKey('stealth')
.intKey('timeout', 5, 30)
.intKey('waitTimePut', 0, 50)
.intKey('waitTimePutGroup', 0, 1000)
.intKey('waitTimeResend', 100, 1000)
.boolKey('waitTimeReset', 10, 2000)
.intKey('waitTimeUpdate', 0, 500)

this.bridgeMap = {}

try {
optionParser.parse(configJson)
if (this.config.hosts.length === 0) {
this.log('no bridges found')
if (this.config.host != null) {
this.config.hosts.push(this.config.host)
}
// ...
} catch (error) {
this.fatal(error)
}
Expand Down

0 comments on commit 4cfcb17

Please sign in to comment.