homebridge-flume 3.0.5 → 3.1.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 +20 -0
- package/README.md +11 -5
- package/config.schema.json +45 -30
- package/dist/{accessory.d.ts → homebridge/accessory.d.ts} +10 -5
- package/dist/{accessory.js → homebridge/accessory.js} +34 -15
- package/dist/homebridge/accessory.js.map +1 -0
- package/dist/{index.d.ts → homebridge/index.d.ts} +0 -1
- package/dist/{index.js → homebridge/index.js} +1 -2
- package/dist/homebridge/index.js.map +1 -0
- package/dist/{platform.d.ts → homebridge/platform.d.ts} +3 -2
- package/dist/{platform.js → homebridge/platform.js} +20 -21
- package/dist/homebridge/platform.js.map +1 -0
- package/dist/lang/en.d.ts +4 -2
- package/dist/lang/en.js +6 -4
- package/dist/lang/en.js.map +1 -1
- package/dist/model/api.d.ts +11 -4
- package/dist/model/api.js +78 -44
- package/dist/model/api.js.map +1 -1
- package/dist/model/auth.d.ts +9 -4
- package/dist/model/auth.js +52 -8
- package/dist/model/auth.js.map +1 -1
- package/dist/model/device.d.ts +1 -0
- package/dist/model/device.js +2 -0
- package/dist/model/device.js.map +1 -1
- package/dist/model/types.d.ts +15 -0
- package/dist/model/types.js +8 -1
- package/dist/model/types.js.map +1 -1
- package/dist/tools/storage.d.ts +3 -0
- package/dist/tools/storage.js +22 -0
- package/dist/tools/storage.js.map +1 -0
- package/dist/{model → tools}/time.js.map +1 -1
- package/example_responses/get_locations.json +29 -0
- package/img/icon.png +0 -0
- package/img/screenshot_3.png +0 -0
- package/package.json +2 -2
- package/src/{accessory.ts → homebridge/accessory.ts} +43 -20
- package/src/{index.ts → homebridge/index.ts} +1 -3
- package/src/{platform.ts → homebridge/platform.ts} +26 -25
- package/src/homebridge-ui/public/index.html +73 -49
- package/src/lang/en.ts +6 -4
- package/src/model/api.ts +95 -47
- package/src/model/auth.ts +65 -8
- package/src/model/device.ts +2 -0
- package/src/model/types.ts +19 -0
- package/src/tools/storage.ts +26 -0
- package/dist/accessory.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/platform.js.map +0 -1
- /package/dist/{model → tools}/time.d.ts +0 -0
- /package/dist/{model → tools}/time.js +0 -0
- /package/src/{model → tools}/time.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to homebridge-flume will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 3.1.0 (2025-05-28)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Devices can now be excluded from HomeKit by adding device IDs in config
|
|
10
|
+
- Fetch device name from Flume location information
|
|
11
|
+
- Volume units for usage data can be changed in config
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Persist tokens across launches to avoid unnecessary authentication calls
|
|
16
|
+
- Limit the number of http retries with exponential backoff
|
|
17
|
+
- Beta versions no longer log unless "verbose" config flag is set to true
|
|
18
|
+
- Simplified config settings
|
|
19
|
+
- Redact all personal info in logs
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- `disableDeviceLogging` actually stops logging accessory changes
|
|
24
|
+
|
|
5
25
|
## 3.0.5 (2025-05-24)
|
|
6
26
|
|
|
7
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/banner.png" width="600">
|
|
2
|
+
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/banner.png?raw=true" width="600">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<span align="center">
|
|
@@ -23,11 +23,11 @@ This plugin is independently developed and is not in any way affiliated with or
|
|
|
23
23
|
|
|
24
24
|
Once you have completed [Configuration](https://github.com/mpatfield/homebridge-flume#configuration) you will see a new leak sensor pop up in your Home app. If the sensor detetcs a leak, you will receive a HomeKit notification and can setup automations to react to state changes.
|
|
25
25
|
|
|
26
|
-
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_1.png"> <img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_2.png">
|
|
26
|
+
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_1.png?raw=true"> <img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_2.png?raw=true">
|
|
27
27
|
|
|
28
28
|
If you use a more advanced HomeKit app like [Eve](https://apps.apple.com/us/app/eve-for-matter-homekit/id917695792) or [Controller for Homekit](https://apps.apple.com/us/app/controller-for-homekit/id1198176727), you will see some additional information about your water use. Unfortunately, Apple currently doesn't offer a way to display this in the Home app.
|
|
29
29
|
|
|
30
|
-
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_3.png">
|
|
30
|
+
<img src="https://github.com/mpatfield/homebridge-flume/blob/latest/img/screenshot_3.png?raw=true">
|
|
31
31
|
|
|
32
32
|
## Configuration
|
|
33
33
|
|
|
@@ -46,15 +46,21 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
|
|
|
46
46
|
"clientId": "1234567890ABCD",
|
|
47
47
|
"clientSecret": "1234567890ABCDEFGHIJ",
|
|
48
48
|
"refreshInterval": 1,
|
|
49
|
+
"units": "GALLONS",
|
|
49
50
|
"disableDeviceLogging": false,
|
|
51
|
+
"verbose": false,
|
|
52
|
+
"excludeDevices": ["1234567890", "9876543210"]
|
|
50
53
|
}
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
- `username` - (Required) Flume username
|
|
54
57
|
- `password` - (Required) Flume password
|
|
55
58
|
- `clientId`/`clientSecret` - (Required) Flume Client ID, found at [https://portal.flumetech.com](https://portal.flumetech.com)
|
|
56
|
-
- `refreshInterval` - (
|
|
57
|
-
- `
|
|
59
|
+
- `refreshInterval` - (Required) number of minutes between updates; must be `1` or more
|
|
60
|
+
- `units` - (Required) the type of units to use for custom characteristics
|
|
61
|
+
- `disableDeviceLogging` - (Optional) if true, then accessory status changes will not be logged
|
|
62
|
+
- `verbose` - (Optional) if true, there will be additional logging for debugging purposes
|
|
63
|
+
- `excludeDevices` - (Optional) a list of devices to exclude; look for `Adding new device: [Device ID]` in the logs
|
|
58
64
|
|
|
59
65
|
## Credits
|
|
60
66
|
|
package/config.schema.json
CHANGED
|
@@ -4,65 +4,80 @@
|
|
|
4
4
|
"singular": true,
|
|
5
5
|
"customUi": true,
|
|
6
6
|
"customUiPath": "./src/homebridge-ui",
|
|
7
|
-
"headerDisplay": "<p align=\"center\"><img width=\"60%\" src=\"https://github.com/mpatfield/homebridge-flume/blob/latest/img/banner.png?raw=true\"></p><p align=\"center\">For help and support please visit <a href=\"https://github.com/mpatfield/homebridge-flume/\">GitHub</a>. We hope you find this plugin useful!</p>",
|
|
8
7
|
"schema": {
|
|
9
8
|
"type": "object",
|
|
10
|
-
"required": ["username", "password", "clientId", "clientSecret", "refreshInterval"],
|
|
9
|
+
"required": ["username", "password", "clientId", "clientSecret", "refreshInterval", "units"],
|
|
11
10
|
"properties": {
|
|
12
11
|
"name": {
|
|
13
|
-
"title": "Plugin Name",
|
|
14
12
|
"type": "string",
|
|
13
|
+
"title": "Plugin Name",
|
|
15
14
|
"default": "Flume"
|
|
16
15
|
},
|
|
17
16
|
"username": {
|
|
18
|
-
"title": "Flume Username",
|
|
19
17
|
"type": "string",
|
|
18
|
+
"title": "Flume Username",
|
|
20
19
|
"required": true
|
|
21
20
|
},
|
|
22
21
|
"password": {
|
|
23
|
-
"title": "Flume Password",
|
|
24
22
|
"type": "string",
|
|
23
|
+
"title": "Flume Password",
|
|
25
24
|
"required": true
|
|
26
25
|
},
|
|
27
26
|
"clientId": {
|
|
28
|
-
"title": "Client ID",
|
|
29
27
|
"type": "string",
|
|
28
|
+
"title": "Client ID",
|
|
30
29
|
"placeholder": "1234567890ABCD",
|
|
31
30
|
"required": true
|
|
32
31
|
},
|
|
33
32
|
"clientSecret": {
|
|
34
|
-
"title": "Client Secret",
|
|
35
33
|
"type": "string",
|
|
34
|
+
"title": "Client Secret",
|
|
35
|
+
"description": "Your Flume Client ID and Client Secret can be found at https://portal.flumetech.com",
|
|
36
36
|
"placeholder": "1234567890ABCDEFGHIJ",
|
|
37
|
-
"required": true
|
|
38
|
-
|
|
37
|
+
"required": true
|
|
38
|
+
},
|
|
39
|
+
"refreshInterval": {
|
|
40
|
+
"type": "integer",
|
|
41
|
+
"title": "Refresh Interval",
|
|
42
|
+
"description": "Number of minutes between requests to Flume for leak information",
|
|
43
|
+
"default": 2,
|
|
44
|
+
"minimum": 1,
|
|
45
|
+
"required": true
|
|
46
|
+
},
|
|
47
|
+
"units": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"title": "Units",
|
|
50
|
+
"description": "Volume units to use for custom characteristics",
|
|
51
|
+
"enum": ["GALLONS", "LITERS", "CUBIC_FEET", "CUBIC_METERS"],
|
|
52
|
+
"enumNames": ["Gallons", "Liters", "Cubic Feet", "Cubic Meters"],
|
|
53
|
+
"default": "GALLONS",
|
|
54
|
+
"required": true
|
|
39
55
|
},
|
|
40
56
|
"disableDeviceLogging": {
|
|
41
57
|
"type": "boolean",
|
|
42
58
|
"title": "Disable Device Logging",
|
|
59
|
+
"description": "If true then accessory status changes will not be logged",
|
|
43
60
|
"default": false,
|
|
44
|
-
"
|
|
61
|
+
"required": false
|
|
45
62
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
63
|
+
"verbose": {
|
|
64
|
+
"type": "boolean",
|
|
65
|
+
"title": "Verbose",
|
|
66
|
+
"description": "Enable additional debug logging",
|
|
67
|
+
"required": false
|
|
68
|
+
},
|
|
69
|
+
"excludeDevices": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"title": "Exclude devices",
|
|
72
|
+
"description": "List of devices to exclude from HomeKit -- look for \"Adding new device: [Device ID]\" in the logs",
|
|
73
|
+
"items": {
|
|
74
|
+
"title": "Device ID",
|
|
75
|
+
"type": "string"
|
|
76
|
+
},
|
|
77
|
+
"uniqueItems": true,
|
|
78
|
+
"default": [],
|
|
79
|
+
"required": false
|
|
52
80
|
}
|
|
53
81
|
}
|
|
54
|
-
}
|
|
55
|
-
"layout": [
|
|
56
|
-
{
|
|
57
|
-
"type": "fieldset",
|
|
58
|
-
"title": "Required Settings",
|
|
59
|
-
"items": ["username", "password", "clientId", "clientSecret"]
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"type": "fieldset",
|
|
63
|
-
"title": "Advanced Settings",
|
|
64
|
-
"expandable": true,
|
|
65
|
-
"items": ["disableDeviceLogging", "refreshInterval"]
|
|
66
|
-
}
|
|
67
|
-
]
|
|
82
|
+
}
|
|
68
83
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { PlatformAccessory } from 'homebridge';
|
|
2
2
|
import { FlumePlatform } from './platform.js';
|
|
3
|
-
import { Device } from '
|
|
3
|
+
import { Device } from '../model/device.js';
|
|
4
|
+
import { VolumeUnits } from '../model/types.js';
|
|
4
5
|
export declare class FlumeAccessory {
|
|
5
|
-
readonly platform
|
|
6
|
-
readonly accessory
|
|
7
|
-
readonly device
|
|
6
|
+
private readonly platform;
|
|
7
|
+
private readonly accessory;
|
|
8
|
+
private readonly device;
|
|
9
|
+
private readonly units;
|
|
10
|
+
private readonly disableLogging;
|
|
8
11
|
private readonly HAP;
|
|
9
12
|
private readonly Characteristic;
|
|
10
13
|
private readonly Service;
|
|
@@ -18,9 +21,11 @@ export declare class FlumeAccessory {
|
|
|
18
21
|
private readonly todayUsageChar;
|
|
19
22
|
private readonly monthUsageChar;
|
|
20
23
|
private readonly lastMonthUsageChar;
|
|
21
|
-
constructor(platform: FlumePlatform, accessory: PlatformAccessory, device: Device);
|
|
24
|
+
constructor(platform: FlumePlatform, accessory: PlatformAccessory, device: Device, name: string | null | undefined, units: VolumeUnits, disableLogging: boolean);
|
|
22
25
|
private handleUpdate;
|
|
23
26
|
private updateCharacteristics;
|
|
27
|
+
private stringForUnits;
|
|
28
|
+
private clearCustomCharacteristics;
|
|
24
29
|
private attachCustomCharacteristic;
|
|
25
30
|
private logState;
|
|
26
31
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import strings from '
|
|
1
|
+
import strings from '../lang/en.js';
|
|
2
|
+
import { VolumeUnits } from '../model/types.js';
|
|
2
3
|
class CustomCharacteristic {
|
|
3
4
|
uuid;
|
|
4
5
|
name;
|
|
@@ -10,11 +11,12 @@ class CustomCharacteristic {
|
|
|
10
11
|
const TODAY_USAGE = new CustomCharacteristic('f25cc272-83cb-46a7-915a-259fa17364ed', strings.todayUsage);
|
|
11
12
|
const MONTH_USAGE = new CustomCharacteristic('580e224d-edf2-4c23-af79-cdbebfc509c5', strings.monthUsage);
|
|
12
13
|
const LAST_MONTH_USAGE = new CustomCharacteristic('69129d54-bdb8-46a1-a93b-f7e8d16d32a8', strings.lastMonth);
|
|
13
|
-
const LEGACY_CHARS = ['Month Usage', 'Previous Month', 'Today Usage'];
|
|
14
14
|
export class FlumeAccessory {
|
|
15
15
|
platform;
|
|
16
16
|
accessory;
|
|
17
17
|
device;
|
|
18
|
+
units;
|
|
19
|
+
disableLogging;
|
|
18
20
|
HAP;
|
|
19
21
|
Characteristic;
|
|
20
22
|
Service;
|
|
@@ -28,20 +30,21 @@ export class FlumeAccessory {
|
|
|
28
30
|
todayUsageChar;
|
|
29
31
|
monthUsageChar;
|
|
30
32
|
lastMonthUsageChar;
|
|
31
|
-
constructor(platform, accessory, device) {
|
|
33
|
+
constructor(platform, accessory, device, name, units, disableLogging) {
|
|
32
34
|
this.platform = platform;
|
|
33
35
|
this.accessory = accessory;
|
|
34
36
|
this.device = device;
|
|
37
|
+
this.units = units;
|
|
38
|
+
this.disableLogging = disableLogging;
|
|
35
39
|
this.HAP = platform.api.hap;
|
|
36
40
|
this.Characteristic = this.HAP.Characteristic;
|
|
37
41
|
this.Service = this.HAP.Service;
|
|
38
42
|
accessory.getService(this.Service.AccessoryInformation)
|
|
39
|
-
.setCharacteristic(this.Characteristic.Name, strings.brand)
|
|
40
|
-
.setCharacteristic(this.Characteristic.ConfiguredName, strings.brand)
|
|
43
|
+
.setCharacteristic(this.Characteristic.Name, name ?? strings.brand)
|
|
44
|
+
.setCharacteristic(this.Characteristic.ConfiguredName, name ?? strings.brand)
|
|
41
45
|
.setCharacteristic(this.Characteristic.Manufacturer, strings.brand)
|
|
42
46
|
.setCharacteristic(this.Characteristic.SerialNumber, device.id)
|
|
43
47
|
.setCharacteristic(this.Characteristic.Model, device.productName)
|
|
44
|
-
.setCharacteristic(this.Characteristic.Identify, true)
|
|
45
48
|
.setCharacteristic(this.Characteristic.FirmwareRevision, platform.packageVersion);
|
|
46
49
|
this.charLeakDetected = this.Characteristic.LeakDetected;
|
|
47
50
|
this.charStatusLowBattery = this.Characteristic.StatusLowBattery;
|
|
@@ -51,16 +54,10 @@ export class FlumeAccessory {
|
|
|
51
54
|
this.isLeakDetected = this.leakService.getCharacteristic(this.charLeakDetected).value === this.charLeakDetected.LEAK_DETECTED;
|
|
52
55
|
this.isBatteryLow = this.leakService.getCharacteristic(this.charStatusLowBattery).value === this.charStatusLowBattery.BATTERY_LEVEL_LOW;
|
|
53
56
|
this.isDisconnected = this.leakService.getCharacteristic(this.charStatusFault).value === this.charStatusFault.GENERAL_FAULT;
|
|
57
|
+
this.clearCustomCharacteristics();
|
|
54
58
|
this.todayUsageChar = this.attachCustomCharacteristic(TODAY_USAGE);
|
|
55
59
|
this.monthUsageChar = this.attachCustomCharacteristic(MONTH_USAGE);
|
|
56
60
|
this.lastMonthUsageChar = this.attachCustomCharacteristic(LAST_MONTH_USAGE);
|
|
57
|
-
// Remove no longer used characteristics if they exists
|
|
58
|
-
LEGACY_CHARS.forEach((name) => {
|
|
59
|
-
if (this.leakService.testCharacteristic(name)) {
|
|
60
|
-
const legacyChar = this.leakService.getCharacteristic(name);
|
|
61
|
-
this.leakService.removeCharacteristic(legacyChar);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
61
|
device.setOnUpdateCallback(this.handleUpdate.bind(this));
|
|
65
62
|
this.updateCharacteristics();
|
|
66
63
|
}
|
|
@@ -92,18 +89,38 @@ export class FlumeAccessory {
|
|
|
92
89
|
this.monthUsageChar.updateValue(this.device.usageMonth);
|
|
93
90
|
this.lastMonthUsageChar.updateValue(this.device.usageLastMonth);
|
|
94
91
|
}
|
|
92
|
+
stringForUnits() {
|
|
93
|
+
switch (this.units) {
|
|
94
|
+
case VolumeUnits.GALLONS: return strings.customCharUnitsGallons;
|
|
95
|
+
case VolumeUnits.LITERS: return strings.customCharUnitsLiters;
|
|
96
|
+
case VolumeUnits.CUBIC_FEET: return strings.customCharUnitsCubicFeet;
|
|
97
|
+
case VolumeUnits.CUBIC_METERS: return strings.customCharUnitsCubicMeters;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
clearCustomCharacteristics() {
|
|
101
|
+
const allowedUUIDs = new Set([
|
|
102
|
+
this.charLeakDetected.UUID,
|
|
103
|
+
this.charStatusLowBattery.UUID,
|
|
104
|
+
this.charStatusFault.UUID,
|
|
105
|
+
]);
|
|
106
|
+
const charsToRemove = this.leakService.characteristics.filter(char => !allowedUUIDs.has(char.UUID));
|
|
107
|
+
charsToRemove.forEach(char => {
|
|
108
|
+
this.leakService.removeCharacteristic(char);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
95
111
|
attachCustomCharacteristic(char) {
|
|
96
112
|
let result;
|
|
97
113
|
if (this.leakService.testCharacteristic(char.name)) {
|
|
98
114
|
result = this.leakService.getCharacteristic(char.name);
|
|
99
115
|
}
|
|
100
116
|
else {
|
|
117
|
+
const unitsString = this.stringForUnits();
|
|
101
118
|
const customCharacteristic = class TodayUsage extends this.Characteristic {
|
|
102
119
|
constructor() {
|
|
103
120
|
super(char.name, char.uuid, {
|
|
104
121
|
format: "uint32" /* Formats.UINT32 */,
|
|
105
122
|
perms: ["pr" /* Perms.PAIRED_READ */, "ev" /* Perms.NOTIFY */],
|
|
106
|
-
unit:
|
|
123
|
+
unit: unitsString,
|
|
107
124
|
});
|
|
108
125
|
this.value = this.getDefaultValue();
|
|
109
126
|
}
|
|
@@ -114,7 +131,9 @@ export class FlumeAccessory {
|
|
|
114
131
|
return result;
|
|
115
132
|
}
|
|
116
133
|
logState(level, message) {
|
|
117
|
-
|
|
134
|
+
if (!this.disableLogging) {
|
|
135
|
+
this.platform.log.log(level, '[%s] %s', this.device.id, message);
|
|
136
|
+
}
|
|
118
137
|
}
|
|
119
138
|
}
|
|
120
139
|
//# sourceMappingURL=accessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../../src/homebridge/accessory.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,oBAAoB;IACH;IAAuB;IAA5C,YAAqB,IAAY,EAAW,IAAY;QAAnC,SAAI,GAAJ,IAAI,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAQ;IACxD,CAAC;CACF;AAED,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACzG,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACzG,MAAM,gBAAgB,GAAG,IAAI,oBAAoB,CAAC,sCAAsC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;AAE7G,MAAM,OAAO,cAAc;IAoBN;IACA;IACA;IAEA;IACA;IAxBF,GAAG,CAAM;IACT,cAAc,CAAwB;IACtC,OAAO,CAAiB;IAExB,WAAW,CAAU;IAE9B,cAAc,GAAY,KAAK,CAAC;IAChC,YAAY,GAAY,KAAK,CAAC;IAC9B,cAAc,GAAY,IAAI,CA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C;YACF,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;YAClE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,QAAQ,CAAC,KAAe,EAAE,OAAe;QAC/C,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/homebridge/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE9D;;GAEG;AACH,eAAe,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig } from 'homebridge';
|
|
2
|
-
import { Device } from '
|
|
2
|
+
import { Device } from '../model/device.js';
|
|
3
|
+
export declare const PLATFORM_ALIAS = "Flume";
|
|
3
4
|
export declare class FlumePlatform implements DynamicPlatformPlugin {
|
|
4
5
|
readonly log: Logger;
|
|
5
6
|
readonly config: PlatformConfig;
|
|
6
7
|
readonly api: API;
|
|
7
|
-
private
|
|
8
|
+
private readonly storagePath;
|
|
8
9
|
private flumeAPI;
|
|
9
10
|
private readonly accessories;
|
|
10
11
|
constructor(log: Logger, config: PlatformConfig, api: API);
|
|
@@ -2,28 +2,26 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { FlumeAccessory } from './accessory.js';
|
|
5
|
-
import strings from '
|
|
6
|
-
import { FlumeAPI } from '
|
|
7
|
-
import {
|
|
5
|
+
import strings from '../lang/en.js';
|
|
6
|
+
import { FlumeAPI } from '../model/api.js';
|
|
7
|
+
import { STORAGE_FILE_NAME } from '../tools/storage.js';
|
|
8
|
+
import { VolumeUnits } from '../model/types.js';
|
|
9
|
+
export const PLATFORM_ALIAS = 'Flume';
|
|
8
10
|
const PLUGIN_NAME = 'homebridge-flume';
|
|
9
11
|
export class FlumePlatform {
|
|
10
12
|
log;
|
|
11
13
|
config;
|
|
12
14
|
api;
|
|
13
|
-
|
|
15
|
+
storagePath;
|
|
14
16
|
flumeAPI = null;
|
|
15
17
|
accessories = new Map();
|
|
16
18
|
constructor(log, config, api) {
|
|
17
19
|
this.log = log;
|
|
18
20
|
this.config = config;
|
|
19
21
|
this.api = api;
|
|
22
|
+
this.storagePath = path.join(api.user.storagePath(), STORAGE_FILE_NAME);
|
|
20
23
|
const packageVersion = this.packageVersion;
|
|
21
|
-
this.isBeta = this.packageVersion.includes('beta');
|
|
22
24
|
this.log.info('v%s | System %s | Node %s | HB v%s | HAPNodeJS v%s', packageVersion, process.platform, process.version, api.serverVersion, api.hap.HAPLibraryVersion());
|
|
23
|
-
if (this.isBeta) {
|
|
24
|
-
const divide = '*'.repeat(strings.beta.length);
|
|
25
|
-
this.log.warn(`\n${divide}\n${strings.beta}\n${divide}`);
|
|
26
|
-
}
|
|
27
25
|
this.api.on('didFinishLaunching', () => this.didFinishLaunching());
|
|
28
26
|
this.api.on('shutdown', () => this.shutdown());
|
|
29
27
|
}
|
|
@@ -36,8 +34,9 @@ export class FlumePlatform {
|
|
|
36
34
|
this.log.error(strings.badConfig);
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
|
-
this.flumeAPI = await FlumeAPI.connect(this.config.username, this.config.password, this.config.clientId, this.config.clientSecret, this.config.refreshInterval, this.log, this.
|
|
40
|
-
const
|
|
37
|
+
this.flumeAPI = await FlumeAPI.connect(this.config.username, this.config.password, this.config.clientId, this.config.clientSecret, this.config.refreshInterval, this.config.units ?? VolumeUnits.GALLONS, this.storagePath, this.log, this.config.verbose);
|
|
38
|
+
const excludeDevices = new Set(this.config.excludeDevices ?? []);
|
|
39
|
+
const devices = this.flumeAPI.devices.filter((device) => !excludeDevices.has(device.id));
|
|
41
40
|
if (devices.length === 0) {
|
|
42
41
|
this.accessories.forEach((accessory) => this.removeAccessory(accessory));
|
|
43
42
|
this.log.warn(strings.noDevices);
|
|
@@ -63,16 +62,16 @@ export class FlumePlatform {
|
|
|
63
62
|
initializeDevice(device) {
|
|
64
63
|
const uuid = this.api.hap.uuid.generate(device.id);
|
|
65
64
|
let accessory = this.accessories.get(uuid);
|
|
66
|
-
if (accessory) {
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
if (!accessory) {
|
|
66
|
+
this.log.info(strings.newDevice, device.id);
|
|
67
|
+
accessory = new this.api.platformAccessory(strings.brand, uuid);
|
|
68
|
+
accessory.context.deviceId = device.id;
|
|
69
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_ALIAS, [accessory]);
|
|
70
|
+
this.accessories.set(uuid, accessory);
|
|
69
71
|
}
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
accessory
|
|
73
|
-
new FlumeAccessory(this, accessory, device);
|
|
74
|
-
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_ALIAS, [accessory]);
|
|
75
|
-
this.accessories.set(uuid, accessory);
|
|
72
|
+
const name = this.flumeAPI?.locationNames.get(device.locationId);
|
|
73
|
+
const units = this.config.units ?? VolumeUnits.GALLONS;
|
|
74
|
+
new FlumeAccessory(this, accessory, device, name, units, this.config.disableDeviceLogging);
|
|
76
75
|
}
|
|
77
76
|
configureAccessory(accessory) {
|
|
78
77
|
this.log.info(strings.restoringDevice, accessory.context.deviceId);
|
|
@@ -86,7 +85,7 @@ export class FlumePlatform {
|
|
|
86
85
|
get packageVersion() {
|
|
87
86
|
try {
|
|
88
87
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
89
|
-
const packageJSONPath = path.join(__dirname, '
|
|
88
|
+
const packageJSONPath = path.join(__dirname, '../../package.json');
|
|
90
89
|
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, { encoding: 'utf8' }));
|
|
91
90
|
return packageJSON.version;
|
|
92
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/homebridge/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AACtC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAEvC,MAAM,OAAO,aAAa;IAQb;IACA;IACA;IARM,WAAW,CAAS;IAC7B,QAAQ,GAAoB,IAAI,CAAC;IAExB,WAAW,GAAmC,IAAI,GAAG,EAAE,CAAC;IAEzE,YACW,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAGjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAExE,MAA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AAO,CAAC,eAAe,EAAE,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,eAAe,CAAC,SAA4B;QAC1C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC,WAAW,EAAE,cAAc,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,cAAc;QAChB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACnE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YACvF,OAAO,WAAW,CAAC,OAAO,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;CACF"}
|
package/dist/lang/en.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
declare const langEn: {
|
|
2
2
|
brand: string;
|
|
3
3
|
redacted: string;
|
|
4
|
-
beta: string;
|
|
5
4
|
complete: string;
|
|
6
5
|
newDevice: string;
|
|
7
6
|
removeDevice: string;
|
|
@@ -18,7 +17,10 @@ declare const langEn: {
|
|
|
18
17
|
connectionNormal: string;
|
|
19
18
|
leakDetected: string;
|
|
20
19
|
leakNotDetected: string;
|
|
21
|
-
|
|
20
|
+
customCharUnitsGallons: string;
|
|
21
|
+
customCharUnitsLiters: string;
|
|
22
|
+
customCharUnitsCubicFeet: string;
|
|
23
|
+
customCharUnitsCubicMeters: string;
|
|
22
24
|
lastMonth: string;
|
|
23
25
|
monthUsage: string;
|
|
24
26
|
todayUsage: string;
|
package/dist/lang/en.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const langEn = {
|
|
2
2
|
// General
|
|
3
3
|
brand: 'Flume',
|
|
4
|
-
redacted: 'redacted',
|
|
4
|
+
redacted: '****redacted****',
|
|
5
5
|
// Startup
|
|
6
|
-
beta: 'This is a beta version of Flume. You will experience more logging than normal.',
|
|
7
6
|
complete: '✓ Setup complete.',
|
|
8
7
|
newDevice: 'Adding new device:',
|
|
9
8
|
removeDevice: 'Removing device:',
|
|
@@ -19,7 +18,7 @@ const langEn = {
|
|
|
19
18
|
noDataReceived: 'No data received from http request',
|
|
20
19
|
noDevices: 'No devices were found in your account',
|
|
21
20
|
noRefreshToken: 'No refresh token has been retrieved. Performing full auth instead…',
|
|
22
|
-
httpRetry: 'Request failed. Retrying in %s
|
|
21
|
+
httpRetry: 'Request failed. Retrying in %s minutes…',
|
|
23
22
|
// Status
|
|
24
23
|
batteryLow: 'Battery is low',
|
|
25
24
|
batteryNormal: 'Battery is normal',
|
|
@@ -28,7 +27,10 @@ const langEn = {
|
|
|
28
27
|
leakDetected: 'Leak detected!',
|
|
29
28
|
leakNotDetected: 'No leaks detected',
|
|
30
29
|
// Custom Characteristic
|
|
31
|
-
|
|
30
|
+
customCharUnitsGallons: 'Gallons',
|
|
31
|
+
customCharUnitsLiters: 'Liters',
|
|
32
|
+
customCharUnitsCubicFeet: 'Cubic Feet',
|
|
33
|
+
customCharUnitsCubicMeters: 'Cubic Meters',
|
|
32
34
|
lastMonth: 'Last Month',
|
|
33
35
|
monthUsage: 'This Month',
|
|
34
36
|
todayUsage: 'Today',
|
package/dist/lang/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/lang/en.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IAEb,UAAU;IACV,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/lang/en.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IAEb,UAAU;IACV,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,kBAAkB;IAE5B,UAAU;IACV,QAAQ,EAAE,mBAAmB;IAC7B,SAAS,EAAE,oBAAoB;IAC/B,YAAY,EAAE,kBAAkB;IAChC,eAAe,EAAE,mBAAmB;IACpC,eAAe,EAAE;QACf,4GAA4G;QAC5G,8EAA8E;QAC9E,gFAAgF;QAChF,4HAA4H;KAC7H;IAED,SAAS;IACT,SAAS,EAAE,2IAA2I;IACtJ,cAAc,EAAE,oCAAoC;IACpD,SAAS,EAAE,uCAAuC;IAClD,cAAc,EAAE,oEAAoE;IACpF,SAAS,EAAE,yCAAyC;IAEpD,SAAS;IACT,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,eAAe,EAAE,wBAAwB;IACzC,gBAAgB,EAAE,qBAAqB;IACvC,YAAY,EAAE,gBAAgB;IAC9B,eAAe,EAAE,mBAAmB;IAEpC,wBAAwB;IACxB,sBAAsB,EAAE,SAAS;IACjC,qBAAqB,EAAE,QAAQ;IAC/B,wBAAwB,EAAE,YAAY;IACtC,0BAA0B,EAAE,cAAc;IAC1C,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,OAAO;CACpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/model/api.d.ts
CHANGED
|
@@ -7,28 +7,35 @@ export declare class FlumeAPI {
|
|
|
7
7
|
private readonly clientId;
|
|
8
8
|
private readonly clientSecret;
|
|
9
9
|
private readonly refreshInterval;
|
|
10
|
+
private readonly units;
|
|
11
|
+
private storagePath;
|
|
10
12
|
private readonly log;
|
|
11
|
-
private readonly
|
|
12
|
-
private
|
|
13
|
+
private readonly verbose;
|
|
14
|
+
private _auth?;
|
|
13
15
|
private userId?;
|
|
16
|
+
readonly locationNames: Map<string, string>;
|
|
14
17
|
private readonly _devices;
|
|
18
|
+
private retryIndex;
|
|
15
19
|
private syncTimer;
|
|
16
20
|
private lastFullRefresh;
|
|
17
21
|
private constructor();
|
|
18
|
-
static connect(username: string, password: string, clientId: string, clientSecret: string, refreshInterval: number, log: Logger,
|
|
22
|
+
static connect(username: string, password: string, clientId: string, clientSecret: string, refreshInterval: number, units: Types.VolumeUnits, storagePath: string, log: Logger, verbose: boolean): Promise<FlumeAPI>;
|
|
19
23
|
get devices(): Device[];
|
|
20
24
|
teardown(): void;
|
|
21
25
|
private do;
|
|
22
26
|
private retryIfPossible;
|
|
27
|
+
private get auth();
|
|
28
|
+
private set auth(value);
|
|
23
29
|
private authenticate;
|
|
24
30
|
private authRefresh;
|
|
25
31
|
private refreshAuthIfNecessary;
|
|
26
32
|
private startSyncTimer;
|
|
33
|
+
private getLocations;
|
|
27
34
|
private getDevices;
|
|
28
35
|
private getDeviceData;
|
|
29
36
|
getLeakData(deviceId: string): Promise<Types.LeakData | null>;
|
|
30
37
|
private getUsageData;
|
|
31
38
|
private synchronizeData;
|
|
32
39
|
private logHTTP;
|
|
33
|
-
private
|
|
40
|
+
private logIfVerbose;
|
|
34
41
|
}
|