homebridge-tasmota-control 1.4.1-beta.5 → 1.4.1-beta.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/switches.js +372 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.4.1-beta.5",
4
+ "version": "1.4.1-beta.6",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/switches.js CHANGED
@@ -22,6 +22,7 @@ class Switches extends EventEmitter {
22
22
  //other config
23
23
  this.relaysDisplayType = config.relaysDisplayType || 0;
24
24
  this.relaysNamePrefix = config.relaysNamePrefix || false;
25
+ this.sensorsNamePrefix = config.sensorsNamePrefix || false;
25
26
  this.enableDebugMode = config.enableDebugMode || false;
26
27
  this.disableLogInfo = config.disableLogInfo || false;
27
28
  this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
@@ -64,6 +65,13 @@ class Switches extends EventEmitter {
64
65
  const powerStatus = powerStatusData.data ?? {};
65
66
  const debug = this.enableDebugMode ? this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`) : false;
66
67
 
68
+ //sensor status keys
69
+ const sensorStatusKeys = Object.keys(sensorStatus);
70
+
71
+ //status SNS
72
+ const statusSnsSupported = sensorStatusKeys.includes('StatusSNS');
73
+ const statusSns = statusSnsSupported ? sensorStatus.StatusSNS : {};
74
+
67
75
  //relays
68
76
  const relaysCount = this.info.relaysCount;
69
77
  if (relaysCount > 0) {
@@ -94,6 +102,160 @@ class Switches extends EventEmitter {
94
102
  }
95
103
  }
96
104
 
105
+ //status SNS
106
+ if (statusSnsSupported) {
107
+ this.sensorsName = [];
108
+ this.sensorsTemperature = [];
109
+ this.sensorsReferenceTemperature = [];
110
+ this.sensorsObjTemperature = [];
111
+ this.sensorsAmbTemperature = [];
112
+ this.sensorsDewPointTemperature = [];
113
+ this.sensorsHumidity = [];
114
+ this.sensorsPressure = [];
115
+ this.sensorsGas = [];
116
+ this.sensorsCarbonDioxyde = [];
117
+ this.sensorsAmbientLight = [];
118
+ this.sensorsMotion = [];
119
+
120
+ const sensor = Object.entries(statusSns)
121
+ .filter(([key]) => SensorKeys.some(type => key.includes(type)))
122
+ .reduce((obj, [key, value]) => {
123
+ obj[key] = value;
124
+ return obj;
125
+ }, {});
126
+
127
+ for (const [key, value] of Object.entries(sensor)) {
128
+ const sensorName = key ?? `Sensor`;
129
+ const sensorData = value;
130
+
131
+ //sensors
132
+ const temperature = sensorData.Temperature ?? false;
133
+ const referenceTemperature = sensorData.ReferenceTemperature ?? false;
134
+ const objTemperature = sensorData.OBJTMP ?? false;
135
+ const ambTemperature = sensorData.AMBTMP ?? false;
136
+ const dewPointTemperature = sensorData.DewPoint ?? false;
137
+ const humidity = sensorData.Humidity ?? false;
138
+ const pressure = sensorData.Pressure ?? false;
139
+ const gas = sensorData.Gas ?? false;
140
+ const carbonDioxyde = sensorData.CarbonDioxyde ?? false;
141
+ const ambientLight = sensorData.Ambient ?? false;
142
+ const motion = sensorData === 'ON';
143
+
144
+ //energy
145
+ const energyTotalStartTime = sensorData.TotalStartTime ?? '';
146
+ const energyTotal = sensorData.Total ?? 0;
147
+ const energyPeriod = sensorData.Period ?? 0;
148
+ const energyYesterday = sensorData.Yesterday ?? 0;
149
+ const energyToday = sensorData.Today ?? 0;
150
+ const power = sensorData.Power ?? 0;
151
+ const apparentPower = sensorData.ApparentPower ?? 0;
152
+ const reactivePower = sensorData.ReactivePower ?? 0;
153
+ const factor = sensorData.Factor ?? 0;
154
+ const voltage = sensorData.Voltage ?? 0;
155
+ const current = sensorData.Current ?? 0;
156
+ const load = sensorData.Load ?? 0;
157
+
158
+ //push to array
159
+ this.sensorsName.push(sensorName);
160
+ const push1 = temperature ? this.sensorsTemperature.push(temperature) : false;
161
+ const push2 = referenceTemperature ? this.sensorsReferenceTemperature.push(referenceTemperature) : false;
162
+ const push3 = objTemperature ? this.sensorsAmbTemperature.push(objTemperature) : false;
163
+ const push4 = ambTemperature ? this.sensorsAmbTemperature.push(ambTemperature) : false;
164
+ const push5 = dewPointTemperature ? this.sensorsDewPointTemperature.push(dewPointTemperature) : false;
165
+ const push6 = humidity ? this.sensorsHumidity.push(humidity) : false;
166
+ const push7 = pressure ? this.sensorsPressure.push(pressure) : false;
167
+ const push8 = gas ? this.sensorsGas.push(gas) : false;
168
+ const push9 = carbonDioxyde ? this.sensorsCarbonDioxyde.push(carbonDioxyde) : false;
169
+ const push10 = ambientLight ? this.sensorsAmbientLight.push(ambientLight) : false;
170
+ const push11 = motion ? this.sensorsMotion.push(motion) : false;
171
+ }
172
+
173
+ this.time = sensorStatus.Time ?? '';
174
+ this.tempUnit = sensorStatus.TempUnit === 'C' ? '°C' : 'F';
175
+ this.pressureUnit = sensorStatus.PressureUnit ?? 'hPa';
176
+ this.sensorsTemperatureCount = this.sensorsTemperature.length;
177
+ this.sensorsReferenceTemperatureCount = this.sensorsReferenceTemperature.length;
178
+ this.sensorsObjTemperatureCount = this.sensorsObjTemperature.length;
179
+ this.sensorsAmbTemperatureCount = this.sensorsAmbTemperature.length;
180
+ this.sensorsDewPointTemperatureCount = this.sensorsDewPointTemperature.length;
181
+ this.sensorsHumidityCount = this.sensorsHumidity.length;
182
+ this.sensorsPressureCount = this.sensorsPressure.length;
183
+ this.sensorsGasCount = this.sensorsGas.length;
184
+ this.sensorsCarbonDioxydeCount = this.sensorsCarbonDioxyde.length;
185
+ this.sensorsAmbientLightCount = this.sensorsAmbientLight.length;
186
+ this.sensorsMotionCount = this.sensorsMotion.length;
187
+ this.sensorsCount = this.sensorsName.length;
188
+
189
+
190
+ //update characteristics
191
+ if (this.sensorTemperatureServices) {
192
+ for (let i = 0; i < this.sensorsTemperatureCount; i++) {
193
+ const value = this.sensorsTemperature[i];
194
+ this.sensorTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
195
+ }
196
+ }
197
+
198
+ if (this.sensorReferenceTemperatureServices) {
199
+ for (let i = 0; i < this.sensorsReferenceTemperatureCount; i++) {
200
+ const value = this.sensorsReferenceTemperature[i];
201
+ this.sensorReferenceTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
202
+ }
203
+ }
204
+
205
+ if (this.sensorObjTemperatureServices) {
206
+ for (let i = 0; i < this.sensorsObjTemperatureCount; i++) {
207
+ const value = this.sensorsObjTemperature[i];
208
+ this.sensorObjTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
209
+ }
210
+ }
211
+
212
+ if (this.sensorAmbTemperatureServices) {
213
+ for (let i = 0; i < this.sensorsAmbTemperatureCount; i++) {
214
+ const value = this.sensorsAmbTemperature[i];
215
+ this.sensorAmbTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
216
+ }
217
+ }
218
+
219
+ if (this.sensorDewPointTemperatureServices) {
220
+ for (let i = 0; i < this.sensorsDewPointTemperatureCount; i++) {
221
+ const value = this.sensorsDewPointTemperature[i];
222
+ this.sensorDewPointTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
223
+ }
224
+ }
225
+
226
+ if (this.sensorHumidityServices) {
227
+ for (let i = 0; i < this.sensorsHumidityCount; i++) {
228
+ const value = this.sensorsHumidity[i];
229
+ this.sensorHumidityServices[i].updateCharacteristic(Characteristic.CurrentRelativeHumidity, value);
230
+ }
231
+ }
232
+
233
+ if (this.sensorCarbonDioxydeServices) {
234
+ for (let i = 0; i < this.sensorsCarbonDioxydeCount; i++) {
235
+ const state = this.sensorsCarbonDioxyde[i] > 1000;
236
+ const value = this.sensorsCarbonDioxyde[i];
237
+ this.sensorCarbonDioxydeServices[i]
238
+ .updateCharacteristic(Characteristic.CarbonDioxideDetected, state)
239
+ .updateCharacteristic(Characteristic.CarbonDioxideLevel, value)
240
+ .updateCharacteristic(Characteristic.CarbonDioxidePeakLevel, value);
241
+ }
242
+ }
243
+
244
+ if (this.sensorAmbientLightServices) {
245
+ for (let i = 0; i < this.sensorsAmbientLightCount; i++) {
246
+ const value = this.sensorsAmbientLight[i];
247
+ this.sensorAmbientLightServices[i].updateCharacteristic(Characteristic.CurrentAmbientLightLevel, value);
248
+ }
249
+ }
250
+
251
+ if (this.sensorMotionServices) {
252
+ for (let i = 0; i < this.sensorsMotionCount; i++) {
253
+ const state = this.sensorsMotion[i];
254
+ this.sensorMotionServices[i].updateCharacteristic(Characteristic.MotionDetected, state);
255
+ }
256
+ }
257
+ }
258
+
97
259
  return true;
98
260
  } catch (error) {
99
261
  throw new Error(`Check state error: ${error}`);
@@ -198,6 +360,216 @@ class Switches extends EventEmitter {
198
360
  }
199
361
  };
200
362
 
363
+ //Prepare services
364
+ if (this.sensorsCount > 0) {
365
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
366
+
367
+ //temperature
368
+ const sensorsTemperatureCount = this.sensorsTemperatureCount;
369
+ if (sensorsTemperatureCount > 0) {
370
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
371
+ this.sensorTemperatureServices = [];
372
+ for (let i = 0; i < sensorsTemperatureCount; i++) {
373
+ const sensorName = this.sensorsName[i];
374
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
375
+ const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
376
+ sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
377
+ sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
378
+ sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
379
+ .onGet(async () => {
380
+ const value = this.sensorsTemperature[i];
381
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
382
+ return value;
383
+ });
384
+ this.sensorTemperatureServices.push(sensorTemperatureService);
385
+ }
386
+ }
387
+
388
+ //reference temperature
389
+ const sensorsReferenceTemperatureCount = this.sensorsReferenceTemperatureCount;
390
+ if (sensorsReferenceTemperatureCount > 0) {
391
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
392
+ this.sensorReferenceTemperatureServices = [];
393
+ for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
394
+ const sensorName = this.sensorsName[i];
395
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
396
+ const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
397
+ sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
398
+ sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
399
+ sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
400
+ .onGet(async () => {
401
+ const value = this.sensorsReferenceTemperature[i];
402
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
403
+ return value;
404
+ });
405
+ this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
406
+ }
407
+ }
408
+
409
+ //object temperature
410
+ const sensorsObjTemperatureCount = this.sensorsObjTemperatureCount;
411
+ if (sensorsObjTemperatureCount > 0) {
412
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
413
+ this.sensorObjTemperatureServices = [];
414
+ for (let i = 0; i < sensorsObjTemperatureCount; i++) {
415
+ const sensorName = this.sensorsName[i];
416
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
417
+ const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
418
+ sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
419
+ sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
420
+ sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
421
+ .onGet(async () => {
422
+ const value = this.sensorsObjTemperature[i];
423
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
424
+ return value;
425
+ });
426
+ this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
427
+ }
428
+ }
429
+
430
+ //ambient temperature
431
+ const sensorsAmbTemperatureCount = this.sensorsAmbTemperatureCount;
432
+ if (sensorsAmbTemperatureCount > 0) {
433
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
434
+ this.sensorAmbTemperatureServices = [];
435
+ for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
436
+ const sensorName = this.sensorsName[i];
437
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
438
+ const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
439
+ sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
440
+ sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
441
+ sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
442
+ .onGet(async () => {
443
+ const value = this.sensorsAmbTemperature[i];
444
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
445
+ return value;
446
+ });
447
+ this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
448
+ }
449
+ }
450
+
451
+ //dew point temperature
452
+ const sensorsDewPointTemperatureCount = this.sensorsDewPointTemperatureCount;
453
+ if (sensorsDewPointTemperatureCount > 0) {
454
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
455
+ this.sensorDewPointTemperatureServices = [];
456
+ for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
457
+ const sensorName = this.sensorsName[i];
458
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
459
+ const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
460
+ sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
461
+ sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
462
+ sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
463
+ .onGet(async () => {
464
+ const value = this.sensorsDewPointTemperature[i];
465
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
466
+ return value;
467
+ });
468
+ this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
469
+ }
470
+ }
471
+
472
+ //humidity
473
+ const sensorsHumidityCount = this.sensorsHumidityCount;
474
+ if (sensorsHumidityCount > 0) {
475
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
476
+ this.sensorHumidityServices = [];
477
+ for (let i = 0; i < sensorsHumidityCount; i++) {
478
+ const sensorName = this.sensorsName[i];
479
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
480
+ const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
481
+ sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
482
+ sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
483
+ sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
484
+ .onGet(async () => {
485
+ const value = this.sensorsHumidity[i];
486
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
487
+ return value;
488
+ });
489
+ this.sensorHumidityServices.push(sensorHumidityService);
490
+ }
491
+ }
492
+
493
+ //pressure
494
+
495
+ //gas
496
+
497
+ //carbon dioxyde
498
+ const sensorsCarbonDioxydeCount = this.sensorsCarbonDioxydeCount;
499
+ if (sensorsCarbonDioxydeCount > 0) {
500
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
501
+ this.sensorCarbonDioxydeServices = [];
502
+ for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
503
+ const sensorName = this.sensorsName[i];
504
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
505
+ const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
506
+ sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
507
+ sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
508
+ sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
509
+ .onGet(async () => {
510
+ const state = this.sensorsCarbonDioxyde[i] > 1000;
511
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
512
+ return state;
513
+ });
514
+ sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
515
+ .onGet(async () => {
516
+ const value = this.sensorsCarbonDioxyde[i];
517
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
518
+ return value;
519
+ });
520
+ sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
521
+ .onGet(async () => {
522
+ const value = this.sensorsCarbonDioxyde[i];
523
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
524
+ return value;
525
+ });
526
+ this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
527
+ }
528
+ }
529
+
530
+ //ambient light
531
+ const sensorsAmbientLightCount = this.sensorsAmbientLightCount;
532
+ if (sensorsAmbientLightCount > 0) {
533
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
534
+ this.sensorAmbientLightServices = [];
535
+ for (let i = 0; i < sensorsAmbientLightCount; i++) {
536
+ const sensorName = this.sensorsName[i];
537
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
538
+ const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
539
+ sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
540
+ sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
541
+ sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
542
+ .onGet(async () => {
543
+ const value = this.sensorsAmbientLight[i];
544
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
545
+ return value;
546
+ });
547
+ this.sensorAmbientLightServices.push(sensorAmbientLightService);
548
+ }
549
+ }
550
+
551
+ //motion
552
+ const sensorsMotionCount = this.sensorsMotionCount;
553
+ if (sensorsMotionCount > 0) {
554
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
555
+ this.sensorMotionServices = [];
556
+ for (let i = 0; i < sensorsMotionCount; i++) {
557
+ const sensorName = this.sensorsName[i];
558
+ const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
559
+ const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
560
+ sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
561
+ sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
562
+ sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
563
+ .onGet(async () => {
564
+ const state = this.sensorsMotion[i];
565
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
566
+ return state;
567
+ });
568
+ this.sensorMotionServices.push(sensorMotionService);
569
+ }
570
+ }
571
+ }
572
+
201
573
  return accessory;
202
574
  } catch (error) {
203
575
  throw new Error(`Prepare accessory error: ${error}`)