homebridge-tasmota-control 1.4.1-beta.9 → 1.5.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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/deviceinfo.js +1 -2
- package/src/fans.js +3 -3
- package/src/lights.js +3 -3
- package/src/sensors.js +106 -221
- package/src/switches.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.5.0] - (31.05.2025)
|
|
9
|
+
|
|
10
|
+
## Changes
|
|
11
|
+
|
|
12
|
+
- added support for sensors as a seperate accessory
|
|
13
|
+
- redme updated
|
|
14
|
+
- cleanup
|
|
15
|
+
|
|
8
16
|
## [1.4.0] - (30.05.2025)
|
|
9
17
|
|
|
10
18
|
## Changes
|
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Homebridge plugin for Tasmota flashed devices.
|
|
|
76
76
|
* Light - `Power ON/OFF`, `Dimmer`, `Color Temperature`, `Hue`, `Saturation`
|
|
77
77
|
* Outlet - `Power ON/OFF`
|
|
78
78
|
* Switch - `Power ON/OFF`
|
|
79
|
-
* Fan - `
|
|
79
|
+
* Fan - `Fan ON/OFF`, `Speed`, `Light ON/OFF`
|
|
80
80
|
|
|
81
81
|
* Supported Sensors:
|
|
82
82
|
* Temperature - `Temperature`, `Dew Point`, `Reference`, `Obj`, `Amb`
|
package/package.json
CHANGED
package/src/deviceinfo.js
CHANGED
|
@@ -72,8 +72,7 @@ class DeviceInfo extends EventEmitter {
|
|
|
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
|
@@ -18,6 +18,7 @@ class Fans extends EventEmitter {
|
|
|
18
18
|
//info
|
|
19
19
|
this.info = info;
|
|
20
20
|
this.serialNumber = serialNumber;
|
|
21
|
+
this.relaysCount = info.friendlyNames.length;
|
|
21
22
|
|
|
22
23
|
//other config
|
|
23
24
|
this.lightsNamePrefix = config.lightsNamePrefix || false;
|
|
@@ -78,7 +79,7 @@ class Fans extends EventEmitter {
|
|
|
78
79
|
const statusSts = statusStsSupported ? sensorStatus.StatusSTS : {};
|
|
79
80
|
|
|
80
81
|
//relays
|
|
81
|
-
const relaysCount = this.
|
|
82
|
+
const relaysCount = this.relaysCount;
|
|
82
83
|
if (relaysCount > 0) {
|
|
83
84
|
this.lights = [];
|
|
84
85
|
this.fans = [];
|
|
@@ -177,8 +178,7 @@ class Fans extends EventEmitter {
|
|
|
177
178
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
178
179
|
this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
|
|
179
180
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
180
|
-
this.emit('devInfo', `Relays: ${this.
|
|
181
|
-
this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
|
|
181
|
+
this.emit('devInfo', `Relays: ${this.relaysCount}`);
|
|
182
182
|
this.emit('devInfo', `----------------------------------`);
|
|
183
183
|
return;
|
|
184
184
|
}
|
package/src/lights.js
CHANGED
|
@@ -18,10 +18,10 @@ class Lights extends EventEmitter {
|
|
|
18
18
|
//info
|
|
19
19
|
this.info = info;
|
|
20
20
|
this.serialNumber = serialNumber;
|
|
21
|
+
this.relaysCount = info.friendlyNames.length;
|
|
21
22
|
|
|
22
23
|
//other config
|
|
23
24
|
this.lightsNamePrefix = config.lightsNamePrefix || false;
|
|
24
|
-
this.sensorsNamePrefix = config.sensorsNamePrefix || false;
|
|
25
25
|
this.enableDebugMode = config.enableDebugMode || false;
|
|
26
26
|
this.disableLogInfo = config.disableLogInfo || false;
|
|
27
27
|
this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
|
|
@@ -78,7 +78,7 @@ class Lights extends EventEmitter {
|
|
|
78
78
|
const statusSts = statusStsSupported ? sensorStatus.StatusSTS : {};
|
|
79
79
|
|
|
80
80
|
//relays
|
|
81
|
-
const relaysCount = this.
|
|
81
|
+
const relaysCount = this.relaysCount;
|
|
82
82
|
if (relaysCount > 0) {
|
|
83
83
|
this.lights = [];
|
|
84
84
|
|
|
@@ -194,7 +194,7 @@ class Lights extends EventEmitter {
|
|
|
194
194
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
195
195
|
this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
|
|
196
196
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
197
|
-
this.emit('devInfo', `Relays: ${this.
|
|
197
|
+
this.emit('devInfo', `Relays: ${this.relaysCount}`);
|
|
198
198
|
this.emit('devInfo', `----------------------------------`);
|
|
199
199
|
return;
|
|
200
200
|
}
|
package/src/sensors.js
CHANGED
|
@@ -86,19 +86,7 @@ class Sensors extends EventEmitter {
|
|
|
86
86
|
|
|
87
87
|
//status SNS
|
|
88
88
|
if (statusSnsSupported) {
|
|
89
|
-
this.
|
|
90
|
-
this.sensorsTemperature = [];
|
|
91
|
-
this.sensorsReferenceTemperature = [];
|
|
92
|
-
this.sensorsObjTemperature = [];
|
|
93
|
-
this.sensorsAmbTemperature = [];
|
|
94
|
-
this.sensorsDewPointTemperature = [];
|
|
95
|
-
this.sensorsHumidity = [];
|
|
96
|
-
this.sensorsPressure = [];
|
|
97
|
-
this.sensorsGas = [];
|
|
98
|
-
this.sensorsCarbonDioxyde = [];
|
|
99
|
-
this.sensorsAmbientLight = [];
|
|
100
|
-
this.sensorsMotion = [];
|
|
101
|
-
|
|
89
|
+
this.sensors = [];
|
|
102
90
|
const sensor = Object.entries(statusSns)
|
|
103
91
|
.filter(([key]) => SensorKeys.some(type => key.includes(type)))
|
|
104
92
|
.reduce((obj, [key, value]) => {
|
|
@@ -107,133 +95,61 @@ class Sensors extends EventEmitter {
|
|
|
107
95
|
}, {});
|
|
108
96
|
|
|
109
97
|
for (const [key, value] of Object.entries(sensor)) {
|
|
110
|
-
const sensorName = key ?? `Sensor`;
|
|
111
98
|
const sensorData = value;
|
|
112
99
|
|
|
113
|
-
//
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
100
|
+
//sensor
|
|
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
|
+
}
|
|
139
131
|
|
|
140
132
|
//push to array
|
|
141
|
-
this.
|
|
142
|
-
const push1 = temperature ? this.sensorsTemperature.push(temperature) : false;
|
|
143
|
-
const push2 = referenceTemperature ? this.sensorsReferenceTemperature.push(referenceTemperature) : false;
|
|
144
|
-
const push3 = objTemperature ? this.sensorsAmbTemperature.push(objTemperature) : false;
|
|
145
|
-
const push4 = ambTemperature ? this.sensorsAmbTemperature.push(ambTemperature) : false;
|
|
146
|
-
const push5 = dewPointTemperature ? this.sensorsDewPointTemperature.push(dewPointTemperature) : false;
|
|
147
|
-
const push6 = humidity ? this.sensorsHumidity.push(humidity) : false;
|
|
148
|
-
const push7 = pressure ? this.sensorsPressure.push(pressure) : false;
|
|
149
|
-
const push8 = gas ? this.sensorsGas.push(gas) : false;
|
|
150
|
-
const push9 = carbonDioxyde ? this.sensorsCarbonDioxyde.push(carbonDioxyde) : false;
|
|
151
|
-
const push10 = ambientLight ? this.sensorsAmbientLight.push(ambientLight) : false;
|
|
152
|
-
const push11 = motion ? this.sensorsMotion.push(motion) : false;
|
|
133
|
+
this.sensors.push(obj);
|
|
153
134
|
}
|
|
154
|
-
|
|
155
|
-
this.time = sensorStatus.Time ?? '';
|
|
156
|
-
this.tempUnit = sensorStatus.TempUnit === 'C' ? '°C' : 'F';
|
|
157
|
-
this.pressureUnit = sensorStatus.PressureUnit ?? 'hPa';
|
|
158
|
-
this.sensorsTemperatureCount = this.sensorsTemperature.length;
|
|
159
|
-
this.sensorsReferenceTemperatureCount = this.sensorsReferenceTemperature.length;
|
|
160
|
-
this.sensorsObjTemperatureCount = this.sensorsObjTemperature.length;
|
|
161
|
-
this.sensorsAmbTemperatureCount = this.sensorsAmbTemperature.length;
|
|
162
|
-
this.sensorsDewPointTemperatureCount = this.sensorsDewPointTemperature.length;
|
|
163
|
-
this.sensorsHumidityCount = this.sensorsHumidity.length;
|
|
164
|
-
this.sensorsPressureCount = this.sensorsPressure.length;
|
|
165
|
-
this.sensorsGasCount = this.sensorsGas.length;
|
|
166
|
-
this.sensorsCarbonDioxydeCount = this.sensorsCarbonDioxyde.length;
|
|
167
|
-
this.sensorsAmbientLightCount = this.sensorsAmbientLight.length;
|
|
168
|
-
this.sensorsMotionCount = this.sensorsMotion.length;
|
|
169
|
-
this.sensorsCount = this.sensorsName.length;
|
|
170
|
-
|
|
135
|
+
this.sensorsCount = this.sensors.length;
|
|
171
136
|
|
|
172
137
|
//update characteristics
|
|
173
|
-
if (this.
|
|
174
|
-
for (let i = 0; i < this.
|
|
175
|
-
const
|
|
176
|
-
this.sensorTemperatureServices[i]
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (let i = 0; i < this.sensorsObjTemperatureCount; i++) {
|
|
189
|
-
const value = this.sensorsObjTemperature[i];
|
|
190
|
-
this.sensorObjTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (this.sensorAmbTemperatureServices) {
|
|
195
|
-
for (let i = 0; i < this.sensorsAmbTemperatureCount; i++) {
|
|
196
|
-
const value = this.sensorsAmbTemperature[i];
|
|
197
|
-
this.sensorAmbTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (this.sensorDewPointTemperatureServices) {
|
|
202
|
-
for (let i = 0; i < this.sensorsDewPointTemperatureCount; i++) {
|
|
203
|
-
const value = this.sensorsDewPointTemperature[i];
|
|
204
|
-
this.sensorDewPointTemperatureServices[i].updateCharacteristic(Characteristic.CurrentTemperature, value);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (this.sensorHumidityServices) {
|
|
209
|
-
for (let i = 0; i < this.sensorsHumidityCount; i++) {
|
|
210
|
-
const value = this.sensorsHumidity[i];
|
|
211
|
-
this.sensorHumidityServices[i].updateCharacteristic(Characteristic.CurrentRelativeHumidity, value);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (this.sensorCarbonDioxydeServices) {
|
|
216
|
-
for (let i = 0; i < this.sensorsCarbonDioxydeCount; i++) {
|
|
217
|
-
const state = this.sensorsCarbonDioxyde[i] > 1000;
|
|
218
|
-
const value = this.sensorsCarbonDioxyde[i];
|
|
219
|
-
this.sensorCarbonDioxydeServices[i]
|
|
220
|
-
.updateCharacteristic(Characteristic.CarbonDioxideDetected, state)
|
|
221
|
-
.updateCharacteristic(Characteristic.CarbonDioxideLevel, value)
|
|
222
|
-
.updateCharacteristic(Characteristic.CarbonDioxidePeakLevel, value);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (this.sensorAmbientLightServices) {
|
|
227
|
-
for (let i = 0; i < this.sensorsAmbientLightCount; i++) {
|
|
228
|
-
const value = this.sensorsAmbientLight[i];
|
|
229
|
-
this.sensorAmbientLightServices[i].updateCharacteristic(Characteristic.CurrentAmbientLightLevel, value);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (this.sensorMotionServices) {
|
|
234
|
-
for (let i = 0; i < this.sensorsMotionCount; i++) {
|
|
235
|
-
const state = this.sensorsMotion[i];
|
|
236
|
-
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);
|
|
237
153
|
}
|
|
238
154
|
}
|
|
239
155
|
}
|
|
@@ -311,208 +227,177 @@ class Sensors extends EventEmitter {
|
|
|
311
227
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
|
|
312
228
|
|
|
313
229
|
//temperature
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
230
|
+
let i = 0;
|
|
231
|
+
for (const sensor of this.sensors) {
|
|
232
|
+
const sensorName = sensor.name;
|
|
233
|
+
if (sensor.temperature !== undefined) {
|
|
234
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
235
|
+
this.sensorTemperatureServices = [];
|
|
320
236
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
321
237
|
const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
|
|
322
238
|
sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
323
239
|
sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
324
240
|
sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
325
241
|
.onGet(async () => {
|
|
326
|
-
const value =
|
|
327
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${
|
|
242
|
+
const value = sensor.temperature;
|
|
243
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${sensor.tempUnit}`);
|
|
328
244
|
return value;
|
|
329
245
|
});
|
|
330
246
|
this.sensorTemperatureServices.push(sensorTemperatureService);
|
|
331
247
|
}
|
|
332
|
-
}
|
|
333
248
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
this.sensorReferenceTemperatureServices = [];
|
|
339
|
-
for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
|
|
340
|
-
const sensorName = this.sensorsName[i];
|
|
249
|
+
//reference temperature
|
|
250
|
+
if (sensor.referenceTemperature !== undefined) {
|
|
251
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
252
|
+
this.sensorReferenceTemperatureServices = [];
|
|
341
253
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
342
254
|
const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
|
|
343
255
|
sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
344
256
|
sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
345
257
|
sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
346
258
|
.onGet(async () => {
|
|
347
|
-
const value =
|
|
348
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${
|
|
259
|
+
const value = sensor.referenceTemperature;
|
|
260
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${sensor.tempUnit}`);
|
|
349
261
|
return value;
|
|
350
262
|
});
|
|
351
263
|
this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
|
|
352
264
|
}
|
|
353
|
-
}
|
|
354
265
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
this.sensorObjTemperatureServices = [];
|
|
360
|
-
for (let i = 0; i < sensorsObjTemperatureCount; i++) {
|
|
361
|
-
const sensorName = this.sensorsName[i];
|
|
266
|
+
//object temperature
|
|
267
|
+
if (sensor.objTemperature !== undefined) {
|
|
268
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
269
|
+
this.sensorObjTemperatureServices = [];
|
|
362
270
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
363
271
|
const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
|
|
364
272
|
sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
365
273
|
sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
366
274
|
sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
367
275
|
.onGet(async () => {
|
|
368
|
-
const value =
|
|
369
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${
|
|
276
|
+
const value = sensor.objTemperature;
|
|
277
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${sensor.tempUnit}`);
|
|
370
278
|
return value;
|
|
371
279
|
});
|
|
372
280
|
this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
|
|
373
281
|
}
|
|
374
|
-
}
|
|
375
282
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
this.sensorAmbTemperatureServices = [];
|
|
381
|
-
for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
|
|
382
|
-
const sensorName = this.sensorsName[i];
|
|
283
|
+
//ambient temperature
|
|
284
|
+
if (sensor.ambTemperature !== undefined) {
|
|
285
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
286
|
+
this.sensorAmbTemperatureServices = [];
|
|
383
287
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
384
288
|
const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
|
|
385
289
|
sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
386
290
|
sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
387
291
|
sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
388
292
|
.onGet(async () => {
|
|
389
|
-
const value =
|
|
390
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${
|
|
293
|
+
const value = sensor.ambTemperature;
|
|
294
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${sensor.tempUnit}`);
|
|
391
295
|
return value;
|
|
392
296
|
});
|
|
393
297
|
this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
|
|
394
298
|
}
|
|
395
|
-
}
|
|
396
299
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
this.sensorDewPointTemperatureServices = [];
|
|
402
|
-
for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
|
|
403
|
-
const sensorName = this.sensorsName[i];
|
|
300
|
+
//dew point temperature
|
|
301
|
+
if (sensor.dewPointTemperature !== undefined) {
|
|
302
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
303
|
+
this.sensorDewPointTemperatureServices = [];
|
|
404
304
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
405
305
|
const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
|
|
406
306
|
sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
407
307
|
sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
408
308
|
sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
409
309
|
.onGet(async () => {
|
|
410
|
-
const value =
|
|
411
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${
|
|
310
|
+
const value = sensor.dewPointTemperature;
|
|
311
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${sensor.tempUnit}`);
|
|
412
312
|
return value;
|
|
413
313
|
});
|
|
414
314
|
this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
|
|
415
315
|
}
|
|
416
|
-
}
|
|
417
316
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.sensorHumidityServices = [];
|
|
423
|
-
for (let i = 0; i < sensorsHumidityCount; i++) {
|
|
424
|
-
const sensorName = this.sensorsName[i];
|
|
317
|
+
//humidity
|
|
318
|
+
if (sensor.humidity !== undefined) {
|
|
319
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
320
|
+
this.sensorHumidityServices = [];
|
|
425
321
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
426
322
|
const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
|
|
427
323
|
sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
428
324
|
sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
429
325
|
sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
430
326
|
.onGet(async () => {
|
|
431
|
-
const value =
|
|
327
|
+
const value = sensor.humidity;
|
|
432
328
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
|
|
433
329
|
return value;
|
|
434
330
|
});
|
|
435
331
|
this.sensorHumidityServices.push(sensorHumidityService);
|
|
436
332
|
}
|
|
437
|
-
}
|
|
438
333
|
|
|
439
|
-
|
|
334
|
+
//pressure
|
|
440
335
|
|
|
441
|
-
|
|
336
|
+
//gas
|
|
442
337
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
this.sensorCarbonDioxydeServices = [];
|
|
448
|
-
for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
|
|
449
|
-
const sensorName = this.sensorsName[i];
|
|
338
|
+
//carbon dioxyde
|
|
339
|
+
if (sensor.carbonDioxyde !== undefined) {
|
|
340
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
341
|
+
this.sensorCarbonDioxydeServices = [];
|
|
450
342
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
451
343
|
const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
|
|
452
344
|
sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
453
345
|
sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
454
346
|
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
|
|
455
347
|
.onGet(async () => {
|
|
456
|
-
const state =
|
|
348
|
+
const state = sensor.carbonDioxyde > 1000;
|
|
457
349
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
|
|
458
350
|
return state;
|
|
459
351
|
});
|
|
460
352
|
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
|
|
461
353
|
.onGet(async () => {
|
|
462
|
-
const value =
|
|
354
|
+
const value = sensor.carbonDioxyde;
|
|
463
355
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
|
|
464
356
|
return value;
|
|
465
357
|
});
|
|
466
358
|
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
|
|
467
359
|
.onGet(async () => {
|
|
468
|
-
const value =
|
|
360
|
+
const value = sensor.carbonDioxyde;
|
|
469
361
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
|
|
470
362
|
return value;
|
|
471
363
|
});
|
|
472
364
|
this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
|
|
473
365
|
}
|
|
474
|
-
}
|
|
475
366
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
this.sensorAmbientLightServices = [];
|
|
481
|
-
for (let i = 0; i < sensorsAmbientLightCount; i++) {
|
|
482
|
-
const sensorName = this.sensorsName[i];
|
|
367
|
+
//ambient light
|
|
368
|
+
if (sensor.ambientLight !== undefined) {
|
|
369
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
370
|
+
this.sensorAmbientLightServices = [];
|
|
483
371
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
484
372
|
const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
|
|
485
373
|
sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
486
374
|
sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
487
375
|
sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
|
488
376
|
.onGet(async () => {
|
|
489
|
-
const value =
|
|
377
|
+
const value = sensor.ambientLight;
|
|
490
378
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
|
|
491
379
|
return value;
|
|
492
380
|
});
|
|
493
381
|
this.sensorAmbientLightServices.push(sensorAmbientLightService);
|
|
494
382
|
}
|
|
495
|
-
}
|
|
496
383
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
this.sensorMotionServices = [];
|
|
502
|
-
for (let i = 0; i < sensorsMotionCount; i++) {
|
|
503
|
-
const sensorName = this.sensorsName[i];
|
|
384
|
+
//motion
|
|
385
|
+
if (sensor.motion !== undefined) {
|
|
386
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
387
|
+
this.sensorMotionServices = [];
|
|
504
388
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
505
389
|
const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
|
|
506
390
|
sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
507
391
|
sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
508
392
|
sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
|
|
509
393
|
.onGet(async () => {
|
|
510
|
-
const state =
|
|
394
|
+
const state = sensor.motion;
|
|
511
395
|
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
|
|
512
396
|
return state;
|
|
513
397
|
});
|
|
514
398
|
this.sensorMotionServices.push(sensorMotionService);
|
|
515
399
|
}
|
|
400
|
+
i++;
|
|
516
401
|
}
|
|
517
402
|
}
|
|
518
403
|
|
package/src/switches.js
CHANGED
|
@@ -18,6 +18,7 @@ class Switches extends EventEmitter {
|
|
|
18
18
|
//info
|
|
19
19
|
this.info = info;
|
|
20
20
|
this.serialNumber = serialNumber;
|
|
21
|
+
this.relaysCount = info.friendlyNames.length;
|
|
21
22
|
|
|
22
23
|
//other config
|
|
23
24
|
this.relaysDisplayType = config.relaysDisplayType || 0;
|
|
@@ -65,7 +66,7 @@ class Switches extends EventEmitter {
|
|
|
65
66
|
const debug = this.enableDebugMode ? this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`) : false;
|
|
66
67
|
|
|
67
68
|
//relays
|
|
68
|
-
const relaysCount = this.
|
|
69
|
+
const relaysCount = this.relaysCount;
|
|
69
70
|
if (relaysCount > 0) {
|
|
70
71
|
this.switchesOutlets = [];
|
|
71
72
|
|
|
@@ -137,7 +138,7 @@ class Switches extends EventEmitter {
|
|
|
137
138
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
138
139
|
this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
|
|
139
140
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
140
|
-
this.emit('devInfo', `Relays: ${this.
|
|
141
|
+
this.emit('devInfo', `Relays: ${this.relaysCount}`);
|
|
141
142
|
this.emit('devInfo', `----------------------------------`);
|
|
142
143
|
return;
|
|
143
144
|
}
|