homebridge-flume 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -4
- package/config.schema.json +40 -5
- package/lib/device/valve.js +4 -4
- package/lib/index.js +4 -4
- package/lib/utils/constants.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@ Configuration sample:
|
|
|
11
11
|
"password": "password",
|
|
12
12
|
"client_id": "12345678901234567890",
|
|
13
13
|
"client_secret": "1234567890",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"refreshInterval": 1,
|
|
15
|
+
"threshold": 0.1,
|
|
16
16
|
"platform": "Flume"
|
|
17
17
|
}
|
|
18
18
|
```
|
|
@@ -23,8 +23,8 @@ Fields:
|
|
|
23
23
|
- "password": Your password for accessing the Flume site (required)
|
|
24
24
|
- "client_id": Your Client ID for API access, found in Settings on the Flume site (required)
|
|
25
25
|
- "client_secret": Your Client Secret for API access, found in Settings on the Flume site (required)
|
|
26
|
-
- "
|
|
27
|
-
- "
|
|
26
|
+
- "refreshInterval": Number of minutes between updates. Defaults to 1 minute. API has a cap of 120 calls per hour. (optional)
|
|
27
|
+
- "threshold": Set to ignore a steady water draw below this value. Defaults to zero (0.0) gallons. (optional)
|
|
28
28
|
|
|
29
29
|
# Retrieving API Login Credentials
|
|
30
30
|
|
package/config.schema.json
CHANGED
|
@@ -39,18 +39,53 @@
|
|
|
39
39
|
"required": true,
|
|
40
40
|
"description": "Your Client Secret for API access, found in Settings on the Flume site"
|
|
41
41
|
},
|
|
42
|
-
"
|
|
43
|
-
"title": "
|
|
42
|
+
"refreshInterval": {
|
|
43
|
+
"title": "Refresh interval",
|
|
44
44
|
"type": "integer",
|
|
45
45
|
"placeholder": 1,
|
|
46
46
|
"description": "Number of minutes between updates. API has a cap of 120 calls per hour."
|
|
47
47
|
},
|
|
48
|
-
"
|
|
48
|
+
"threshold": {
|
|
49
49
|
"title": "Adjustment for False Positives",
|
|
50
50
|
"type": "number",
|
|
51
51
|
"placeholder": 0,
|
|
52
52
|
"description": "Set to ignore a steady water draw below this value (gallons)."
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
|
+
"disableDeviceLogging": {
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"title": "Disable Device Logging",
|
|
57
|
+
"description": "Global logging setting for accessory status changes. If true then accessory status changes will not be logged."
|
|
58
|
+
},
|
|
59
|
+
"debug": {
|
|
60
|
+
"title": "Debug Logging",
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"description": "Global logging setting for the plugin. If true then debug information will be added to the log."
|
|
63
|
+
},
|
|
64
|
+
"disablePlugin": {
|
|
65
|
+
"title": "Disable Plugin",
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"description": "If true, the plugin will remove all accessories and not load the plugin on restart."
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"layout": [
|
|
72
|
+
{
|
|
73
|
+
"type": "fieldset",
|
|
74
|
+
"title": "Required Settings",
|
|
75
|
+
"items": ["username", "password", "client_id", "client_secret"]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "fieldset",
|
|
79
|
+
"title": "Optional Settings",
|
|
80
|
+
"description": "Optional settings for the plugin, including global logging settings.",
|
|
81
|
+
"expandable": true,
|
|
82
|
+
"items": [
|
|
83
|
+
"refreshInterval",
|
|
84
|
+
"threshold",
|
|
85
|
+
"disableDeviceLogging",
|
|
86
|
+
"debug",
|
|
87
|
+
"disablePlugin"
|
|
88
|
+
]
|
|
54
89
|
}
|
|
55
|
-
|
|
90
|
+
]
|
|
56
91
|
}
|
package/lib/device/valve.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports = class deviceValve {
|
|
|
8
8
|
this.accessory = accessory
|
|
9
9
|
this.disableDeviceLogging = platform.config.disableDeviceLogging
|
|
10
10
|
this.funcs = platform.funcs
|
|
11
|
-
this.
|
|
11
|
+
this.threshold = platform.config.threshold
|
|
12
12
|
this.hapChar = platform.api.hap.Characteristic
|
|
13
13
|
this.hapErr = platform.api.hap.HapStatusError
|
|
14
14
|
this.hapServ = platform.api.hap.Service
|
|
@@ -16,7 +16,7 @@ module.exports = class deviceValve {
|
|
|
16
16
|
this.log = platform.log
|
|
17
17
|
this.name = accessory.displayName
|
|
18
18
|
this.platform = platform
|
|
19
|
-
this.
|
|
19
|
+
this.refreshInterval = platform.config.refreshInterval
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
externalUpdate (params) {
|
|
@@ -25,13 +25,13 @@ module.exports = class deviceValve {
|
|
|
25
25
|
params.currentusage && params.currentusage[0] && params.currentusage[0].value
|
|
26
26
|
? params.currentusage[0].value
|
|
27
27
|
: 0
|
|
28
|
-
if (usage > this.
|
|
28
|
+
if (usage > this.threshold) {
|
|
29
29
|
this.log(
|
|
30
30
|
'[%s] %s - [%s] gallons within the last [%s] minutes.',
|
|
31
31
|
this.name,
|
|
32
32
|
'usage detected',
|
|
33
33
|
usage,
|
|
34
|
-
this.
|
|
34
|
+
this.refreshInterval
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
}
|
package/lib/index.js
CHANGED
|
@@ -106,7 +106,7 @@ class FlumePlatform {
|
|
|
106
106
|
}
|
|
107
107
|
this.config[key] = val === 'false' ? false : !!val
|
|
108
108
|
break
|
|
109
|
-
case '
|
|
109
|
+
case 'threshold': {
|
|
110
110
|
if (typeof v === 'string') {
|
|
111
111
|
logQuotes(key)
|
|
112
112
|
}
|
|
@@ -122,7 +122,7 @@ class FlumePlatform {
|
|
|
122
122
|
case 'platform':
|
|
123
123
|
case 'plugin_map':
|
|
124
124
|
break
|
|
125
|
-
case '
|
|
125
|
+
case 'refreshInterval': {
|
|
126
126
|
if (typeof val === 'string') {
|
|
127
127
|
logQuotes(key)
|
|
128
128
|
}
|
|
@@ -185,13 +185,13 @@ class FlumePlatform {
|
|
|
185
185
|
})
|
|
186
186
|
|
|
187
187
|
// Set up an initial last sync time
|
|
188
|
-
this.lastSync = new Date(Date.now() - this.config.
|
|
188
|
+
this.lastSync = new Date(Date.now() - this.config.refreshInterval * 60000)
|
|
189
189
|
|
|
190
190
|
// Perform a first sync and setup the refresh interval
|
|
191
191
|
this.flumeSync()
|
|
192
192
|
this.refreshInterval = setInterval(
|
|
193
193
|
() => this.flumeSync(),
|
|
194
|
-
this.config.
|
|
194
|
+
this.config.refreshInterval * 60000
|
|
195
195
|
)
|
|
196
196
|
|
|
197
197
|
// Log that the plugin setup has been successful with a welcome message
|
package/lib/utils/constants.js
CHANGED
|
@@ -9,8 +9,8 @@ module.exports = {
|
|
|
9
9
|
password: '',
|
|
10
10
|
client_id: '',
|
|
11
11
|
client_secret: '',
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
refreshInterval: 1,
|
|
13
|
+
threshold: 0,
|
|
14
14
|
disableDeviceLogging: false,
|
|
15
15
|
debug: false,
|
|
16
16
|
disablePlugin: false,
|
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
defaultValues: {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
refreshInterval: 1,
|
|
22
|
+
threshold: 0
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
minValues: {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
refreshInterval: 1,
|
|
27
|
+
threshold: 0
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
httpRetryCodes: ['ENOTFOUND', 'ETIMEDOUT', 'EAI_AGAIN', 'ECONNABORTED']
|