homebridge-eggtimer-plugin 1.1.1 → 1.1.2
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/.github/workflows/audit.yml +1 -1
- package/.github/workflows/build-homebridge2.0.yml +1 -1
- package/.github/workflows/build.yml +1 -1
- package/.github/workflows/corepack.yml +1 -1
- package/.github/workflows/npm-publish.yml +2 -2
- package/dist/accessory.d.ts.map +1 -1
- package/dist/accessory.js.map +1 -1
- package/eslint.config.mjs +30 -0
- package/package.json +7 -6
- package/src/accessory.ts +63 -30
- package/eslint.config.js +0 -36
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
- uses: pnpm/action-setup@v4
|
|
20
20
|
- run: |
|
|
21
21
|
sed -i -e 's/"homebridge": "\^[0-9]\.[0-9]\.[0-9]/"homebridge": "^2.0.0-beta.0/g' package.json
|
|
22
|
-
- uses: actions/setup-node@v4.
|
|
22
|
+
- uses: actions/setup-node@v4.3.0
|
|
23
23
|
with:
|
|
24
24
|
node-version: latest
|
|
25
25
|
cache: pnpm
|
|
@@ -13,7 +13,7 @@ jobs:
|
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v4
|
|
15
15
|
- uses: pnpm/action-setup@v4
|
|
16
|
-
- uses: actions/setup-node@v4.
|
|
16
|
+
- uses: actions/setup-node@v4.3.0
|
|
17
17
|
with:
|
|
18
18
|
node-version: latest
|
|
19
19
|
cache: pnpm
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
ref: main
|
|
37
37
|
fetch-tags: true
|
|
38
38
|
- uses: pnpm/action-setup@v4
|
|
39
|
-
- uses: actions/setup-node@v4.
|
|
39
|
+
- uses: actions/setup-node@v4.3.0
|
|
40
40
|
with:
|
|
41
41
|
node-version: latest
|
|
42
42
|
cache: pnpm
|
package/dist/accessory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessory.d.ts","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAKJ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"accessory.d.ts","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAKJ,MAAM,YAAY,CAAC;yBAyMV,KAAK,GAAG;AAAlB,kBAKE"}
|
package/dist/accessory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":";;;;AAUA,+CAKsB;AAEtB,4DAAmC;AAEnC,MAAM,YAAY;IAehB,YAAY,GAAY,EAAE,MAAuB,EAAE,GAAQ;QAJnD,eAAU,GAAG,CAAC,CAAC;QAKrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAE3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpE,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;aAChE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC5B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEhC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC;aACxE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC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gBACzD,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;YAED,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,iBAAiB,CACnB,cAAc,EACd,YAAY,CACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import eslint from '@eslint/js';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
import stylistic from '@stylistic/eslint-plugin'
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
eslint.configs.recommended,
|
|
9
|
+
tseslint.configs.strictTypeChecked,
|
|
10
|
+
stylistic.configs.all,
|
|
11
|
+
stylistic.configs.customize(
|
|
12
|
+
{
|
|
13
|
+
indent: 2,
|
|
14
|
+
quotes: "double",
|
|
15
|
+
commaDangle: "never",
|
|
16
|
+
quoteProps: "as-needed",
|
|
17
|
+
arrowParens: false,
|
|
18
|
+
blockSpacing: true,
|
|
19
|
+
braceStyle: "1tbs",
|
|
20
|
+
semi: true
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
{
|
|
24
|
+
languageOptions: {
|
|
25
|
+
parserOptions: {
|
|
26
|
+
project: true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-eggtimer-plugin",
|
|
3
3
|
"displayName": "Homebridge Eggtimer Plugin",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Egg Timers for Homebridge: https://github.com/nfarina/homebridge",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
"homebridge": ">=1.3.5 || ^2.0.0-beta.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@
|
|
35
|
+
"@eslint/js": "^9.23.0",
|
|
36
|
+
"@stylistic/eslint-plugin": "^4.2.0",
|
|
36
37
|
"@types/async-lock": "^1.4.2",
|
|
37
|
-
"@types/node": "^22.13.
|
|
38
|
+
"@types/node": "^22.13.17",
|
|
38
39
|
"@types/node-persist": "^3.1.8",
|
|
39
|
-
"eslint": "^9.
|
|
40
|
+
"eslint": "^9.23.0",
|
|
40
41
|
"homebridge": "^1.9.0",
|
|
41
42
|
"rimraf": "^6.0.1",
|
|
42
43
|
"ts-node": "^10.9.2",
|
|
43
|
-
"typescript": "^5.
|
|
44
|
-
"typescript-eslint": "^8.
|
|
44
|
+
"typescript": "^5.8.2",
|
|
45
|
+
"typescript-eslint": "^8.29.0"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"async-lock": "^1.4.1",
|
package/src/accessory.ts
CHANGED
|
@@ -49,8 +49,14 @@ class EggTimerBulb implements AccessoryPlugin {
|
|
|
49
49
|
.onSet(this.setBrightness.bind(this));
|
|
50
50
|
|
|
51
51
|
this.informationService = new this.hap.Service.AccessoryInformation()
|
|
52
|
-
.setCharacteristic(
|
|
53
|
-
|
|
52
|
+
.setCharacteristic(
|
|
53
|
+
this.hap.Characteristic.Manufacturer,
|
|
54
|
+
"Egg Timer Bulb"
|
|
55
|
+
)
|
|
56
|
+
.setCharacteristic(
|
|
57
|
+
this.hap.Characteristic.Model,
|
|
58
|
+
`${config.name} (${this.interval.toString()}ms)`
|
|
59
|
+
);
|
|
54
60
|
|
|
55
61
|
this.stateful = config.stateful === true;
|
|
56
62
|
this.storageKey = `${config.name}-${this.interval.toString()}`;
|
|
@@ -112,13 +118,22 @@ class EggTimerBulb implements AccessoryPlugin {
|
|
|
112
118
|
|
|
113
119
|
private async updateBrightness(value: number): Promise<void> {
|
|
114
120
|
this.log.debug(`Brightness: ${this.brightness.toString()} -> ${value.toString()}`);
|
|
115
|
-
this.brightness = Math.max(
|
|
121
|
+
this.brightness = Math.max(
|
|
122
|
+
0,
|
|
123
|
+
Math.min(
|
|
124
|
+
100,
|
|
125
|
+
value
|
|
126
|
+
)
|
|
127
|
+
);
|
|
116
128
|
|
|
117
129
|
// Persist state
|
|
118
130
|
if (this.stateful) {
|
|
119
131
|
if (this.brightness > 0) {
|
|
120
132
|
this.log.debug("Caching state");
|
|
121
|
-
await set(
|
|
133
|
+
await set(
|
|
134
|
+
this.storageKey,
|
|
135
|
+
this.brightness
|
|
136
|
+
);
|
|
122
137
|
} else {
|
|
123
138
|
this.log.debug("Deleting state");
|
|
124
139
|
await del(this.storageKey);
|
|
@@ -127,20 +142,32 @@ class EggTimerBulb implements AccessoryPlugin {
|
|
|
127
142
|
|
|
128
143
|
// Update HomeKit
|
|
129
144
|
const isActive = this.brightness > 0;
|
|
130
|
-
this.lightbulbService.updateCharacteristic(
|
|
131
|
-
|
|
145
|
+
this.lightbulbService.updateCharacteristic(
|
|
146
|
+
this.hap.Characteristic.Brightness,
|
|
147
|
+
this.brightness
|
|
148
|
+
);
|
|
149
|
+
this.lightbulbService.updateCharacteristic(
|
|
150
|
+
this.hap.Characteristic.On,
|
|
151
|
+
isActive
|
|
152
|
+
);
|
|
132
153
|
if (this.occupancyService !== undefined) {
|
|
133
|
-
this.occupancyService.updateCharacteristic(
|
|
154
|
+
this.occupancyService.updateCharacteristic(
|
|
155
|
+
this.hap.Characteristic.OccupancyDetected,
|
|
156
|
+
isActive
|
|
157
|
+
);
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
// Update Timer
|
|
137
161
|
if (isActive && this.timer === undefined) {
|
|
138
162
|
this.log.info("Starting timer");
|
|
139
|
-
this.timer = setInterval(
|
|
140
|
-
|
|
141
|
-
this.
|
|
142
|
-
|
|
143
|
-
|
|
163
|
+
this.timer = setInterval(
|
|
164
|
+
() => {
|
|
165
|
+
this.updateBrightness(this.brightness - 1).catch((error: unknown) => {
|
|
166
|
+
this.log.error(String(error));
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
this.interval
|
|
170
|
+
);
|
|
144
171
|
} else if (this.brightness === 0) {
|
|
145
172
|
this.log.info("Timer completed.");
|
|
146
173
|
clearInterval(this.timer);
|
|
@@ -153,30 +180,36 @@ class EggTimerBulb implements AccessoryPlugin {
|
|
|
153
180
|
return;
|
|
154
181
|
}
|
|
155
182
|
|
|
156
|
-
await this.lock.acquire(
|
|
183
|
+
await this.lock.acquire(
|
|
184
|
+
"restoreState",
|
|
185
|
+
async () => {
|
|
157
186
|
// Double-lock
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
187
|
+
if (this.stateRestored) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this.log.debug("Checking for stored state.");
|
|
192
|
+
await init({
|
|
193
|
+
expiredInterval: 1000 * 60 * 60 * 24 * 14, // Delete cached items after 14 days.
|
|
194
|
+
forgiveParseErrors: true,
|
|
195
|
+
dir: this.storageDir
|
|
196
|
+
});
|
|
161
197
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
198
|
+
const value = await get(this.storageKey) as number | undefined;
|
|
199
|
+
if (value !== undefined && value > 0) {
|
|
200
|
+
this.log.info(`Restoring state to: ${value.toString()}`);
|
|
201
|
+
await this.updateBrightness(value);
|
|
202
|
+
}
|
|
168
203
|
|
|
169
|
-
|
|
170
|
-
if (value !== undefined && value > 0) {
|
|
171
|
-
this.log.info(`Restoring state to: ${value.toString()}`);
|
|
172
|
-
await this.updateBrightness(value);
|
|
204
|
+
this.stateRestored = true;
|
|
173
205
|
}
|
|
174
|
-
|
|
175
|
-
this.stateRestored = true;
|
|
176
|
-
});
|
|
206
|
+
);
|
|
177
207
|
}
|
|
178
208
|
}
|
|
179
209
|
|
|
180
210
|
export = (api: API) => {
|
|
181
|
-
api.registerAccessory(
|
|
211
|
+
api.registerAccessory(
|
|
212
|
+
"EggTimerBulb",
|
|
213
|
+
EggTimerBulb
|
|
214
|
+
);
|
|
182
215
|
};
|
package/eslint.config.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
-
// @ts-check
|
|
3
|
-
|
|
4
|
-
//import eslint from "@eslint/js";
|
|
5
|
-
const eslint = require('@eslint/js')
|
|
6
|
-
//import tseslint from "typescript-eslint";
|
|
7
|
-
const tseslint = require('typescript-eslint')
|
|
8
|
-
//import stylistic from "@stylistic/eslint-plugin";
|
|
9
|
-
const stylistic = require('@stylistic/eslint-plugin')
|
|
10
|
-
|
|
11
|
-
module.exports = [
|
|
12
|
-
...tseslint.config(
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
|
-
eslint.configs.recommended,
|
|
15
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
16
|
-
...tseslint.configs.strictTypeChecked,
|
|
17
|
-
{
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parserOptions: {
|
|
20
|
-
project: true
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
),
|
|
25
|
-
stylistic.configs.customize({
|
|
26
|
-
indent: 2,
|
|
27
|
-
quotes: "double",
|
|
28
|
-
commaDangle: "never",
|
|
29
|
-
quoteProps: "as-needed",
|
|
30
|
-
arrowParens: false,
|
|
31
|
-
blockSpacing: true,
|
|
32
|
-
braceStyle: "1tbs",
|
|
33
|
-
flat: true,
|
|
34
|
-
semi: true
|
|
35
|
-
})
|
|
36
|
-
];
|