homebridge-dummy 0.9.1-beta.0 → 0.9.1-beta.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/CHANGELOG.md +4 -1
- package/dist/homebridge/index.d.ts +5 -0
- package/dist/homebridge/index.js +138 -0
- package/dist/homebridge/index.js.map +1 -0
- package/dist/homebridge/settings.d.ts +2 -0
- package/dist/homebridge/settings.js +3 -0
- package/dist/homebridge/settings.js.map +1 -0
- package/dist/i18n/en.d.ts +20 -0
- package/dist/i18n/en.js +21 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/i18n.d.ts +29 -0
- package/dist/i18n/i18n.js +38 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/template.d.ts +20 -0
- package/dist/i18n/template.js +8 -0
- package/dist/i18n/template.js.map +1 -0
- package/dist/i18n/zz.d.ts +20 -0
- package/dist/i18n/zz.js +6 -0
- package/dist/i18n/zz.js.map +1 -0
- package/dist/tools/storage.d.ts +2 -0
- package/dist/tools/storage.js +24 -0
- package/dist/tools/storage.js.map +1 -0
- package/package.json +5 -8
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -148
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to homebridge-dummy will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## 0.9.1 (
|
|
5
|
+
## 0.9.1 (####-##-##)
|
|
6
6
|
|
|
7
7
|
⚠️ Plugin has a new maintainer and will undergo significant cleanup and modernization in the near term. If you experience issues you can always downgrade to the last stable version v0.9.0
|
|
8
8
|
|
|
9
9
|
Please report any issues you encounte here: https://github.com/mpatfield/homebridge-dummy/issues
|
|
10
10
|
|
|
11
|
+
### ⚠️ BREAKING
|
|
12
|
+
- node-persist updated from major version 2 to 4 so stateful and dimmer switches will lose their previously saved states
|
|
13
|
+
|
|
11
14
|
### Changed
|
|
12
15
|
- Migrated to typescript
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { PLUGIN_ALIAS, PLUGIN_NAME } from './settings.js';
|
|
2
|
+
import { strings } from '../i18n/i18n.js';
|
|
3
|
+
import { storageGet, storageSet } from '../tools/storage.js';
|
|
4
|
+
import getVersion from '../tools/version.js';
|
|
5
|
+
const init = (api) => {
|
|
6
|
+
api.registerAccessory(PLUGIN_NAME, PLUGIN_ALIAS, DummySwitch);
|
|
7
|
+
};
|
|
8
|
+
export default init;
|
|
9
|
+
export const SUFFIX_BRIGHTNESS = '_brightness';
|
|
10
|
+
export const SUFFIX_STATE = '_state';
|
|
11
|
+
class DummySwitch {
|
|
12
|
+
log;
|
|
13
|
+
Service;
|
|
14
|
+
Characteristic;
|
|
15
|
+
service;
|
|
16
|
+
infoService;
|
|
17
|
+
persistPath;
|
|
18
|
+
name;
|
|
19
|
+
isDimmer;
|
|
20
|
+
isStateful;
|
|
21
|
+
isReverse;
|
|
22
|
+
isRandom;
|
|
23
|
+
isResettable;
|
|
24
|
+
brightness;
|
|
25
|
+
timeout;
|
|
26
|
+
timer = undefined;
|
|
27
|
+
constructor(log, config, api) {
|
|
28
|
+
this.log = config.disableLogging ? undefined : log;
|
|
29
|
+
this.Service = api.hap.Service;
|
|
30
|
+
this.Characteristic = api.hap.Characteristic;
|
|
31
|
+
this.persistPath = api.user.persistPath();
|
|
32
|
+
this.name = config.name;
|
|
33
|
+
this.isDimmer = config.dimmer ?? false;
|
|
34
|
+
this.isReverse = config.reverse ?? false;
|
|
35
|
+
this.isStateful = config.stateful ?? false;
|
|
36
|
+
this.isRandom = config.random ?? false;
|
|
37
|
+
this.isResettable = config.resettable ?? false;
|
|
38
|
+
this.timeout = config.time;
|
|
39
|
+
this.brightness = config.brightness ?? 0;
|
|
40
|
+
let model;
|
|
41
|
+
if (this.isDimmer) {
|
|
42
|
+
this.service = new this.Service.Lightbulb(this.name);
|
|
43
|
+
model = strings.info.dimmer;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.service = new this.Service.Switch(this.name);
|
|
47
|
+
model = strings.info.switch;
|
|
48
|
+
}
|
|
49
|
+
this.infoService = new this.Service.AccessoryInformation();
|
|
50
|
+
this.infoService
|
|
51
|
+
.setCharacteristic(this.Characteristic.Manufacturer, strings.info.homebridge)
|
|
52
|
+
.setCharacteristic(this.Characteristic.Model, model)
|
|
53
|
+
.setCharacteristic(this.Characteristic.FirmwareRevision, getVersion())
|
|
54
|
+
.setCharacteristic(this.Characteristic.SerialNumber, 'Dummy-' + this.name.replace(/\s/g, '-'));
|
|
55
|
+
this.finishSetup();
|
|
56
|
+
}
|
|
57
|
+
getServices() {
|
|
58
|
+
return [this.infoService, this.service];
|
|
59
|
+
}
|
|
60
|
+
async finishSetup() {
|
|
61
|
+
if (this.isReverse) {
|
|
62
|
+
this.service.setCharacteristic(this.Characteristic.On, true);
|
|
63
|
+
}
|
|
64
|
+
if (this.isStateful) {
|
|
65
|
+
const state = await storageGet(this.persistPath, this.storageKey(SUFFIX_STATE));
|
|
66
|
+
if (!state) {
|
|
67
|
+
this.service.setCharacteristic(this.Characteristic.On, false);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.service.setCharacteristic(this.Characteristic.On, true);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (this.isDimmer) {
|
|
74
|
+
const brightness = await storageGet(this.persistPath, this.storageKey(SUFFIX_BRIGHTNESS));
|
|
75
|
+
if (brightness) {
|
|
76
|
+
this.brightness = Number(brightness);
|
|
77
|
+
this.service.setCharacteristic(this.Characteristic.Brightness, Number(this.brightness));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.service.setCharacteristic(this.Characteristic.Brightness, 0);
|
|
81
|
+
}
|
|
82
|
+
this.service.getCharacteristic(this.Characteristic.Brightness)
|
|
83
|
+
.onGet(this._getBrightness.bind(this))
|
|
84
|
+
.onSet(this._setBrightness.bind(this));
|
|
85
|
+
}
|
|
86
|
+
this.service.getCharacteristic(this.Characteristic.On)
|
|
87
|
+
.onSet(this._setOn.bind(this));
|
|
88
|
+
}
|
|
89
|
+
storageKey(suffix) {
|
|
90
|
+
return this.name.replace(/\s/g, '_').toLowerCase() + suffix;
|
|
91
|
+
}
|
|
92
|
+
randomize(timeout) {
|
|
93
|
+
return timeout ? Math.floor(Math.random() * (timeout + 1)) : undefined;
|
|
94
|
+
}
|
|
95
|
+
async _getBrightness() {
|
|
96
|
+
return this.brightness;
|
|
97
|
+
}
|
|
98
|
+
async _setBrightness(brightness) {
|
|
99
|
+
this.log?.(strings.brightness.set, brightness);
|
|
100
|
+
this.brightness = brightness;
|
|
101
|
+
await storageSet(this.persistPath, this.storageKey(SUFFIX_BRIGHTNESS), brightness.toString());
|
|
102
|
+
}
|
|
103
|
+
;
|
|
104
|
+
async _setOn(value) {
|
|
105
|
+
if (this.isDimmer) {
|
|
106
|
+
this.log?.('%s / %s', value ? strings.switch.on : strings.switch.off, this.brightness);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.log?.(value ? strings.switch.on : strings.switch.off);
|
|
110
|
+
}
|
|
111
|
+
if (this.isStateful) {
|
|
112
|
+
await storageSet(this.persistPath, this.storageKey(SUFFIX_STATE), value.toString());
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (value === this.isReverse) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (this.isResettable) {
|
|
119
|
+
clearTimeout(this.timer);
|
|
120
|
+
this.timer = undefined;
|
|
121
|
+
}
|
|
122
|
+
const delay = this.isRandom ? this.randomize(this.timeout) : this.timeout;
|
|
123
|
+
if (!delay) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (delay % 1000 === 0) {
|
|
127
|
+
this.log?.(strings.switch.delay_s, delay / 1000);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.log?.(strings.switch.delay_ms, delay);
|
|
131
|
+
}
|
|
132
|
+
this.timer = setTimeout(() => {
|
|
133
|
+
this.service.setCharacteristic(this.Characteristic.On, this.isReverse);
|
|
134
|
+
}, delay);
|
|
135
|
+
}
|
|
136
|
+
;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/homebridge/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,IAAI,GAAG,CAAC,GAAQ,EAAE,EAAE;IACxB,GAAG,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,MAAM,WAAW;IACE,GAAG,CAAsB;IAEzB,OAAO,CAAiB;IACxB,cAAc,CAAwB;IAEtC,OAAO,CAAU;IACjB,WAAW,CAAU;IAErB,WAAW,CAAS;IAEpB,IAAI,CAAS;IAEb,QAAQ,CAAU;IAClB,UAAU,CAAU;IACpB,SAAS,CAAU;IACnB,QAAQ,CAAU;IAClB,YAAY,CAAU;IAE/B,UAAU,CAAsB;IAEvB,OAAO,CAAqB;IACrC,KAAK,GAA+B,SAAS,CAAC;IAEtD,YAAY,GAAY,EAAE,MAAuB,EAAE,GAAQ;QACzD,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;QAEnD,IAAI,CAAC,OAAO,GAA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CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAC1E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,SAAgC,CAAC,CAAC;QAChG,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;IAAA,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/homebridge/settings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const en: {
|
|
2
|
+
brightness: {
|
|
3
|
+
set: string;
|
|
4
|
+
};
|
|
5
|
+
config: {
|
|
6
|
+
support: string;
|
|
7
|
+
};
|
|
8
|
+
info: {
|
|
9
|
+
dimmer: string;
|
|
10
|
+
homebridge: string;
|
|
11
|
+
switch: string;
|
|
12
|
+
};
|
|
13
|
+
switch: {
|
|
14
|
+
delay_ms: string;
|
|
15
|
+
delay_s: string;
|
|
16
|
+
off: string;
|
|
17
|
+
on: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default en;
|
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
brightness: {
|
|
3
|
+
set: 'Brightness = %s',
|
|
4
|
+
},
|
|
5
|
+
config: {
|
|
6
|
+
support: 'For help and support please visit %s',
|
|
7
|
+
},
|
|
8
|
+
info: {
|
|
9
|
+
dimmer: 'Dummy Dimmer',
|
|
10
|
+
homebridge: 'Homebridge',
|
|
11
|
+
switch: 'Dummy Switch',
|
|
12
|
+
},
|
|
13
|
+
switch: {
|
|
14
|
+
delay_ms: 'Delaying %sms…',
|
|
15
|
+
delay_s: 'Delaying %ss…',
|
|
16
|
+
off: 'Off',
|
|
17
|
+
on: 'On',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default en;
|
|
21
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG;IAET,UAAU,EAAE;QACV,GAAG,EAAE,iBAAiB;KACvB;IAED,MAAM,EAAE;QACN,OAAO,EAAE,sCAAsC;KAChD;IAED,IAAI,EAAE;QACJ,MAAM,EAAE,cAAc;QACtB,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,cAAc;KACvB;IAED,MAAM,EAAE;QACN,QAAQ,EAAE,gBAAgB;QAC1B,OAAO,EAAE,eAAe;QACxB,GAAG,EAAE,KAAK;QACV,EAAE,EAAE,IAAI;KACT;CACF,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import en from './en.js';
|
|
2
|
+
export declare enum Language {
|
|
3
|
+
EN = "en",
|
|
4
|
+
ZZ = "zz"
|
|
5
|
+
}
|
|
6
|
+
export type Translation = typeof en;
|
|
7
|
+
export declare function getLanguage(): Language;
|
|
8
|
+
export declare function setLanguage(i18nLang: string): void;
|
|
9
|
+
export declare function getAllTranslations(): Translation;
|
|
10
|
+
declare const translations: {
|
|
11
|
+
brightness: {
|
|
12
|
+
set: string;
|
|
13
|
+
};
|
|
14
|
+
config: {
|
|
15
|
+
support: string;
|
|
16
|
+
};
|
|
17
|
+
info: {
|
|
18
|
+
dimmer: string;
|
|
19
|
+
homebridge: string;
|
|
20
|
+
switch: string;
|
|
21
|
+
};
|
|
22
|
+
switch: {
|
|
23
|
+
delay_ms: string;
|
|
24
|
+
delay_s: string;
|
|
25
|
+
off: string;
|
|
26
|
+
on: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export { translations as strings };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import en from './en.js';
|
|
2
|
+
import zz from './zz.js';
|
|
3
|
+
export var Language;
|
|
4
|
+
(function (Language) {
|
|
5
|
+
Language["EN"] = "en";
|
|
6
|
+
Language["ZZ"] = "zz";
|
|
7
|
+
})(Language || (Language = {}));
|
|
8
|
+
const Translations = {
|
|
9
|
+
[Language.EN]: en,
|
|
10
|
+
[Language.ZZ]: zz,
|
|
11
|
+
};
|
|
12
|
+
let currentLanguage = Language.EN;
|
|
13
|
+
export function getLanguage() {
|
|
14
|
+
return currentLanguage;
|
|
15
|
+
}
|
|
16
|
+
export function setLanguage(i18nLang) {
|
|
17
|
+
let language = Language.EN;
|
|
18
|
+
switch (i18nLang) {
|
|
19
|
+
case Language.EN:
|
|
20
|
+
language = Language.EN;
|
|
21
|
+
break;
|
|
22
|
+
case Language.ZZ:
|
|
23
|
+
language = Language.ZZ;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
currentLanguage = Translations[language] ? language : Language.EN;
|
|
27
|
+
}
|
|
28
|
+
export function getAllTranslations() {
|
|
29
|
+
return Translations[currentLanguage];
|
|
30
|
+
}
|
|
31
|
+
const translations = new Proxy({}, {
|
|
32
|
+
get(_target, prop) {
|
|
33
|
+
return (Translations[currentLanguage][prop] ??
|
|
34
|
+
Translations[Language.EN][prop]);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export { translations as strings };
|
|
38
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,qBAAS,CAAA;AACX,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAED,MAAM,YAAY,GAAkC;IAClD,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE;IACjB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE;CAClB,CAAC;AAIF,IAAI,eAAe,GAAa,QAAQ,CAAC,EAAE,CAAC;AAE5C,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB;IAE1C,IAAI,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;IAC3B,QAAO,QAAQ,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC,EAAE;YACd,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;YACvB,MAAM;QACR,KAAK,QAAQ,CAAC,EAAE;YACd,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;YACvB,MAAM;IACR,CAAC;IAED,eAAe,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,YAAY,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,EAAiB,EAAE;IAChD,GAAG,CAAC,OAAO,EAAE,IAAY;QACvB,OAAO,CACL,YAAY,CAAC,eAAe,CAAC,CAAC,IAAyB,CAAC;YACxD,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAyB,CAAC,CACrD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const REPLACE_THIS_WITH_ISO_CODE: {
|
|
2
|
+
brightness: {
|
|
3
|
+
set: string;
|
|
4
|
+
};
|
|
5
|
+
config: {
|
|
6
|
+
support: string;
|
|
7
|
+
};
|
|
8
|
+
info: {
|
|
9
|
+
dimmer: string;
|
|
10
|
+
homebridge: string;
|
|
11
|
+
switch: string;
|
|
12
|
+
};
|
|
13
|
+
switch: {
|
|
14
|
+
delay_ms: string;
|
|
15
|
+
delay_s: string;
|
|
16
|
+
off: string;
|
|
17
|
+
on: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default REPLACE_THIS_WITH_ISO_CODE;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import merge from 'lodash.merge';
|
|
2
|
+
import en from './en.js';
|
|
3
|
+
const overrides = {
|
|
4
|
+
// Copy strings from en.js to here and translate
|
|
5
|
+
};
|
|
6
|
+
const REPLACE_THIS_WITH_ISO_CODE = merge({}, en, overrides);
|
|
7
|
+
export default REPLACE_THIS_WITH_ISO_CODE;
|
|
8
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/i18n/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,SAAS,GAAG;AAEhB,gDAAgD;CAEjD,CAAC;AAEF,MAAM,0BAA0B,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAE5D,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const zz: {
|
|
2
|
+
brightness: {
|
|
3
|
+
set: string;
|
|
4
|
+
};
|
|
5
|
+
config: {
|
|
6
|
+
support: string;
|
|
7
|
+
};
|
|
8
|
+
info: {
|
|
9
|
+
dimmer: string;
|
|
10
|
+
homebridge: string;
|
|
11
|
+
switch: string;
|
|
12
|
+
};
|
|
13
|
+
switch: {
|
|
14
|
+
delay_ms: string;
|
|
15
|
+
delay_s: string;
|
|
16
|
+
off: string;
|
|
17
|
+
on: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default zz;
|
package/dist/i18n/zz.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zz.js","sourceRoot":"","sources":["../../src/i18n/zz.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,SAAS,GAAG,EACjB,CAAC;AAEF,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAEpC,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import storage from 'node-persist';
|
|
2
|
+
import { PLUGIN_NAME } from '../homebridge/settings.js';
|
|
3
|
+
async function init(dir) {
|
|
4
|
+
await storage.init({ dir: dir, forgiveParseErrors: true });
|
|
5
|
+
}
|
|
6
|
+
export async function storageGet(dir, key) {
|
|
7
|
+
try {
|
|
8
|
+
await init(dir);
|
|
9
|
+
return await storage.get(`${PLUGIN_NAME}:${key}`);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function storageSet(dir, key, value) {
|
|
16
|
+
try {
|
|
17
|
+
await init(dir);
|
|
18
|
+
storage.set(`${PLUGIN_NAME}:${key}`, value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Nothing
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,KAAK,UAAU,IAAI,CAAC,GAAW;IAC7B,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,GAAW;IACvD,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,GAAW,EAAE,KAAa;IACtE,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,UAAU;IACZ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-dummy",
|
|
3
3
|
"displayName": "Homebridge Dummy",
|
|
4
|
-
"version": "0.9.1-beta.
|
|
4
|
+
"version": "0.9.1-beta.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "mpatfield"
|
|
7
7
|
},
|
|
8
8
|
"description": "Dummy switches for Homebridge",
|
|
9
9
|
"homepage": "https://github.com/mpatfield/homebridge-dummy#readme",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"main": "dist/index.js",
|
|
11
|
+
"main": "dist/homebridge/index.js",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"homebridge",
|
|
14
14
|
"homebridge-plugin",
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "rimraf ./dist && tsc",
|
|
22
|
-
"build:html": "mkdir ./dist/homebridge-ui/public && cp -r ./src/homebridge-ui/public/* ./dist/homebridge-ui/public/",
|
|
23
|
-
"build:ui": "esbuild src/homebridge-ui/ui.ts --bundle --outfile=dist/homebridge-ui/public/ui.js --minify",
|
|
24
22
|
"lint": "eslint . --max-warnings=0",
|
|
25
23
|
"prepublishOnly": "npm run lint && npm run build"
|
|
26
24
|
},
|
|
@@ -40,16 +38,15 @@
|
|
|
40
38
|
"url": "https://github.com/sponsors/mpatfield"
|
|
41
39
|
},
|
|
42
40
|
"dependencies": {
|
|
43
|
-
"@homebridge/plugin-ui-utils": "^2.0.2",
|
|
44
41
|
"homebridge-lib": "^7.1.4",
|
|
45
|
-
"
|
|
42
|
+
"lodash.merge": "^4.6.2",
|
|
43
|
+
"node-persist": "^4.0.4"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
46
|
+
"@types/lodash.merge": "^4.6.9",
|
|
48
47
|
"@types/node-persist": "^3.1.8",
|
|
49
|
-
"esbuild": "^0.25.5",
|
|
50
48
|
"eslint": "^9.27.0",
|
|
51
49
|
"homebridge": "^2.0.0-beta.0",
|
|
52
|
-
"jiti": "^2.4.2",
|
|
53
50
|
"rimraf": "^6.0.1",
|
|
54
51
|
"ts-node": "^10.9.2",
|
|
55
52
|
"typescript-eslint": "^8.24.1"
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import storage from 'node-persist';
|
|
2
|
-
import getVersion from './tools/version.js';
|
|
3
|
-
const init = (api) => {
|
|
4
|
-
api.registerAccessory('homebridge-dummy', 'DummySwitch', DummySwitch);
|
|
5
|
-
};
|
|
6
|
-
export default init;
|
|
7
|
-
class DummySwitch {
|
|
8
|
-
log;
|
|
9
|
-
name;
|
|
10
|
-
api;
|
|
11
|
-
service;
|
|
12
|
-
infoService;
|
|
13
|
-
dimmer;
|
|
14
|
-
stateful;
|
|
15
|
-
reverse;
|
|
16
|
-
brightness;
|
|
17
|
-
random;
|
|
18
|
-
resettable;
|
|
19
|
-
time;
|
|
20
|
-
brightnessStorageKey;
|
|
21
|
-
disableLogging;
|
|
22
|
-
timer = null;
|
|
23
|
-
constructor(log, config, api) {
|
|
24
|
-
this.log = log;
|
|
25
|
-
this.name = config.name;
|
|
26
|
-
this.dimmer = config.dimmer;
|
|
27
|
-
this.reverse = config.reverse;
|
|
28
|
-
this.stateful = config.stateful;
|
|
29
|
-
this.brightness = config.brightness;
|
|
30
|
-
this.random = config.random;
|
|
31
|
-
this.resettable = config.resettable;
|
|
32
|
-
this.time = config.time ? config.time : 1000;
|
|
33
|
-
this.brightnessStorageKey = this.name + 'Brightness';
|
|
34
|
-
this.disableLogging = config.disableLogging;
|
|
35
|
-
this.api = api;
|
|
36
|
-
let modelString;
|
|
37
|
-
if (this.dimmer) {
|
|
38
|
-
this.service = new api.hap.Service.Lightbulb(this.name);
|
|
39
|
-
modelString = 'Dummy Dimmer';
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
this.service = new api.hap.Service.Switch(this.name);
|
|
43
|
-
modelString = 'Dummy Switch';
|
|
44
|
-
}
|
|
45
|
-
this.infoService = new api.hap.Service.AccessoryInformation();
|
|
46
|
-
this.infoService
|
|
47
|
-
.setCharacteristic(api.hap.Characteristic.Manufacturer, 'Homebridge')
|
|
48
|
-
.setCharacteristic(api.hap.Characteristic.Model, modelString)
|
|
49
|
-
.setCharacteristic(api.hap.Characteristic.FirmwareRevision, getVersion())
|
|
50
|
-
.setCharacteristic(api.hap.Characteristic.SerialNumber, 'Dummy-' + this.name.replace(/\s/g, '-'));
|
|
51
|
-
const cacheDirectory = api.user.persistPath();
|
|
52
|
-
storage.init({ dir: cacheDirectory, forgiveParseErrors: true }).then(() => {
|
|
53
|
-
this.service.getCharacteristic(this.api.hap.Characteristic.On)
|
|
54
|
-
.on("set" /* CharacteristicEventTypes.SET */, this._setOn.bind(this));
|
|
55
|
-
if (this.dimmer) {
|
|
56
|
-
this.service.getCharacteristic(this.api.hap.Characteristic.Brightness)
|
|
57
|
-
.on("get" /* CharacteristicEventTypes.GET */, this._getBrightness.bind(this))
|
|
58
|
-
.on("set" /* CharacteristicEventTypes.SET */, this._setBrightness.bind(this));
|
|
59
|
-
}
|
|
60
|
-
if (this.reverse) {
|
|
61
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, true);
|
|
62
|
-
}
|
|
63
|
-
if (this.stateful) {
|
|
64
|
-
storage.getItem(this.name).then((cachedState) => {
|
|
65
|
-
if ((cachedState === undefined) || (cachedState === false)) {
|
|
66
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, false);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, true);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (this.dimmer) {
|
|
74
|
-
storage.getItem(this.brightnessStorageKey).then((cachedBrightness) => {
|
|
75
|
-
if ((cachedBrightness === undefined) || cachedBrightness === 0) {
|
|
76
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, false);
|
|
77
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.Brightness, 0);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, true);
|
|
81
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.Brightness, cachedBrightness);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
getServices() {
|
|
88
|
-
return [this.infoService, this.service];
|
|
89
|
-
}
|
|
90
|
-
randomize(time) {
|
|
91
|
-
return Math.floor(Math.random() * (time + 1));
|
|
92
|
-
}
|
|
93
|
-
_getBrightness(callback) {
|
|
94
|
-
if (!this.disableLogging) {
|
|
95
|
-
this.log('Getting ' + 'brightness: ' + this.brightness);
|
|
96
|
-
}
|
|
97
|
-
callback(null, this.brightness);
|
|
98
|
-
}
|
|
99
|
-
_setBrightness(brightness, callback) {
|
|
100
|
-
if (!this.disableLogging) {
|
|
101
|
-
const msg = 'Setting brightness: ' + brightness;
|
|
102
|
-
this.log(msg);
|
|
103
|
-
}
|
|
104
|
-
this.brightness = brightness;
|
|
105
|
-
storage.setItem(this.brightnessStorageKey, brightness).then(() => {
|
|
106
|
-
callback();
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
;
|
|
110
|
-
_setOn(on, callback) {
|
|
111
|
-
const delay = this.random ? this.randomize(this.time) : this.time;
|
|
112
|
-
let msg = 'Setting switch to ' + on;
|
|
113
|
-
if (this.random && !this.stateful) {
|
|
114
|
-
if (on && !this.reverse || !on && this.reverse) {
|
|
115
|
-
msg = msg + ' (random delay ' + delay + 'ms)';
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (!this.disableLogging) {
|
|
119
|
-
this.log(msg);
|
|
120
|
-
}
|
|
121
|
-
if (on && !this.reverse && !this.stateful) {
|
|
122
|
-
if (this.resettable && this.timer) {
|
|
123
|
-
clearTimeout(this.timer);
|
|
124
|
-
}
|
|
125
|
-
this.timer = setTimeout(() => {
|
|
126
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, false);
|
|
127
|
-
}, delay);
|
|
128
|
-
}
|
|
129
|
-
else if (!on && this.reverse && !this.stateful) {
|
|
130
|
-
if (this.resettable && this.timer) {
|
|
131
|
-
clearTimeout(this.timer);
|
|
132
|
-
}
|
|
133
|
-
this.timer = setTimeout(() => {
|
|
134
|
-
this.service.setCharacteristic(this.api.hap.Characteristic.On, true);
|
|
135
|
-
}, delay);
|
|
136
|
-
}
|
|
137
|
-
if (this.stateful) {
|
|
138
|
-
storage.setItem(this.name, on).then(() => {
|
|
139
|
-
callback();
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
callback();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
;
|
|
147
|
-
}
|
|
148
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAE5C,MAAM,IAAI,GAAG,CAAC,GAAQ,EAAE,EAAE;IACxB,GAAG,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,MAAM,WAAW;IAqBM;IApBb,IAAI,CAAS;IAEb,GAAG,CAAM;IACT,OAAO,CAAU;IACjB,WAAW,CAAU;IAErB,MAAM,CAAU;IAChB,QAAQ,CAAU;IAClB,OAAO,CAAU;IACjB,UAAU,CAAsB;IAChC,MAAM,CAAU;IAChB,UAAU,CAAU;IACpB,IAAI,CAAS;IAEb,oBAAoB,CAAS;IAE7B,cAAc,CAAU;IAExB,KAAK,GAA0B,IAAI,CAAC;IAE5C,YAAqB,GAAY,EAAE,MAAuB,EAAE,GAAQ;QAA/C,QAAG,GAAH,GAAG,CAAS;QAC/B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,I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