homebridge-tasmota-control 1.4.1-beta.7 → 1.4.1-beta.9

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