@homebridge-plugins/homebridge-meross 10.8.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +1346 -0
  2. package/LICENSE +21 -0
  3. package/README.md +68 -0
  4. package/config.schema.json +2066 -0
  5. package/eslint.config.js +49 -0
  6. package/lib/connection/http.js +345 -0
  7. package/lib/connection/mqtt.js +174 -0
  8. package/lib/device/baby.js +532 -0
  9. package/lib/device/cooler-single.js +447 -0
  10. package/lib/device/diffuser.js +730 -0
  11. package/lib/device/fan.js +530 -0
  12. package/lib/device/garage-main.js +225 -0
  13. package/lib/device/garage-single.js +495 -0
  14. package/lib/device/garage-sub.js +376 -0
  15. package/lib/device/heater-single.js +445 -0
  16. package/lib/device/hub-contact.js +56 -0
  17. package/lib/device/hub-leak.js +86 -0
  18. package/lib/device/hub-main.js +403 -0
  19. package/lib/device/hub-sensor.js +115 -0
  20. package/lib/device/hub-smoke.js +40 -0
  21. package/lib/device/hub-valve.js +377 -0
  22. package/lib/device/humidifier.js +521 -0
  23. package/lib/device/index.js +63 -0
  24. package/lib/device/light-cct.js +474 -0
  25. package/lib/device/light-dimmer.js +312 -0
  26. package/lib/device/light-rgb.js +528 -0
  27. package/lib/device/outlet-multi.js +383 -0
  28. package/lib/device/outlet-single.js +405 -0
  29. package/lib/device/power-strip.js +282 -0
  30. package/lib/device/purifier-single.js +372 -0
  31. package/lib/device/purifier.js +403 -0
  32. package/lib/device/roller-location.js +317 -0
  33. package/lib/device/roller.js +234 -0
  34. package/lib/device/sensor-presence.js +201 -0
  35. package/lib/device/switch-multi.js +403 -0
  36. package/lib/device/switch-single.js +371 -0
  37. package/lib/device/template.js +177 -0
  38. package/lib/device/thermostat.js +493 -0
  39. package/lib/fakegato/LICENSE +21 -0
  40. package/lib/fakegato/fakegato-history.js +814 -0
  41. package/lib/fakegato/fakegato-storage.js +108 -0
  42. package/lib/fakegato/fakegato-timer.js +125 -0
  43. package/lib/fakegato/uuid.js +27 -0
  44. package/lib/homebridge-ui/public/index.html +316 -0
  45. package/lib/homebridge-ui/server.js +10 -0
  46. package/lib/index.js +8 -0
  47. package/lib/platform.js +1256 -0
  48. package/lib/utils/colour.js +581 -0
  49. package/lib/utils/constants.js +377 -0
  50. package/lib/utils/custom-chars.js +165 -0
  51. package/lib/utils/eve-chars.js +130 -0
  52. package/lib/utils/functions.js +39 -0
  53. package/lib/utils/lang-en.js +114 -0
  54. package/package.json +70 -0
