homebridge-tasmota-control 1.4.1-beta.1 → 1.4.1-beta.11

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/index.js CHANGED
@@ -83,10 +83,13 @@ class tasmotaPlatform {
83
83
  return;
84
84
  }
85
85
 
86
+ let i = 0;
86
87
  for (const type of info.deviceTypes) {
88
+ const serialNumber = i === 0 ? info.serialNumber : `${info.serialNumber}${i}`;
89
+
87
90
  let deviceType;
88
91
  switch (type) {
89
- case 0://mielhvac
92
+ case 0: //mielhvac
90
93
  //check files exists, if not then create it
91
94
  try {
92
95
  const postFix = device.host.split('.').join('');
@@ -108,22 +111,22 @@ class tasmotaPlatform {
108
111
  return;
109
112
  }
110
113
 
111
- deviceType = new MiElHvac(api, device, info, refreshInterval);
114
+ deviceType = new MiElHvac(api, device, info, serialNumber, refreshInterval);
112
115
  break;
113
116
  case 1: //switches
114
- deviceType = new Switches(api, device, info, refreshInterval);
117
+ deviceType = new Switches(api, device, info, serialNumber, refreshInterval);
115
118
  break;
116
119
  case 2: //lights
117
- deviceType = new Lights(api, device, info, refreshInterval);
120
+ deviceType = new Lights(api, device, info, serialNumber, refreshInterval);
118
121
  break;
119
122
  case 3: //fans
120
- deviceType = new Fans(api, device, info, refreshInterval);
123
+ deviceType = new Fans(api, device, info, serialNumber, refreshInterval);
121
124
  break;
122
125
  case 4: //sensors
123
- deviceType = new Sensors(api, device, info, refreshInterval);
126
+ deviceType = new Sensors(api, device, info, serialNumber, refreshInterval);
124
127
  break;
125
128
  default:
126
- const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceType}.`);
129
+ const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceTypes}.`);
127
130
  return;
128
131
  }
129
132
 
@@ -168,6 +171,7 @@ class tasmotaPlatform {
168
171
 
169
172
  //start impulse generator
170
173
  await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
174
+ i++;
171
175
  }
