Skip to content

Commit 4cfcb17

Browse files
committed
Add _Settings_ dialogue for Homebridge UI
See ebaauw/homebridge-hue#1070 (comment)
1 parent f61f675 commit 4cfcb17

File tree

2 files changed

+132
-3
lines changed

2 files changed

+132
-3
lines changed

config.schema.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"pluginAlias": "Hue2",
3+
"pluginType": "platform",
4+
"singular": true,
5+
"customUi": false,
6+
"headerDisplay": "Homebridge plugin for gen-2 Hue bridge",
7+
"footerDisplay": "For a detailed description, see the [wiki](https://github.com/ebaauw/homebridge-hue2/wiki/Configuration).",
8+
"schema": {
9+
"type": "object",
10+
"properties": {
11+
"name": {
12+
"description": "Plugin name as displayed in the Homebridge log.",
13+
"type": "string",
14+
"required": true,
15+
"default": "deCONZ"
16+
},
17+
"hosts": {
18+
"title": "Bridges",
19+
"type": "array",
20+
"items": {
21+
"type": "string"
22+
}
23+
},
24+
"noResponse": {
25+
"description": "Report unreachable lights as <i>No Response</i> in HomeKit.",
26+
"type": "boolean"
27+
},
28+
"parallelRequests": {
29+
"description": "The number of ansynchronous requests Homebridge deCONZ sends in parallel to a deCONZ gateway. Default: 10.",
30+
"type": "integer",
31+
"minimum": 1,
32+
"maximum": 30
33+
},
34+
"stealth": {
35+
"description": "Stealth mode: don't make any calls to the Internet. Default: false.",
36+
"type": "boolean"
37+
},
38+
"timeout": {
39+
"description": "The timeout in seconds to wait for a response from a deCONZ gateway. Default: 5.",
40+
"type": "integer",
41+
"minimum": 1,
42+
"maximum": 30
43+
},
44+
"waitTimePut": {
45+
"description": "The time, in milliseconds, to wait after sending a PUT request, before sending the next PUT request. Default: 50.",
46+
"type": "integer",
47+
"minimum": 0,
48+
"maximum": 50
49+
},
50+
"waitTimePutGroup": {
51+
"description": "The time, in milliseconds, to wait after sending a PUT request to a group, before sending the next PUT request. Default: 1000.",
52+
"type": "integer",
53+
"minimum": 0,
54+
"maximum": 1000
55+
},
56+
"waitTimeResend": {
57+
"description": "The time, in milliseconds, to wait before resending a request after an ECONNRESET or http status 503 error. Default: 300.",
58+
"type": "integer",
59+
"minimum": 100,
60+
"maximum": 1000
61+
},
62+
"waitTimeReset": {
63+
"description": "The timeout in milliseconds, to wait before resetting a characteristic value. Default: 500.",
64+
"type": "integer",
65+
"minimum": 10,
66+
"maximum": 2000
67+
},
68+
"waitTimeUpdate": {
69+
"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.",
70+
"type": "integer",
71+
"minimum": 0,
72+
"maximum": 500
73+
}
74+
}
75+
},
76+
"layout": [
77+
"name",
78+
{
79+
"key": "hosts",
80+
"type": "array",
81+
"items": {
82+
"title": "Bridge",
83+
"description": "Hostname of the Hue bridge. Leave empty to discover bridges.",
84+
"type": "string"
85+
}
86+
},
87+
{
88+
"type": "fieldset",
89+
"expandable": true,
90+
"title": "Advanced Settings",
91+
"description": "Don't change these, unless you understand what you're doing.",
92+
"items": [
93+
"forceHttp",
94+
"noResponse",
95+
"parallelRequests",
96+
"stealth",
97+
"timeout",
98+
"waitTimePut",
99+
"waitTimePutGroup",
100+
"waitTimeResend",
101+
"waitTimeReset",
102+
"waitTimeUpdate"
103+
]
104+
}
105+
]
106+
}

lib/Hue2Platform.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ class Hue2Platform extends homebridgeLib.Platform {
2222

2323
parseConfigJson (configJson) {
2424
this.config = {
25-
hosts: []
25+
hosts: [],
26+
noResponse: false,
27+
parallelRequests: 10,
28+
stealth: false,
29+
timeout: 5,
30+
waitTimePut: 50,
31+
waitTimePutGroup: 1000,
32+
waitTimeResend: 300,
33+
waitTimeReset: 500,
34+
waitTimeUpdate: 100
2635
}
2736
const optionParser = new homebridgeLib.OptionParser(this.config, true)
2837
optionParser
@@ -31,12 +40,26 @@ class Hue2Platform extends homebridgeLib.Platform {
3140
})
3241
.stringKey('name')
3342
.stringKey('platform')
43+
.stringKey('host')
3444
.arrayKey('hosts')
45+
.boolKey('noResponse')
46+
.intKey('parallelRequests', 1, 30)
47+
.boolKey('stealth')
48+
.intKey('timeout', 5, 30)
49+
.intKey('waitTimePut', 0, 50)
50+
.intKey('waitTimePutGroup', 0, 1000)
51+
.intKey('waitTimeResend', 100, 1000)
52+
.boolKey('waitTimeReset', 10, 2000)
53+
.intKey('waitTimeUpdate', 0, 500)
54+
55+
this.bridgeMap = {}
56+
3557
try {
3658
optionParser.parse(configJson)
37-
if (this.config.hosts.length === 0) {
38-
this.log('no bridges found')
59+
if (this.config.host != null) {
60+
this.config.hosts.push(this.config.host)
3961
}
62+
// ...
4063
} catch (error) {
4164
this.fatal(error)
4265
}

0 commit comments

Comments
 (0)