@@ -0,0 +1,377 @@
1
+ export default {
2
+ defaultConfig: {
3
+ name: 'Meross',
4
+ username: '',
5
+ password: '',
6
+ mfaCode: '',
7
+ showUserKey: false,
8
+ userkey: '',
9
+ ignoreHKNative: false,
10
+ ignoreMatter: false,
11
+ connection: 'hybrid',
12
+ domain: 'iotx.meross.com',
13
+ disableDeviceLogging: false,
14
+ cloudRefreshRate: 300,
15
+ refreshRate: 5,
16
+ singleDevices: [],
17
+ multiDevices: [],
18
+ lightDevices: [],
19
+ fanDevices: [],
20
+ diffuserDevices: [],
21
+ purifierDevices: [],
22
+ humidifierDevices: [],
23
+ thermostatDevices: [],
24
+ garageDevices: [],
25
+ rollerDevices: [],
26
+ babyDevices: [],
27
+ sensorDevices: [],
28
+ platform: 'Meross',
29
+ },
30
+
31
+ defaultValues: {
32
+ adaptiveLightingShift: 0,
33
+ brightnessStep: 1,
34
+ cloudRefreshRate: 0,
35
+ connection: 'hybrid',
36
+ garageDoorOpeningTime: 20,
37
+ inUsePowerThreshold: 0,
38
+ lowBattThreshold: 20,
39
+ refreshRate: 5,
40
+ showAs: 'default',
41
+ },
42
+
43
+ minValues: {
44
+ adaptiveLightingShift: -1,
45
+ brightnessStep: 1,
46
+ cloudRefreshRate: 30,
47
+ garageDoorOpeningTime: 1,
48
+ inUsePowerThreshold: 0,
49
+ lowBattThreshold: 1,
50
+ refreshRate: 5,
51
+ },
52
+
53
+ allowed: {
54
+ singleDevices: [
55
+ 'name',
56
+ 'serialNumber',
57
+ 'connection',
58
+ 'deviceUrl',
59
+ 'ignoreDevice',
60
+ 'model',
61
+ 'showAs',
62
+ 'inUsePowerThreshold',
63
+ 'temperatureSource',
64
+ 'firmwareRevision',
65
+ 'userkey',
66
+ ],
67
+ multiDevices: [
68
+ 'name',
69
+ 'serialNumber',
70
+ 'connection',
71
+ 'deviceUrl',
72
+ 'ignoreDevice',
73
+ 'model',
74
+ 'showAs',
75
+ 'hideChannels',
76
+ 'firmwareRevision',
77
+ 'userkey',
78
+ ],
79
+ lightDevices: [
80
+ 'name',
81
+ 'serialNumber',
82
+ 'connection',
83
+ 'deviceUrl',
84
+ 'ignoreDevice',
85
+ 'model',
86
+ 'brightnessStep',
87
+ 'adaptiveLightingShift',
88
+ 'firmwareRevision',
89
+ 'userkey',
90
+ ],
91
+ fanDevices: [
92
+ 'name',
93
+ 'serialNumber',
94
+ 'connection',
95
+ 'deviceUrl',
96
+ 'ignoreDevice',
97
+ 'model',
98
+ 'firmwareRevision',
99
+ 'userkey',
100
+ ],
101
+ diffuserDevices: [
102
+ 'name',
103
+ 'serialNumber',
104
+ 'connection',
105
+ 'deviceUrl',
106
+ 'ignoreDevice',
107
+ 'model',
108
+ 'brightnessStep',
109
+ 'firmwareRevision',
110
+ 'userkey',
111
+ ],
112
+ purifierDevices: [
113
+ 'name',
114
+ 'serialNumber',
115
+ 'connection',
116
+ 'deviceUrl',
117
+ 'ignoreDevice',
118
+ 'model',
119
+ 'firmwareRevision',
120
+ 'userkey',
121
+ ],
122
+ humidifierDevices: [
123
+ 'name',
124
+ 'serialNumber',
125
+ 'connection',
126
+ 'deviceUrl',
127
+ 'ignoreDevice',
128
+ 'model',
129
+ 'firmwareRevision',
130
+ 'userkey',
131
+ ],
132
+ thermostatDevices: [
133
+ 'name',
134
+ 'serialNumber',
135
+ 'connection',
136
+ 'deviceUrl',
137
+ 'ignoreDevice',
138
+ 'model',
139
+ 'firmwareRevision',
140
+ 'userkey',
141
+ ],
142
+ garageDevices: [
143
+ 'name',
144
+ 'serialNumber',
145
+ 'connection',
146
+ 'deviceUrl',
147
+ 'ignoreDevice',
148
+ 'model',
149
+ 'garageDoorOpeningTime',
150
+ 'hideChannels',
151
+ 'firmwareRevision',
152
+ 'userkey',
153
+ ],
154
+ rollerDevices: [
155
+ 'name',
156
+ 'serialNumber',
157
+ 'connection',
158
+ 'deviceUrl',
159
+ 'ignoreDevice',
160
+ 'model',
161
+ 'reversePolarity',
162
+ 'showAs',
163
+ 'firmwareRevision',
164
+ 'userkey',
165
+ ],
166
+ babyDevices: [
167
+ 'name',
168
+ 'serialNumber',
169
+ 'connection',
170
+ 'deviceUrl',
171
+ 'ignoreDevice',
172
+ 'model',
173
+ 'firmwareRevision',
174
+ 'userkey',
175
+ ],
176
+ sensorDevices: [
177
+ 'name',
178
+ 'serialNumber',
179
+ 'ignoreDevice',
180
+ 'model',
181
+ 'ignoreSubdevices',
182
+ 'lowBattThreshold',
183
+ ],
184
+ connection: ['default', 'cloud', 'local'],
185
+ showAs: [ // 'switch' and 'blind' are considered as default
186
+ 'default',
187
+ 'cooler',
188
+ 'heater',
189
+ 'outlet',
190
+ 'purifier',
191
+ 'door',
192
+ 'window',
193
+ 'power-strip',
194
+ ],
195
+ },
196
+
197
+ models: {
198
+ switchSingle: [
199
+ 'HP110A',
200
+ 'MSS105',
201
+ 'MSS110',
202
+ 'MSS115',
203
+ 'MSS1101',
204
+ 'MSS1102',
205
+ 'MSS110NR',
206
+ 'MSS110R',
207
+ 'MSS110RTL',
208
+ 'MSS210',
209
+ 'MSS210N',
210
+ 'MSS210P',
211
+ 'MSS210R',
212
+ 'MSS210RTL',
213
+ 'MSS305',
214
+ 'MSS310',
215
+ 'MSS310H',
216
+ 'MSS310R',
217
+ 'MSS310X',
218
+ 'MSS315',
219
+ 'MSS510',
220
+ 'MSS510H',
221
+ 'MSS510K',
222
+ 'MSS510M',
223
+ 'MSS510S',
224
+ 'MSS510X',
225
+ 'MSS510XR',
226
+ 'MSS550',
227
+ 'MSS550K',
228
+ 'MSS550L',
229
+ 'MSS550X',
230
+ 'MSS5X0',
231
+ 'MSS710',
232
+ 'MSS710R',
233
+ 'MSS810',
234
+ ],
235
+ switchMulti: {
236
+ MSP843P: 5,
237
+ MSP844: 5,
238
+ MSS120: 2,
239
+ MSS120B: 2,
240
+ MSS120BR: 2,
241
+ MSS420: 4,
242
+ MSS420F: 4,
243
+ MSS425: 4,
244
+ MSS425E: 4,
245
+ MSS425ER: 4,
246
+ MSS425EX: 4,
247
+ MSS425F: 5,
248
+ MSS425FC: 5,
249
+ MSS426: 7,
250
+ MSS426F: 5,
251
+ MSS426S: 7,
252
+ MSS530: 3,
253
+ MSS530H: 3,
254
+ MSS620: 2,
255
+ MSS620B: 2,
256
+ MSS620BR: 2,
257
+ MSS620R: 2,
258
+ MSS620S: 2,
259
+ MSS630: 3,
260
+ SP425EW: 4, // MSS425E
261
+ SP425FW: 4, // MSS425F
262
+ },
263
+ lightDimmer: [
264
+ 'MPD100',
265
+ 'MSL100',
266
+ 'MSL100D',
267
+ 'MSL100R',
268
+ 'MSS560',
269
+ 'MSS560M',
270
+ 'MSS560X',
271
+ 'MSS565',
272
+ 'MSS565X',
273
+ 'MSS570',
274
+ 'MSS570M',
275
+ 'MSS570X',
276
+ ],
277
+ lightRGB: [
278
+ 'MSL120',
279
+ 'MSL120B',
280
+ 'MSL120D',
281
+ 'MSL120DA',
282
+ 'MSL120DBR',
283
+ 'MSL120DR',
284
+ 'MSL120J',
285
+ 'MSL120M',
286
+ 'MSL320',
287
+ 'MSL320C',
288
+ 'MSL320CP',
289
+ 'MSL320CPR',
290
+ 'MSL320CR',
291
+ 'MSL320M',
292
+ 'MSL420',
293
+ 'MSL430',
294
+ 'MSL450',
295
+ ],
296
+ lightCCT: ['MDL110', 'MDL110M', 'MSL210', 'MSL610'],
297
+ fan: ['MFC100'],
298
+ diffuser: ['MOD100', 'MOD150'],
299
+ purifier: ['MAP100'],
300
+ humidifier: ['MSXH0'],
301
+ garage: ['MSG100', 'MSG200'],
302
+ roller: ['MRS100'],
303
+ baby: ['HP110A', 'HP110AHK'],
304
+ thermostat: ['MTS200', 'MTS200B', 'MTS960'],
305
+ sensorPresence: ['MS600'],
306
+ hubMain: ['MSH300', 'MSH300HK', 'MSH400'],
307
+ hubSub: ['GS559A', 'MS100', 'MS100F', 'MS200', 'MS400', 'MTS100V3', 'MTS150'],
308
+ template: [],
309
+ },
310
+
311
+ hkNativeHardware: {
312
+ MAP100: ['7'],
313
+ MDL110: ['4'],
314
+ MDL110M: ['4'],
315
+ MFC100: ['7'],
316
+ MOD100: ['4'],
317
+ MOD150: ['4'],
318
+ MOD100HK: ['4'],
319
+ MRS100: ['7'],
320
+ MSG100: ['4'],
321
+ MSG200: ['4'],
322
+ MSL100D: ['4'],
323
+ MSL100R: ['4'],
324
+ MSL120D: ['4', '7'],
325
+ MSL120DA: ['7'],
326
+ MSL120DBR: ['4'],
327
+ MSL120DR: ['4'],
328
+ MSL320C: ['4'],
329
+ MSL320CP: ['4'],
330
+ MSL320CPR: ['4'],
331
+ MSL320CR: ['4'],
332
+ MSL420: ['4'],
333
+ MSL430: ['4'],
334
+ MSL450: ['7'],
335
+ MSL610: ['4'],
336
+ MSS110: ['4', '7'],
337
+ MSS110NR: ['4'],
338
+ MSS110R: ['4'],
339
+ MSS120B: ['4'],
340
+ MSS120BR: ['4'],
341
+ MSS210: ['4', '7'],
342
+ MSS210P: ['7'],
343
+ MSS210RTL: ['4'],
344
+ MSS425E: ['4'],
345
+ MSS425ER: ['4'],
346
+ MSS425F: ['4'],
347
+ MSS425FC: ['7'],
348
+ MSS510: ['4'],
349
+ MSS510X: ['4'],
350
+ MSS510XR: ['4'],
351
+ MSS550X: ['4'],
352
+ MSS560X: ['4'],
353
+ MSS570X: ['4'],
354
+ MSS620: ['4', '7'],
355
+ MSS620R: ['4'],
356
+ MSS620BR: ['4'],
357
+ MSS630: ['4'],
358
+ MSS710: ['4'],
359
+ MSS710R: ['4'],
360
+ MSS810: ['7'],
361
+ MTS200: ['7'],
362
+ MTS200B: ['7'],
363
+ SP425EW: ['4'], // MSS425E
364
+ MSH300HK: ['4', '5'],
365
+ },
366
+
367
+ matterHardware: {
368
+ MS600: ['9'], // https://github.com/homebridge-plugins/homebridge-meross/issues/582
369
+ MSP844: ['5', '9'], // https://github.com/homebridge-plugins/homebridge-meross/issues/578, https://github.com/homebridge-plugins/homebridge-meross/issues/585
370
+ MSS115: ['9'], // https://github.com/homebridge-plugins/homebridge-meross/issues/549
371
+ MSS315: ['9'], // https://github.com/homebridge-plugins/homebridge-meross/issues/537
372
+ },
373
+
374
+ noLocalControl: ['MSH300', 'MSH300HK', 'MSH400'],
375
+
376
+ httpRetryCodes: ['ENOTFOUND', 'ETIMEDOUT', 'EAI_AGAIN', 'ECONNABORTED'],
377
+ }
@@ -0,0 +1,165 @@
1
+ import { inherits } from 'node:util'
2
+
3
+ export default class {
4
+ constructor(api) {
5
+ this.hapServ = api.hap.Service
6
+ this.hapChar = api.hap.Characteristic
7
+ this.uuids = {
8
+ diffColourMode: 'E962F001-079E-48FF-8F27-9C2605A29F52',
9
+ diffRainbowMode: 'E962F002-079E-48FF-8F27-9C2605A29F52',
10
+ diffTemperatureMode: 'E962F003-079E-48FF-8F27-9C2605A29F52',
11
+ valveHeatMode: 'E962F004-079E-48FF-8F27-9C2605A29F52',
12
+ valveCoolMode: 'E962F005-079E-48FF-8F27-9C2605A29F52',
13
+ valveAutoMode: 'E962F006-079E-48FF-8F27-9C2605A29F52',
14
+ valveEconomyMode: 'E962F007-079E-48FF-8F27-9C2605A29F52',
15
+ valveWindowOpen: 'E962F008-079E-48FF-8F27-9C2605A29F52',
16
+ lightNightWarm: 'E962F009-079E-48FF-8F27-9C2605A29F52',
17
+ lightNightWhite: 'E962F010-079E-48FF-8F27-9C2605A29F52',
18
+ babySceneOne: 'E962F011-079E-48FF-8F27-9C2605A29F52',
19
+ babySceneTwo: 'E962F012-079E-48FF-8F27-9C2605A29F52',
20
+ babySceneThree: 'E962F013-079E-48FF-8F27-9C2605A29F52',
21
+ babySceneFour: 'E962F014-079E-48FF-8F27-9C2605A29F52',
22
+ }
23
+ const self = this
24
+ this.DiffColourMode = function DiffColourMode() {
25
+ self.hapChar.call(this, 'Colour Mode', self.uuids.diffColourMode)
26
+ this.setProps({
27
+ format: api.hap.Formats.BOOL,
28
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
29
+ })
30
+ this.value = this.getDefaultValue()
31
+ }
32
+ this.DiffRainbowMode = function DiffRainbowMode() {
33
+ self.hapChar.call(this, 'Rainbow Mode', self.uuids.diffRainbowMode)
34
+ this.setProps({
35
+ format: api.hap.Formats.BOOL,
36
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
37
+ })
38
+ this.value = this.getDefaultValue()
39
+ }
40
+ this.DiffTemperatureMode = function DiffTemperatureMode() {
41
+ self.hapChar.call(this, 'Temperature Mode', self.uuids.diffTemperatureMode)
42
+ this.setProps({
43
+ format: api.hap.Formats.BOOL,
44
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
45
+ })
46
+ this.value = this.getDefaultValue()
47
+ }
48
+ this.ValveHeatMode = function ValveHeatMode() {
49
+ self.hapChar.call(this, 'Heat Mode', self.uuids.valveHeatMode)
50
+ this.setProps({
51
+ format: api.hap.Formats.BOOL,
52
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
53
+ })
54
+ this.value = this.getDefaultValue()
55
+ }
56
+ this.ValveCoolMode = function ValveCoolMode() {
57
+ self.hapChar.call(this, 'Cool Mode', self.uuids.valveCoolMode)
58
+ this.setProps({
59
+ format: api.hap.Formats.BOOL,
60
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
61
+ })
62
+ this.value = this.getDefaultValue()
63
+ }
64
+ this.ValveAutoMode = function ValveAutoMode() {
65
+ self.hapChar.call(this, 'Auto Mode', self.uuids.valveAutoMode)
66
+ this.setProps({
67
+ format: api.hap.Formats.BOOL,
68
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
69
+ })
70
+ this.value = this.getDefaultValue()
71
+ }
72
+ this.ValveEconomyMode = function ValveEconomyMode() {
73
+ self.hapChar.call(this, 'Economy Mode', self.uuids.valveEconomyMode)
74
+ this.setProps({
75
+ format: api.hap.Formats.BOOL,
76
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
77
+ })
78
+ this.value = this.getDefaultValue()
79
+ }
80
+ this.ValveWindowOpen = function ValveWindowOpen() {
81
+ self.hapChar.call(this, 'Window Open', self.uuids.valveWindowOpen)
82
+ this.setProps({
83
+ format: api.hap.Formats.BOOL,
84
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
85
+ })
86
+ this.value = this.getDefaultValue()
87
+ }
88
+ this.LightNightWarm = function LightNightWarm() {
89
+ self.hapChar.call(this, 'Night Light Warm', self.uuids.lightNightWarm)
90
+ this.setProps({
91
+ format: api.hap.Formats.BOOL,
92
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
93
+ })
94
+ this.value = this.getDefaultValue()
95
+ }
96
+ this.LightNightWhite = function LightNightWhite() {
97
+ self.hapChar.call(this, 'Night Light White', self.uuids.lightNightWhite)
98
+ this.setProps({
99
+ format: api.hap.Formats.BOOL,
100
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
101
+ })
102
+ this.value = this.getDefaultValue()
103
+ }
104
+ this.BabySceneOne = function BabySceneOne() {
105
+ self.hapChar.call(this, 'Baby Scene 1', self.uuids.babySceneOne)
106
+ this.setProps({
107
+ format: api.hap.Formats.BOOL,
108
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
109
+ })
110
+ this.value = this.getDefaultValue()
111
+ }
112
+ this.BabySceneTwo = function BabySceneTwo() {
113
+ self.hapChar.call(this, 'Baby Scene 2', self.uuids.babySceneTwo)
114
+ this.setProps({
115
+ format: api.hap.Formats.BOOL,
116
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
117
+ })
118
+ this.value = this.getDefaultValue()
119
+ }
120
+ this.BabySceneThree = function BabySceneThree() {
121
+ self.hapChar.call(this, 'Baby Scene 3', self.uuids.babySceneThree)
122
+ this.setProps({
123
+ format: api.hap.Formats.BOOL,
124
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
125
+ })
126
+ this.value = this.getDefaultValue()
127
+ }
128
+ this.BabySceneFour = function BabySceneFour() {
129
+ self.hapChar.call(this, 'Baby Scene 4', self.uuids.babySceneFour)
130
+ this.setProps({
131
+ format: api.hap.Formats.BOOL,
132
+ perms: [api.hap.Perms.READ, api.hap.Perms.WRITE, api.hap.Perms.NOTIFY],
133
+ })
134
+ this.value = this.getDefaultValue()
135
+ }
136
+ inherits(this.DiffColourMode, this.hapChar)
137
+ inherits(this.DiffRainbowMode, this.hapChar)
138
+ inherits(this.DiffTemperatureMode, this.hapChar)
139
+ inherits(this.ValveHeatMode, this.hapChar)
140
+ inherits(this.ValveCoolMode, this.hapChar)
141
+ inherits(this.ValveAutoMode, this.hapChar)
142
+ inherits(this.ValveEconomyMode, this.hapChar)
143
+ inherits(this.ValveWindowOpen, this.hapChar)
144
+ inherits(this.LightNightWarm, this.hapChar)
145
+ inherits(this.LightNightWhite, this.hapChar)
146
+ inherits(this.BabySceneOne, this.hapChar)
147
+ inherits(this.BabySceneTwo, this.hapChar)
148
+ inherits(this.BabySceneThree, this.hapChar)
149
+ inherits(this.BabySceneFour, this.hapChar)
150
+ this.DiffColourMode.UUID = this.uuids.diffColourMode
151
+ this.DiffRainbowMode.UUID = this.uuids.diffRainbowMode
152
+ this.DiffTemperatureMode.UUID = this.uuids.diffTemperatureMode
153
+ this.ValveHeatMode.UUID = this.uuids.valveHeatMode
154
+ this.ValveCoolMode.UUID = this.uuids.valveCoolMode
155
+ this.ValveAutoMode.UUID = this.uuids.valveAutoMode
156
+ this.ValveEconomyMode.UUID = this.uuids.valveEconomyMode
157
+ this.ValveWindowOpen.UUID = this.uuids.valveWindowOpen
158
+ this.LightNightWarm.UUID = this.uuids.lightNightWarm
159
+ this.LightNightWhite.UUID = this.uuids.lightNightWhite
160
+ this.BabySceneOne.UUID = this.uuids.babySceneOne
161
+ this.BabySceneTwo.UUID = this.uuids.babySceneTwo
162
+ this.BabySceneThree.UUID = this.uuids.babySceneThree
163
+ this.BabySceneFour.UUID = this.uuids.babySceneFour
164
+ }
165
+ }
@@ -0,0 +1,130 @@
1
+ import { inherits } from 'node:util'
2
+
3
+ export default class {
4
+ constructor(api) {
5
+ this.hapServ = api.hap.Service
6
+ this.hapChar = api.hap.Characteristic
7
+ this.uuids = {
8
+ currentConsumption: 'E863F10D-079E-48FF-8F27-9C2605A29F52',
9
+ totalConsumption: 'E863F10C-079E-48FF-8F27-9C2605A29F52',
10
+ voltage: 'E863F10A-079E-48FF-8F27-9C2605A29F52',
11
+ electricCurrent: 'E863F126-079E-48FF-8F27-9C2605A29F52',
12
+ resetTotal: 'E863F112-079E-48FF-8F27-9C2605A29F52',
13
+ lastActivation: 'E863F11A-079E-48FF-8F27-9C2605A29F52',
14
+ openDuration: 'E863F118-079E-48FF-8F27-9C2605A29F52',
15
+ closedDuration: 'E863F119-079E-48FF-8F27-9C2605A29F52',
16
+ timesOpened: 'E863F129-079E-48FF-8F27-9C2605A29F52',
17
+ }
18
+ const self = this
19
+ this.CurrentConsumption = function CurrentConsumption() {
20
+ self.hapChar.call(this, 'Current Consumption', self.uuids.currentConsumption)
21
+ this.setProps({
22
+ format: api.hap.Formats.UINT16,
23
+ unit: 'W',
24
+ maxValue: 100000,
25
+ minValue: 0,
26
+ minStep: 1,
27
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
28
+ })
29
+ this.value = this.getDefaultValue()
30
+ }
31
+ this.TotalConsumption = function TotalConsumption() {
32
+ self.hapChar.call(this, 'Total Consumption', self.uuids.totalConsumption)
33
+ this.setProps({
34
+ format: api.hap.Formats.FLOAT,
35
+ unit: 'kWh',
36
+ maxValue: 100000000000,
37
+ minValue: 0,
38
+ minStep: 0.01,
39
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
40
+ })
41
+ this.value = this.getDefaultValue()
42
+ }
43
+ this.Voltage = function Voltage() {
44
+ self.hapChar.call(this, 'Voltage', self.uuids.voltage)
45
+ this.setProps({
46
+ format: api.hap.Formats.FLOAT,
47
+ unit: 'V',
48
+ maxValue: 100000000000,
49
+ minValue: 0,
50
+ minStep: 1,
51
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
52
+ })
53
+ this.value = this.getDefaultValue()
54
+ }
55
+ this.ElectricCurrent = function ElectricCurrent() {
56
+ self.hapChar.call(this, 'Electric Current', self.uuids.electricCurrent)
57
+ this.setProps({
58
+ format: api.hap.Formats.FLOAT,
59
+ unit: 'A',
60
+ maxValue: 100000000000,
61
+ minValue: 0,
62
+ minStep: 0.1,
63
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
64
+ })
65
+ this.value = this.getDefaultValue()
66
+ }
67
+ this.ResetTotal = function ResetTotal() {
68
+ self.hapChar.call(this, 'Reset Total', self.uuids.resetTotal)
69
+ this.setProps({
70
+ format: api.hap.Formats.UINT32,
71
+ unit: api.hap.Units.seconds,
72
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY, api.hap.Perms.WRITE],
73
+ })
74
+ this.value = this.getDefaultValue()
75
+ }
76
+ this.LastActivation = function LastActivation() {
77
+ self.hapChar.call(this, 'Last Activation', self.uuids.lastActivation)
78
+ this.setProps({
79
+ format: api.hap.Formats.UINT32,
80
+ unit: api.hap.Units.SECONDS,
81
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
82
+ })
83
+ this.value = this.getDefaultValue()
84
+ }
85
+ this.OpenDuration = function OpenDuration() {
86
+ self.hapChar.call(this, 'Open Duration', self.uuids.openDuration)
87
+ this.setProps({
88
+ format: api.hap.Formats.UINT32,
89
+ unit: api.hap.Units.SECONDS,
90
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY, api.hap.Perms.WRITE],
91
+ })
92
+ this.value = this.getDefaultValue()
93
+ }
94
+ this.ClosedDuration = function ClosedDuration() {
95
+ self.hapChar.call(this, 'Closed Duration', self.uuids.closedDuration)
96
+ this.setProps({
97
+ format: api.hap.Formats.UINT32,
98
+ unit: api.hap.Units.SECONDS,
99
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY, api.hap.Perms.WRITE],
100
+ })
101
+ this.value = this.getDefaultValue()
102
+ }
103
+ this.TimesOpened = function TimesOpened() {
104
+ self.hapChar.call(this, 'Times Opened', self.uuids.timesOpened)
105
+ this.setProps({
106
+ format: api.hap.Formats.UINT32,
107
+ perms: [api.hap.Perms.READ, api.hap.Perms.NOTIFY],
108
+ })
109
+ this.value = this.getDefaultValue()
110
+ }
111
+ inherits(this.CurrentConsumption, this.hapChar)
112
+ inherits(this.TotalConsumption, this.hapChar)
113
+ inherits(this.Voltage, this.hapChar)
114
+ inherits(this.ElectricCurrent, this.hapChar)
115
+ inherits(this.LastActivation, this.hapChar)
116
+ inherits(this.ResetTotal, this.hapChar)
117
+ inherits(this.OpenDuration, this.hapChar)
118
+ inherits(this.ClosedDuration, this.hapChar)
119
+ inherits(this.TimesOpened, this.hapChar)
120
+ this.CurrentConsumption.UUID = this.uuids.currentConsumption
121
+ this.TotalConsumption.UUID = this.uuids.totalConsumption
122
+ this.Voltage.UUID = this.uuids.voltage
123
+ this.ElectricCurrent.UUID = this.uuids.electricCurrent
124
+ this.LastActivation.UUID = this.uuids.lastActivation
125
+ this.ResetTotal.UUID = this.uuids.resetTotal
126
+ this.OpenDuration.UUID = this.uuids.openDuration
127
+ this.ClosedDuration.UUID = this.uuids.closedDuration
128
+ this.TimesOpened.UUID = this.uuids.timesOpened
129
+ }
130
+ }
@@ -0,0 +1,39 @@
1
+ import { Buffer } from 'node:buffer'
2
+
3
+ const encodeParams = params => Buffer.from(JSON.stringify(params)).toString('base64')
4
+
5
+ function generateRandomString(length) {
6
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
7
+ let nonce = ''
8
+ while (nonce.length < length) {
9
+ nonce += chars.charAt(Math.floor(Math.random() * chars.length))
10
+ }
11
+ return nonce
12
+ }
13
+
14
+ const hasProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
15
+
16
+ function parseError(err, hideStack = []) {
17
+ let toReturn = err.message
18
+ if (err?.stack?.length > 0 && !hideStack.includes(err.message)) {
19
+ const stack = err.stack.split('\n')
20
+ if (stack[1]) {
21
+ toReturn += stack[1].replace(' ', '')
22
+ }
23
+ }
24
+ return toReturn
25
+ }
26
+
27
+ function sleep(ms) {
28
+ return new Promise((resolve) => {
29
+ setTimeout(resolve, ms)
30
+ })
31
+ }
32
+
33
+ export {
34
+ encodeParams,
35
+ generateRandomString,
36
+ hasProperty,
37
+ parseError,
38
+ sleep,
39
+ }