172
176
  } catch (error) {
173
177
  const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
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.1",
4
+ "version": "1.4.1-beta.11",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceinfo.js CHANGED
@@ -64,16 +64,15 @@ class DeviceInfo extends EventEmitter {
64
64
  const mielhvac = statusSnsKeys.includes('MiElHVAC') ? types.push(0) : false;
65
65
  const lights = statusStsKeys.some(key => LightKeys.includes(key)) ? types.push(2) : false;
66
66
  const fans = statusStsKeys.includes('FanSpeed') ? types.push(3) : false;
67
+ const switches = !mielhvac && !lights && !fans ? types.push(1) : false
67
68
  const sensors = statusSnsKeys.some(key => SensorKeys.includes(key)) ? types.push(4) : false;
68
- const switches = !mielhvac && !lights && !fans && !sensors ? types.push(1) : false
69
69
  const obj = {
70
70
  deviceTypes: types,
71
71
  deviceName: deviceName,
72
72
  friendlyNames: friendlyNames,
73
73
  modelName: modelName,
74
74
  serialNumber: addressMac,
75
- firmwareRevision: firmwareRevision,
76
- relaysCount: friendlyNames.length
75
+ firmwareRevision: firmwareRevision
77
76
  };
78
77
  return obj;
79
78
  } catch (error) {
package/src/fans.js CHANGED
@@ -6,7 +6,7 @@ import { ApiCommands } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class Fans extends EventEmitter {
9
- constructor(api, config, info, refreshInterval) {
9
+ constructor(api, config, info, serialNumber, refreshInterval) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -17,6 +17,8 @@ class Fans extends EventEmitter {
17
17
 
18
18
  //info
19
19
  this.info = info;
20
+ this.serialNumber = serialNumber;
21
+ this.relaysCount = info.friendlyNames.length;
20
22
 
21
23
  //other config
22
24
  this.lightsNamePrefix = config.lightsNamePrefix || false;
@@ -77,7 +79,7 @@ class Fans extends EventEmitter {
77
79
  const statusSts = statusStsSupported ? sensorStatus.StatusSTS : {};
78
80
 
79
81
  //relays
80
- const relaysCount = this.info.relaysCount;
82
+ const relaysCount = this.relaysCount;
81
83
  if (relaysCount > 0) {
82
84
  this.lights = [];
83
85
  this.fans = [];
@@ -174,10 +176,9 @@ class Fans extends EventEmitter {
174
176
  this.emit('devInfo', `----- ${this.info.deviceName} -----`);
175
177
  this.emit('devInfo', `Manufacturer: Tasmota`);
176
178
  this.emit('devInfo', `Hardware: ${this.info.modelName}`);
177
- this.emit('devInfo', `Serialnr: ${this.info.serialNumber}`)
179
+ this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
178
180
  this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
179
- this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
180
- this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
181
+ this.emit('devInfo', `Relays: ${this.relaysCount}`);
181
182
  this.emit('devInfo', `----------------------------------`);
182
183
  return;
183
184
  }
@@ -189,7 +190,7 @@ class Fans extends EventEmitter {
189
190
  try {
190
191
  //accessory
191
192
  const accessoryName = this.info.deviceName;
192
- const accessoryUUID = AccessoryUUID.generate(this.info.serialNumber);
193
+ const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
193
194
  const accessoryCategory = Categories.FAN;
194
195
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
195
196
 
@@ -198,7 +199,7 @@ class Fans extends EventEmitter {
198
199
  accessory.getService(Service.AccessoryInformation)
199
200
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
200
201
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
201
- .setCharacteristic(Characteristic.SerialNumber, this.info.serialNumber ?? 'Serial Number')
202
+ .setCharacteristic(Characteristic.SerialNumber, this.serialNumber ?? 'Serial Number')
202
203
  .setCharacteristic(Characteristic.FirmwareRevision, this.info.firmwareRevision.replace(/[a-zA-Z]/g, '') ?? '0')
203
204
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
204
205
 
package/src/lights.js CHANGED
@@ -6,7 +6,7 @@ import { ApiCommands } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class Lights extends EventEmitter {
9
- constructor(api, config, info, refreshInterval) {
9
+ constructor(api, config, info, serialNumber, refreshInterval) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -17,6 +17,8 @@ class Lights extends EventEmitter {
17
17
 
18
18
  //info
19
19
  this.info = info;
20
+ this.serialNumber = serialNumber;
21
+ this.relaysCount = info.friendlyNames.length;
20
22
 
21
23
  //other config
22
24
  this.lightsNamePrefix = config.lightsNamePrefix || false;
@@ -77,7 +79,7 @@ class Lights extends EventEmitter {
77
79
  const statusSts = statusStsSupported ? sensorStatus.StatusSTS : {};
78
80
 
79
81
  //relays
80
- const relaysCount = this.info.relaysCount;
82
+ const relaysCount = this.relaysCount;
81
83
  if (relaysCount > 0) {
82
84
  this.lights = [];
83
85
 
@@ -191,9 +193,9 @@ class Lights extends EventEmitter {
191
193
  this.emit('devInfo', `----- ${this.info.deviceName} -----`);
192
194
  this.emit('devInfo', `Manufacturer: Tasmota`);
193
195
  this.emit('devInfo', `Hardware: ${this.info.modelName}`);
194
- this.emit('devInfo', `Serialnr: ${this.info.serialNumber}`)
196
+ this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
195
197
  this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
196
- this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
198
+ this.emit('devInfo', `Relays: ${this.relaysCount}`);
197
199
  this.emit('devInfo', `----------------------------------`);
198
200
  return;
199
201
  }
@@ -205,7 +207,7 @@ class Lights extends EventEmitter {
205
207
  try {
206
208
  //accessory
207
209
  const accessoryName = this.info.deviceName;
208
- const accessoryUUID = AccessoryUUID.generate(this.info.serialNumber);
210
+ const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
209
211
  const accessoryCategory = Categories.LIGHTBULB
210
212
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
211
213
 
@@ -214,7 +216,7 @@ class Lights extends EventEmitter {
214
216
  accessory.getService(Service.AccessoryInformation)
215
217
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
216
218
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
217
- .setCharacteristic(Characteristic.SerialNumber, this.info.serialNumber ?? 'Serial Number')
219
+ .setCharacteristic(Characteristic.SerialNumber, this.serialNumber ?? 'Serial Number')
218
220
  .setCharacteristic(Characteristic.FirmwareRevision, this.info.firmwareRevision.replace(/[a-zA-Z]/g, '') ?? '0')
219
221
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
220
222
 
package/src/mielhvac.js CHANGED
@@ -6,7 +6,7 @@ import { ApiCommands, MiElHVAC, TemperatureDisplayUnits } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class MiElHvac extends EventEmitter {
9
- constructor(api, config, info, refreshInterval) {
9
+ constructor(api, config, info, serialNumber, refreshInterval) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -17,6 +17,7 @@ class MiElHvac extends EventEmitter {
17
17
 
18
18
  //info
19
19
  this.info = info;
20
+ this.serialNumber = serialNumber;
20
21
 
21
22
  //mitsubishi ac
22
23
  const miElHvac = config.miElHvac ?? {};
@@ -811,7 +812,7 @@ class MiElHvac extends EventEmitter {
811
812
  this.emit('devInfo', `----- ${this.info.deviceName} -----`);
812
813
  this.emit('devInfo', `Manufacturer: Tasmota`);
813
814
  this.emit('devInfo', `Hardware: ${this.info.modelName}`);
814
- this.emit('devInfo', `Serialnr: ${this.info.serialNumber}`)
815
+ this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
815
816
  this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
816
817
  this.emit('devInfo', `Sensor: MiELHVAC`);
817
818
  this.emit('devInfo', `----------------------------------`);
@@ -825,7 +826,7 @@ class MiElHvac extends EventEmitter {
825
826
  try {
826
827
  //accessory
827
828
  const accessoryName = this.info.deviceName;
828
- const accessoryUUID = AccessoryUUID.generate(this.info.serialNumber);
829
+ const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
829
830
  const accessoryCategory = Categories.AIR_CONDITIONER
830
831
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
831
832
 
@@ -834,7 +835,7 @@ class MiElHvac extends EventEmitter {
834
835
  accessory.getService(Service.AccessoryInformation)
835
836
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
836
837
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
837
- .setCharacteristic(Characteristic.SerialNumber, this.info.serialNumber ?? 'Serial Number')
838
+ .setCharacteristic(Characteristic.SerialNumber, this.serialNumber ?? 'Serial Number')
838
839
  .setCharacteristic(Characteristic.FirmwareRevision, this.info.firmwareRevision.replace(/[a-zA-Z]/g, '') ?? '0')
839
840
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
840
841
 
@@ -846,7 +847,7 @@ class MiElHvac extends EventEmitter {
846
847
  const coolDryFanMode = [MiElHVAC.SetMode.cool, MiElHVAC.SetMode.cool, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.coolDryFanMode]; //NONE, COOL, DRY, FAN
847
848
 
848
849
  //services
849
- this.miElHvacService = new Service.HeaterCooler(accessoryName, `HeaterCooler ${this.info.serialNumber}`);
850
+ this.miElHvacService = new Service.HeaterCooler(accessoryName, `HeaterCooler ${this.serialNumber}`);
850
851
  this.miElHvacService.setPrimaryService(true);
851
852
  this.miElHvacService.getCharacteristic(Characteristic.Active)
852
853
  .onGet(async () => {
package/src/sensors.js CHANGED
@@ -6,7 +6,7 @@ import { ApiCommands, SensorKeys } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class Sensors extends EventEmitter {
9
- constructor(api, config, info, refreshInterval) {
9
+ constructor(api, config, info, serialNumber, refreshInterval) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -17,6 +17,7 @@ class Sensors extends EventEmitter {
17
17
 
18
18
  //info
19
19
  this.info = info;
20
+ this.serialNumber = serialNumber;
20
21
 
21
22
  //other config
22
23
  this.sensorsNamePrefix = config.sensorsNamePrefix || false;
@@ -85,19 +86,7 @@ class Sensors extends EventEmitter {
85
86
 
86
87
  //status SNS
87
88
  if (statusSnsSupported) {
88
- this.sensorsName = [];
89
- this.sensorsTemperature = [];
90
- this.sensorsReferenceTemperature = [];
91
- this.sensorsObjTemperature = [];
92
- this.sensorsAmbTemperature = [];
93
- this.sensorsDewPointTemperature = [];
94
- this.sensorsHumidity = [];
95
- this.sensorsPressure = [];
96
- this.sensorsGas = [];
97
- this.sensorsCarbonDioxyde = [];
98
- this.sensorsAmbientLight = [];
99
- this.sensorsMotion = [];
100
-
89
+ this.sensors = [];
101
90
  const sensor = Object.entries(statusSns)
102
91
  .filter(([key]) => SensorKeys.some(type => key.includes(type)))
103
92
  .reduce((obj, [key, value]) => {
@@ -106,133 +95,61 @@ class Sensors extends EventEmitter {
106
95
  }, {});
107
96
 
108
97
  for (const [key, value] of Object.entries(sensor)) {
109
- const sensorName = key ?? `Sensor`;
110
98
  const sensorData = value;
111
99
 
112
100
  //sensors
113
- const temperature = sensorData.Temperature ?? false;
114
- const referenceTemperature = sensorData.ReferenceTemperature ?? false;
115
- const objTemperature = sensorData.OBJTMP ?? false;
116
- const ambTemperature = sensorData.AMBTMP ?? false;
117
- const dewPointTemperature = sensorData.DewPoint ?? false;
118
- const humidity = sensorData.Humidity ?? false;
119
- const pressure = sensorData.Pressure ?? false;
120
- const gas = sensorData.Gas ?? false;
121
- const carbonDioxyde = sensorData.CarbonDioxyde ?? false;
122
- const ambientLight = sensorData.Ambient ?? false;
123
- const motion = sensorData === 'ON';
124
-
125
- //energy
126
- const energyTotalStartTime = sensorData.TotalStartTime ?? '';
127
- const energyTotal = sensorData.Total ?? 0;
128
- const energyPeriod = sensorData.Period ?? 0;
129
- const energyYesterday = sensorData.Yesterday ?? 0;
130
- const energyToday = sensorData.Today ?? 0;
131
- const power = sensorData.Power ?? 0;
132
- const apparentPower = sensorData.ApparentPower ?? 0;
133
- const reactivePower = sensorData.ReactivePower ?? 0;
134
- const factor = sensorData.Factor ?? 0;
135
- const voltage = sensorData.Voltage ?? 0;
136
- const current = sensorData.Current ?? 0;
137
- const load = sensorData.Load ?? 0;
101
+ const obj = {
102
+ name: key ?? `Sensor`,
103
+ temperature: sensorData.Temperature,
104
+ referenceTemperature: sensorData.ReferenceTemperature,
105
+ objTemperature: sensorData.OBJTMP,
106
+ ambTemperature: sensorData.AMBTMP,
107
+ dewPointTemperature: sensorData.DewPoint,
108
+ humidity: sensorData.Humidity,
109
+ pressure: sensorData.Pressure,
110
+ gas: sensorData.Gas,
111
+ carbonDioxyde: sensorData.CarbonDioxyde,
112
+ ambientLight: sensorData.Ambient,
113
+ motion: sensorData === 'ON',
114
+ //energy
115
+ energyTotalStartTime: sensorData.TotalStartTime ?? '',
116
+ energyTotal: sensorData.Total ?? 0,
117
+ energyPeriod: sensorData.Period ?? 0,
118
+ energyYesterday: sensorData.Yesterday ?? 0,
119
+ energyToday: sensorData.Today ?? 0,
120
+ power: sensorData.Power ?? 0,
121
+ apparentPower: sensorData.ApparentPower ?? 0,
122
+ reactivePower: sensorData.ReactivePower ?? 0,
123
+ factor: sensorData.Factor ?? 0,
124
+ voltage: sensorData.Voltage ?? 0,
125
+ current: sensorData.Current ?? 0,
126
+ load: sensorData.Load ?? 0,
127
+ time: sensorStatus.Time ?? '',
128
+ tempUnit: sensorStatus.TempUnit === 'C' ? '°C' : 'F',
129
+ pressureUnit: sensorStatus.PressureUnit ?? 'hPa'
130
+ }
138
131
 
139
132
  //push to array
140
- this.sensorsName.push(sensorName);
141
- const push1 = temperature ? this.sensorsTemperature.push(temperature) : false;
142
- const push2 = referenceTemperature ? this.sensorsReferenceTemperature.push(referenceTemperature) : false;
143
- const push3 = objTemperature ? this.sensorsAmbTemperature.push(objTemperature) : false;
144
- const push4 = ambTemperature ? this.sensorsAmbTemperature.push(ambTemperature) : false;
145
- const push5 = dewPointTemperature ? this.sensorsDewPointTemperature.push(dewPointTemperature) : false;
146
- const push6 = humidity ? this.sensorsHumidity.push(humidity) : false;
147
- const push7 = pressure ? this.sensorsPressure.push(pressure) : false;
148
- const push8 = gas ? this.sensorsGas.push(gas) : false;
149
- const push9 = carbonDioxyde ? this.sensorsCarbonDioxyde.push(carbonDioxyde) : false;
150
- const push10 = ambientLight ? this.sensorsAmbientLight.push(ambientLight) : false;
151
- const push11 = motion ? this.sensorsMotion.push(motion) : false;
133
+ this.sensors.push(obj);
152
134
  }
153
-
154
- this.time = sensorStatus.Time ?? '';
155
- this.tempUnit = sensorStatus.TempUnit === 'C' ? '°C' : 'F';
156
- this.pressureUnit = sensorStatus.PressureUnit ?? 'hPa';
157
- this.sensorsTemperatureCount = this.sensorsTemperature.length;
158
- this.sensorsReferenceTemperatureCount = this.sensorsReferenceTemperature.length;
159
- this.sensorsObjTemperatureCount = this.sensorsObjTemperature.length;
160
- this.sensorsAmbTemperatureCount = this.sensorsAmbTemperature.length;
161
- this.sensorsDewPointTemperatureCount = this.sensorsDewPointTemperature.length;
162
- this.sensorsHumidityCount = this.sensorsHumidity.length;
163
- this.sensorsPressureCount = this.sensorsPressure.length;
164
- this.sensorsGasCount = this.sensorsGas.length;
165
- this.sensorsCarbonDioxydeCount = this.sensorsCarbonDioxyde.length;
166
- this.sensorsAmbientLightCount = this.sensorsAmbientLight.length;
167
- this.sensorsMotionCount = this.sensorsMotion.length;
168
- this.sensorsCount = this.sensorsName.length;
169
-
135
+ this.sensorsCount = this.sensors.length;
170
136
 
171
137
  //update characteristics
172
- if (this.sensorTemperatureServices) {
173
- for (let i = 0; i < this.sensorsTemperatureCount; i++) {
174
- const value = this.sensorsTemperature[i];
175
- this.sensorTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
176
- }
177
- }
178
-
179
- if (this.sensorReferenceTemperatureServices) {
180
- for (let i = 0; i < this.sensorsReferenceTemperatureCount; i++) {
181
- const value = this.sensorsReferenceTemperature[i];
182
- this.sensorReferenceTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
183
- }
184
- }
185
-
186
- if (this.sensorObjTemperatureServices) {
187
- for (let i = 0; i < this.sensorsObjTemperatureCount; i++) {
188
- const value = this.sensorsObjTemperature[i];
189
- this.sensorObjTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
190
- }
191
- }
192
-
193
- if (this.sensorAmbTemperatureServices) {
194
- for (let i = 0; i < this.sensorsAmbTemperatureCount; i++) {
195
- const value = this.sensorsAmbTemperature[i];
196
- this.sensorAmbTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
197
- }
198
- }
199
-
200
- if (this.sensorDewPointTemperatureServices) {
201
- for (let i = 0; i < this.sensorsDewPointTemperatureCount; i++) {
202
- const value = this.sensorsDewPointTemperature[i];
203
- this.sensorDewPointTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
204
- }
205
- }
206
-
207
- if (this.sensorHumidityServices) {
208
- for (let i = 0; i < this.sensorsHumidityCount; i++) {
209
- const value = this.sensorsHumidity[i];
210
- this.sensorHumidityServices[i].updateCharacteristic(Characteristic.CurrentRelativeHumidity, value);
211
- }
212
- }
213
-
214
- if (this.sensorCarbonDioxydeServices) {
215
- for (let i = 0; i < this.sensorsCarbonDioxydeCount; i++) {
216
- const state = this.sensorsCarbonDioxyde[i] > 1000;
217
- const value = this.sensorsCarbonDioxyde[i];
218
- this.sensorCarbonDioxydeServices[i]
219
- .updateCharacteristic(Characteristic.CarbonDioxideDetected, state)
220
- .updateCharacteristic(Characteristic.CarbonDioxideLevel, value)
221
- .updateCharacteristic(Characteristic.CarbonDioxidePeakLevel, value);
222
- }
223
- }
224
-
225
- if (this.sensorAmbientLightServices) {
226
- for (let i = 0; i < this.sensorsAmbientLightCount; i++) {
227
- const value = this.sensorsAmbientLight[i];
228
- this.sensorAmbientLightServices[i].updateCharacteristic(Characteristic.CurrentAmbientLightLevel, value);
229
- }
230
- }
231
-
232
- if (this.sensorMotionServices) {
233
- for (let i = 0; i < this.sensorsMotionCount; i++) {
234
- const state = this.sensorsMotion[i];
235
- this.sensorMotionServices[i].updateCharacteristic(Characteristic.MotionDetected, state);
138
+ if (this.sensorsCount > 0) {
139
+ for (let i = 0; i < this.sensorsCount; i++) {
140
+ const sensor = this.sensors[i];
141
+ this.sensorTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.temperature);
142
+ this.sensorReferenceTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.referenceTemperature);
143
+ this.sensorObjTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.objTemperature);
144
+ this.sensorAmbTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.ambTemperature);
145
+ this.sensorDewPointTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.dewPointTemperature);
146
+ this.sensorHumidityServices?.[i]?.updateCharacteristic(Characteristic.CurrentRelativeHumidity, sensor.humidity);
147
+ this.sensorCarbonDioxydeServices?.[i]
148
+ ?.updateCharacteristic(Characteristic.CarbonDioxideDetected, sensor.carbonDioxyde > 1000)
149
+ .updateCharacteristic(Characteristic.CarbonDioxideLevel, sensor.carbonDioxyde)
150
+ .updateCharacteristic(Characteristic.CarbonDioxidePeakLevel, sensor.carbonDioxyde);
151
+ this.sensorAmbientLightServices?.[i]?.updateCharacteristic(Characteristic.CurrentAmbientLightLevel, sensor.ambientLight);
152
+ this.sensorMotionServices?.[i]?.updateCharacteristic(Characteristic.MotionDetected, sensor.motion);
236
153
  }
237
154
  }
238
155
  }
@@ -278,7 +195,7 @@ class Sensors extends EventEmitter {
278
195
  this.emit('devInfo', `----- ${this.info.deviceName} -----`);
279
196
  this.emit('devInfo', `Manufacturer: Tasmota`);
280
197
  this.emit('devInfo', `Hardware: ${this.info.modelName}`);
281
- this.emit('devInfo', `Serialnr: ${this.info.serialNumber}`)
198
+ this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
282
199
  this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
283
200
  this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
284
201
  this.emit('devInfo', `----------------------------------`);
@@ -292,7 +209,7 @@ class Sensors extends EventEmitter {
292
209
  try {
293
210
  //accessory
294
211
  const accessoryName = this.info.deviceName;
295
- const accessoryUUID = AccessoryUUID.generate(this.info.serialNumber);
212
+ const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
296
213
  const accessoryCategory = Categories.SENSOR;
297
214
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
298
215
 
@@ -301,7 +218,7 @@ class Sensors extends EventEmitter {
301
218
  accessory.getService(Service.AccessoryInformation)
302
219
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
303
220
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
304
- .setCharacteristic(Characteristic.SerialNumber, this.info.serialNumber ?? 'Serial Number')
221
+ .setCharacteristic(Characteristic.SerialNumber, this.serialNumber ?? 'Serial Number')
305
222
  .setCharacteristic(Characteristic.FirmwareRevision, this.info.firmwareRevision.replace(/[a-zA-Z]/g, '') ?? '0')
306
223
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
307
224
 
@@ -310,203 +227,170 @@ class Sensors extends EventEmitter {
310
227
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
311
228
 
312
229
  //temperature
313
- const sensorsTemperatureCount = this.sensorsTemperatureCount;
314
- if (sensorsTemperatureCount > 0) {
315
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
316
- this.sensorTemperatureServices = [];
317
- for (let i = 0; i < sensorsTemperatureCount; i++) {
318
- const sensorName = this.sensorsName[i];
230
+ for (const sensor of this.sensors) {
231
+ const sensorName = sensor.name;
232
+ if (sensor.temperature !== undefined) {
233
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
234
+ this.sensorTemperatureServices = [];
319
235
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
320
236
  const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
321
237
  sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
322
238
  sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
323
239
  sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
324
240
  .onGet(async () => {
325
- const value = this.sensorsTemperature[i];
326
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
241
+ const value = sensor.temperature;
242
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${sensor.tempUnit}`);
327
243
  return value;
328
244
  });
329
245
  this.sensorTemperatureServices.push(sensorTemperatureService);
330
246
  }
331
- }
332
247
 
333
- //reference temperature
334
- const sensorsReferenceTemperatureCount = this.sensorsReferenceTemperatureCount;
335
- if (sensorsReferenceTemperatureCount > 0) {
336
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
337
- this.sensorReferenceTemperatureServices = [];
338
- for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
339
- const sensorName = this.sensorsName[i];
248
+ //reference temperature
249
+ if (sensor.referenceTemperature !== undefined) {
250
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
251
+ this.sensorReferenceTemperatureServices = [];
340
252
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
341
253
  const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
342
254
  sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
343
255
  sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
344
256
  sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
345
257
  .onGet(async () => {
346
- const value = this.sensorsReferenceTemperature[i];
347
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
258
+ const value = sensor.referenceTemperature;
259
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${sensor.tempUnit}`);
348
260
  return value;
349
261
  });
350
262
  this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
351
263
  }
352
- }
353
264
 
354
- //object temperature
355
- const sensorsObjTemperatureCount = this.sensorsObjTemperatureCount;
356
- if (sensorsObjTemperatureCount > 0) {
357
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
358
- this.sensorObjTemperatureServices = [];
359
- for (let i = 0; i < sensorsObjTemperatureCount; i++) {
360
- const sensorName = this.sensorsName[i];
265
+ //object temperature
266
+ if (sensor.objTemperature !== undefined) {
267
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
268
+ this.sensorObjTemperatureServices = [];
361
269
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
362
270
  const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
363
271
  sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
364
272
  sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
365
273
  sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
366
274
  .onGet(async () => {
367
- const value = this.sensorsObjTemperature[i];
368
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
275
+ const value = sensor.objTemperature;
276
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${sensor.tempUnit}`);
369
277
  return value;
370
278
  });
371
279
  this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
372
280
  }
373
- }
374
281
 
375
- //ambient temperature
376
- const sensorsAmbTemperatureCount = this.sensorsAmbTemperatureCount;
377
- if (sensorsAmbTemperatureCount > 0) {
378
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
379
- this.sensorAmbTemperatureServices = [];
380
- for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
381
- const sensorName = this.sensorsName[i];
282
+ //ambient temperature
283
+ if (sensor.ambTemperature !== undefined) {
284
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
285
+ this.sensorAmbTemperatureServices = [];
382
286
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
383
287
  const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
384
288
  sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
385
289
  sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
386
290
  sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
387
291
  .onGet(async () => {
388
- const value = this.sensorsAmbTemperature[i];
389
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
292
+ const value = sensor.ambTemperature;
293
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${sensor.tempUnit}`);
390
294
  return value;
391
295
  });
392
296
  this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
393
297
  }
394
- }
395
298
 
396
- //dew point temperature
397
- const sensorsDewPointTemperatureCount = this.sensorsDewPointTemperatureCount;
398
- if (sensorsDewPointTemperatureCount > 0) {
399
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
400
- this.sensorDewPointTemperatureServices = [];
401
- for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
402
- const sensorName = this.sensorsName[i];
299
+ //dew point temperature
300
+ if (sensor.dewPointTemperature !== undefined) {
301
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
302
+ this.sensorDewPointTemperatureServices = [];
403
303
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
404
304
  const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
405
305
  sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
406
306
  sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
407
307
  sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
408
308
  .onGet(async () => {
409
- const value = this.sensorsDewPointTemperature[i];
410
- const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
309
+ const value = sensor.dewPointTemperature;
310
+ const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${sensor.tempUnit}`);
411
311
  return value;
412
312
  });
413
313
  this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
414
314
  }
415
- }
416
315
 
417
- //humidity
418
- const sensorsHumidityCount = this.sensorsHumidityCount;
419
- if (sensorsHumidityCount > 0) {
420
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
421
- this.sensorHumidityServices = [];
422
- for (let i = 0; i < sensorsHumidityCount; i++) {
423
- const sensorName = this.sensorsName[i];
316
+ //humidity
317
+ if (sensor.humidity !== undefined) {
318
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
319
+ this.sensorHumidityServices = [];
424
320
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
425
321
  const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
426
322
  sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
427
323
  sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
428
324
  sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
429
325
  .onGet(async () => {
430
- const value = this.sensorsHumidity[i];
326
+ const value = sensor.humidity;
431
327
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
432
328
  return value;
433
329
  });
434
330
  this.sensorHumidityServices.push(sensorHumidityService);
435
331
  }
436
- }
437
332
 
438
- //pressure
333
+ //pressure
439
334
 
440
- //gas
335
+ //gas
441
336
 
442
- //carbon dioxyde
443
- const sensorsCarbonDioxydeCount = this.sensorsCarbonDioxydeCount;
444
- if (sensorsCarbonDioxydeCount > 0) {
445
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
446
- this.sensorCarbonDioxydeServices = [];
447
- for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
448
- const sensorName = this.sensorsName[i];
337
+ //carbon dioxyde
338
+ if (sensor.carbonDioxyde !== undefined) {
339
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
340
+ this.sensorCarbonDioxydeServices = [];
449
341
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
450
342
  const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
451
343
  sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
452
344
  sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
453
345
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
454
346
  .onGet(async () => {
455
- const state = this.sensorsCarbonDioxyde[i] > 1000;
347
+ const state = sensor.carbonDioxyde > 1000;
456
348
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
457
349
  return state;
458
350
  });
459
351
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
460
352
  .onGet(async () => {
461
- const value = this.sensorsCarbonDioxyde[i];
353
+ const value = sensor.carbonDioxyde;
462
354
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
463
355
  return value;
464
356
  });
465
357
  sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
466
358
  .onGet(async () => {
467
- const value = this.sensorsCarbonDioxyde[i];
359
+ const value = sensor.carbonDioxyde;
468
360
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
469
361
  return value;
470
362
  });
471
363
  this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
472
364
  }
473
- }
474
365
 
475
- //ambient light
476
- const sensorsAmbientLightCount = this.sensorsAmbientLightCount;
477
- if (sensorsAmbientLightCount > 0) {
478
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
479
- this.sensorAmbientLightServices = [];
480
- for (let i = 0; i < sensorsAmbientLightCount; i++) {
481
- const sensorName = this.sensorsName[i];
366
+ //ambient light
367
+ if (sensor.ambientLight !== undefined) {
368
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
369
+ this.sensorAmbientLightServices = [];
482
370
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
483
371
  const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
484
372
  sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
485
373
  sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
486
374
  sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
487
375
  .onGet(async () => {
488
- const value = this.sensorsAmbientLight[i];
376
+ const value = sensor.ambientLight;
489
377
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
490
378
  return value;
491
379
  });
492
380
  this.sensorAmbientLightServices.push(sensorAmbientLightService);
493
381
  }
494
- }
495
382
 
496
- //motion
497
- const sensorsMotionCount = this.sensorsMotionCount;
498
- if (sensorsMotionCount > 0) {
499
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
500
- this.sensorMotionServices = [];
501
- for (let i = 0; i < sensorsMotionCount; i++) {
502
- const sensorName = this.sensorsName[i];
383
+ //motion
384
+ if (sensor.motion !== undefined) {
385
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
386
+ this.sensorMotionServices = [];
503
387
  const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
504
388
  const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
505
389
  sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
506
390
  sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
507
391
  sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
508
392
  .onGet(async () => {
509
- const state = this.sensorsMotion[i];
393
+ const state = sensor.motion;
510
394
  const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
511
395
  return state;
512
396
  });
package/src/switches.js CHANGED
@@ -6,7 +6,7 @@ import { ApiCommands } from './constants.js';
6
6
  let Accessory, Characteristic, Service, Categories, AccessoryUUID;
7
7
 
8
8
  class Switches extends EventEmitter {
9
- constructor(api, config, info, refreshInterval) {
9
+ constructor(api, config, info, serialNumber, refreshInterval) {
10
10
  super();
11
11
 
12
12
  Accessory = api.platformAccessory;
@@ -17,6 +17,8 @@ class Switches extends EventEmitter {
17
17
 
18
18
  //info
19
19
  this.info = info;
20
+ this.serialNumber = serialNumber;
21
+ this.relaysCount = info.friendlyNames.length;
20
22
 
21
23
  //other config
22
24
  this.relaysDisplayType = config.relaysDisplayType || 0;
@@ -64,7 +66,7 @@ class Switches extends EventEmitter {
64
66
  const debug = this.enableDebugMode ? this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`) : false;
65
67
 
66
68
  //relays
67
- const relaysCount = this.info.relaysCount;
69
+ const relaysCount = this.relaysCount;
68
70
  if (relaysCount > 0) {
69
71
  this.switchesOutlets = [];
70
72
 
@@ -134,9 +136,9 @@ class Switches extends EventEmitter {
134
136
  this.emit('devInfo', `----- ${this.info.deviceName} -----`);
135
137
  this.emit('devInfo', `Manufacturer: Tasmota`);
136
138
  this.emit('devInfo', `Hardware: ${this.info.modelName}`);
137
- this.emit('devInfo', `Serialnr: ${this.info.serialNumber}`)
139
+ this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
138
140
  this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
139
- this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
141
+ this.emit('devInfo', `Relays: ${this.relaysCount}`);
140
142
  this.emit('devInfo', `----------------------------------`);
141
143
  return;
142
144
  }
@@ -148,7 +150,7 @@ class Switches extends EventEmitter {
148
150
  try {
149
151
  //accessory
150
152
  const accessoryName = this.info.deviceName;
151
- const accessoryUUID = AccessoryUUID.generate(this.info.serialNumber);
153
+ const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
152
154
  const accessoryCategory = this.relaysDisplayType === 0 ? Categories.OUTLET : Categories.SWITCH;
153
155
  const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
154
156
 
@@ -157,7 +159,7 @@ class Switches extends EventEmitter {
157
159
  accessory.getService(Service.AccessoryInformation)
158
160
  .setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
159
161
  .setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
160
- .setCharacteristic(Characteristic.SerialNumber, this.info.serialNumber ?? 'Serial Number')
162
+ .setCharacteristic(Characteristic.SerialNumber, this.serialNumber ?? 'Serial Number')
161
163
  .setCharacteristic(Characteristic.FirmwareRevision, this.info.firmwareRevision.replace(/[a-zA-Z]/g, '') ?? '0')
162
164
  .setCharacteristic(Characteristic.ConfiguredName, accessoryName);
163
165