homebridge-tasmota-control 1.4.0-beta.1 → 1.4.0-beta.3
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 +9 -0
- package/README.md +2 -0
- package/config.schema.json +14 -0
- package/package.json +1 -1
- package/src/tasmotadevice.js +222 -625
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ 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.4.0] - (30.05.2025)
|
|
9
|
+
|
|
10
|
+
## Changes
|
|
11
|
+
|
|
12
|
+
- added support for Fan, solved [#24](https://github.com/grzegorz914/homebridge-tasmota-control/issues/24)
|
|
13
|
+
- config schema updated
|
|
14
|
+
- redme updated
|
|
15
|
+
- cleanup
|
|
16
|
+
|
|
8
17
|
## [1.3.0] - (13.03.2025)
|
|
9
18
|
|
|
10
19
|
## Changes
|
package/README.md
CHANGED
|
@@ -76,6 +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 - `Power ON/OFF`, `Speed`
|
|
79
80
|
|
|
80
81
|
* Supported Sensors:
|
|
81
82
|
* Temperature - `Temperature`, `Dew Point`, `Reference`, `Obj`, `Amb`
|
|
@@ -139,6 +140,7 @@ Homebridge plugin for Tasmota flashed devices.
|
|
|
139
140
|
| `relaysNamePrefix` | Here enable/disable the accessory name as a prefix for relays name. |
|
|
140
141
|
| `relaysDisplayType` | Here select characteristic display type for relays which are exposed in the HomeKit app. |
|
|
141
142
|
| `lightsNamePrefix` | Here enable/disable the accessory name as a prefix for lights name. |
|
|
143
|
+
| `fansNamePrefix` | Here enable/disable the accessory name as a prefix for fan name. |
|
|
142
144
|
| `sensorsNamePrefix` | Here enable/disable the accessory name as a prefix for sensors name. |
|
|
143
145
|
| `loadNameFromDevice` | If enabled, the accessory name will be loaded direct from device. |
|
|
144
146
|
| `refreshInterval` | Here set the data refresh time in (sec). |
|
package/config.schema.json
CHANGED
|
@@ -1248,6 +1248,13 @@
|
|
|
1248
1248
|
"description": "Here enable/disable the accessory name as a prefix for light name.",
|
|
1249
1249
|
"required": false
|
|
1250
1250
|
},
|
|
1251
|
+
"fansNamePrefix": {
|
|
1252
|
+
"title": "Name Prefix",
|
|
1253
|
+
"type": "boolean",
|
|
1254
|
+
"default": false,
|
|
1255
|
+
"description": "Here enable/disable the accessory name as a prefix for fan name.",
|
|
1256
|
+
"required": false
|
|
1257
|
+
},
|
|
1251
1258
|
"sensorsNamePrefix": {
|
|
1252
1259
|
"title": "Name Prefix",
|
|
1253
1260
|
"type": "boolean",
|
|
@@ -1455,6 +1462,13 @@
|
|
|
1455
1462
|
"devices[].lightsNamePrefix"
|
|
1456
1463
|
]
|
|
1457
1464
|
},
|
|
1465
|
+
{
|
|
1466
|
+
"key": "devices[]",
|
|
1467
|
+
"title": "Fans",
|
|
1468
|
+
"items": [
|
|
1469
|
+
"devices[].fansNamePrefix"
|
|
1470
|
+
]
|
|
1471
|
+
},
|
|
1458
1472
|
{
|
|
1459
1473
|
"key": "devices[]",
|
|
1460
1474
|
"title": "Sensors",
|
package/package.json
CHANGED
package/src/tasmotadevice.js
CHANGED
|
@@ -114,6 +114,7 @@ class TasmotaDevice extends EventEmitter {
|
|
|
114
114
|
this.relaysDisplayType = config.relaysDisplayType || 0;
|
|
115
115
|
this.relaysNamePrefix = config.relaysNamePrefix || false;
|
|
116
116
|
this.lightsNamePrefix = config.lightsNamePrefix || false;
|
|
117
|
+
this.fansNamePrefix = config.fansNamePrefix || false;
|
|
117
118
|
this.sensorsNamePrefix = config.sensorsNamePrefix || false;
|
|
118
119
|
this.enableDebugMode = config.enableDebugMode || false;
|
|
119
120
|
this.disableLogInfo = config.disableLogInfo || false;
|
|
@@ -1529,7 +1530,23 @@ class TasmotaDevice extends EventEmitter {
|
|
|
1529
1530
|
//accessory
|
|
1530
1531
|
const accessoryName = this.deviceName;
|
|
1531
1532
|
const accessoryUUID = AccessoryUUID.generate(this.serialNumber);
|
|
1532
|
-
|
|
1533
|
+
let accessoryCategory;
|
|
1534
|
+
switch (this.deviceType) {
|
|
1535
|
+
case 0:
|
|
1536
|
+
accessoryCategory = Categories.AIR_CONDITIONER;
|
|
1537
|
+
break;
|
|
1538
|
+
case 1:
|
|
1539
|
+
accessoryCategory = this.relaysDisplayType === 0 ? Categories.OUTLET : Categories.SWITCH;
|
|
1540
|
+
break;
|
|
1541
|
+
case 2:
|
|
1542
|
+
accessoryCategory = Categories.LIGHTBULB;
|
|
1543
|
+
break;
|
|
1544
|
+
case 3:
|
|
1545
|
+
accessoryCategory = Categories.FAN;
|
|
1546
|
+
break;
|
|
1547
|
+
default:
|
|
1548
|
+
accessoryCategory = Categories.OTHER;
|
|
1549
|
+
}
|
|
1533
1550
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
1534
1551
|
|
|
1535
1552
|
//Prepare information service
|
|
@@ -2098,216 +2115,6 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2098
2115
|
this.switchOutletLightServices.push(switchOutletLightService);
|
|
2099
2116
|
}
|
|
2100
2117
|
};
|
|
2101
|
-
|
|
2102
|
-
//sensors
|
|
2103
|
-
if (this.sensorsCount > 0) {
|
|
2104
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
|
|
2105
|
-
|
|
2106
|
-
//temperature
|
|
2107
|
-
const sensorsTemperatureCount = this.sensorsTemperatureCount;
|
|
2108
|
-
if (sensorsTemperatureCount > 0) {
|
|
2109
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
2110
|
-
this.sensorTemperatureServices = [];
|
|
2111
|
-
for (let i = 0; i < sensorsTemperatureCount; i++) {
|
|
2112
|
-
const sensorName = this.sensorsName[i];
|
|
2113
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
2114
|
-
const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
|
|
2115
|
-
sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2116
|
-
sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2117
|
-
sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2118
|
-
.onGet(async () => {
|
|
2119
|
-
const value = this.sensorsTemperature[i];
|
|
2120
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
|
|
2121
|
-
return value;
|
|
2122
|
-
});
|
|
2123
|
-
this.sensorTemperatureServices.push(sensorTemperatureService);
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
//reference temperature
|
|
2128
|
-
const sensorsReferenceTemperatureCount = this.sensorsReferenceTemperatureCount;
|
|
2129
|
-
if (sensorsReferenceTemperatureCount > 0) {
|
|
2130
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
2131
|
-
this.sensorReferenceTemperatureServices = [];
|
|
2132
|
-
for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
|
|
2133
|
-
const sensorName = this.sensorsName[i];
|
|
2134
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
2135
|
-
const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
|
|
2136
|
-
sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2137
|
-
sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2138
|
-
sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2139
|
-
.onGet(async () => {
|
|
2140
|
-
const value = this.sensorsReferenceTemperature[i];
|
|
2141
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
|
|
2142
|
-
return value;
|
|
2143
|
-
});
|
|
2144
|
-
this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
//object temperature
|
|
2149
|
-
const sensorsObjTemperatureCount = this.sensorsObjTemperatureCount;
|
|
2150
|
-
if (sensorsObjTemperatureCount > 0) {
|
|
2151
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
2152
|
-
this.sensorObjTemperatureServices = [];
|
|
2153
|
-
for (let i = 0; i < sensorsObjTemperatureCount; i++) {
|
|
2154
|
-
const sensorName = this.sensorsName[i];
|
|
2155
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
2156
|
-
const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
|
|
2157
|
-
sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2158
|
-
sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2159
|
-
sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2160
|
-
.onGet(async () => {
|
|
2161
|
-
const value = this.sensorsObjTemperature[i];
|
|
2162
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
|
|
2163
|
-
return value;
|
|
2164
|
-
});
|
|
2165
|
-
this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
//ambient temperature
|
|
2170
|
-
const sensorsAmbTemperatureCount = this.sensorsAmbTemperatureCount;
|
|
2171
|
-
if (sensorsAmbTemperatureCount > 0) {
|
|
2172
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
2173
|
-
this.sensorAmbTemperatureServices = [];
|
|
2174
|
-
for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
|
|
2175
|
-
const sensorName = this.sensorsName[i];
|
|
2176
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
2177
|
-
const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
|
|
2178
|
-
sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2179
|
-
sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2180
|
-
sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2181
|
-
.onGet(async () => {
|
|
2182
|
-
const value = this.sensorsAmbTemperature[i];
|
|
2183
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
|
|
2184
|
-
return value;
|
|
2185
|
-
});
|
|
2186
|
-
this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
//dew point temperature
|
|
2191
|
-
const sensorsDewPointTemperatureCount = this.sensorsDewPointTemperatureCount;
|
|
2192
|
-
if (sensorsDewPointTemperatureCount > 0) {
|
|
2193
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
2194
|
-
this.sensorDewPointTemperatureServices = [];
|
|
2195
|
-
for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
|
|
2196
|
-
const sensorName = this.sensorsName[i];
|
|
2197
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
2198
|
-
const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
|
|
2199
|
-
sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2200
|
-
sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2201
|
-
sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2202
|
-
.onGet(async () => {
|
|
2203
|
-
const value = this.sensorsDewPointTemperature[i];
|
|
2204
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
|
|
2205
|
-
return value;
|
|
2206
|
-
});
|
|
2207
|
-
this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
//humidity
|
|
2212
|
-
const sensorsHumidityCount = this.sensorsHumidityCount;
|
|
2213
|
-
if (sensorsHumidityCount > 0) {
|
|
2214
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
2215
|
-
this.sensorHumidityServices = [];
|
|
2216
|
-
for (let i = 0; i < sensorsHumidityCount; i++) {
|
|
2217
|
-
const sensorName = this.sensorsName[i];
|
|
2218
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
2219
|
-
const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
|
|
2220
|
-
sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2221
|
-
sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2222
|
-
sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
2223
|
-
.onGet(async () => {
|
|
2224
|
-
const value = this.sensorsHumidity[i];
|
|
2225
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
|
|
2226
|
-
return value;
|
|
2227
|
-
});
|
|
2228
|
-
this.sensorHumidityServices.push(sensorHumidityService);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
|
|
2232
|
-
//pressure
|
|
2233
|
-
|
|
2234
|
-
//gas
|
|
2235
|
-
|
|
2236
|
-
//carbon dioxyde
|
|
2237
|
-
const sensorsCarbonDioxydeCount = this.sensorsCarbonDioxydeCount;
|
|
2238
|
-
if (sensorsCarbonDioxydeCount > 0) {
|
|
2239
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
2240
|
-
this.sensorCarbonDioxydeServices = [];
|
|
2241
|
-
for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
|
|
2242
|
-
const sensorName = this.sensorsName[i];
|
|
2243
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
2244
|
-
const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
|
|
2245
|
-
sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2246
|
-
sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2247
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
|
|
2248
|
-
.onGet(async () => {
|
|
2249
|
-
const state = this.sensorsCarbonDioxyde[i] > 1000;
|
|
2250
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
|
|
2251
|
-
return state;
|
|
2252
|
-
});
|
|
2253
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
|
|
2254
|
-
.onGet(async () => {
|
|
2255
|
-
const value = this.sensorsCarbonDioxyde[i];
|
|
2256
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
|
|
2257
|
-
return value;
|
|
2258
|
-
});
|
|
2259
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
|
|
2260
|
-
.onGet(async () => {
|
|
2261
|
-
const value = this.sensorsCarbonDioxyde[i];
|
|
2262
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
|
|
2263
|
-
return value;
|
|
2264
|
-
});
|
|
2265
|
-
this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
//ambient light
|
|
2270
|
-
const sensorsAmbientLightCount = this.sensorsAmbientLightCount;
|
|
2271
|
-
if (sensorsAmbientLightCount > 0) {
|
|
2272
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
2273
|
-
this.sensorAmbientLightServices = [];
|
|
2274
|
-
for (let i = 0; i < sensorsAmbientLightCount; i++) {
|
|
2275
|
-
const sensorName = this.sensorsName[i];
|
|
2276
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
2277
|
-
const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
|
|
2278
|
-
sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2279
|
-
sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2280
|
-
sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
|
2281
|
-
.onGet(async () => {
|
|
2282
|
-
const value = this.sensorsAmbientLight[i];
|
|
2283
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
|
|
2284
|
-
return value;
|
|
2285
|
-
});
|
|
2286
|
-
this.sensorAmbientLightServices.push(sensorAmbientLightService);
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
//motion
|
|
2291
|
-
const sensorsMotionCount = this.sensorsMotionCount;
|
|
2292
|
-
if (sensorsMotionCount > 0) {
|
|
2293
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
2294
|
-
this.sensorMotionServices = [];
|
|
2295
|
-
for (let i = 0; i < sensorsMotionCount; i++) {
|
|
2296
|
-
const sensorName = this.sensorsName[i];
|
|
2297
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
2298
|
-
const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
|
|
2299
|
-
sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2300
|
-
sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2301
|
-
sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
|
|
2302
|
-
.onGet(async () => {
|
|
2303
|
-
const state = this.sensorsMotion[i];
|
|
2304
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
|
|
2305
|
-
return state;
|
|
2306
|
-
});
|
|
2307
|
-
this.sensorMotionServices.push(sensorMotionService);
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
2118
|
break;
|
|
2312
2119
|
case 2: //lights
|
|
2313
2120
|
if (this.lights.length > 0) {
|
|
@@ -2406,216 +2213,6 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2406
2213
|
this.switchOutletLightServices.push(switchOutletLightService);
|
|
2407
2214
|
}
|
|
2408
2215
|
}
|
|
2409
|
-
|
|
2410
|
-
//sensors
|
|
2411
|
-
if (this.sensorsCount > 0) {
|
|
2412
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
|
|
2413
|
-
|
|
2414
|
-
//temperature
|
|
2415
|
-
const sensorsTemperatureCount = this.sensorsTemperatureCount;
|
|
2416
|
-
if (sensorsTemperatureCount > 0) {
|
|
2417
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
2418
|
-
this.sensorTemperatureServices = [];
|
|
2419
|
-
for (let i = 0; i < sensorsTemperatureCount; i++) {
|
|
2420
|
-
const sensorName = this.sensorsName[i];
|
|
2421
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
2422
|
-
const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
|
|
2423
|
-
sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2424
|
-
sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2425
|
-
sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2426
|
-
.onGet(async () => {
|
|
2427
|
-
const value = this.sensorsTemperature[i];
|
|
2428
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
|
|
2429
|
-
return value;
|
|
2430
|
-
});
|
|
2431
|
-
this.sensorTemperatureServices.push(sensorTemperatureService);
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
//reference temperature
|
|
2436
|
-
const sensorsReferenceTemperatureCount = this.sensorsReferenceTemperatureCount;
|
|
2437
|
-
if (sensorsReferenceTemperatureCount > 0) {
|
|
2438
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
2439
|
-
this.sensorReferenceTemperatureServices = [];
|
|
2440
|
-
for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
|
|
2441
|
-
const sensorName = this.sensorsName[i];
|
|
2442
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
2443
|
-
const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
|
|
2444
|
-
sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2445
|
-
sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2446
|
-
sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2447
|
-
.onGet(async () => {
|
|
2448
|
-
const value = this.sensorsReferenceTemperature[i];
|
|
2449
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
|
|
2450
|
-
return value;
|
|
2451
|
-
});
|
|
2452
|
-
this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
//object temperature
|
|
2457
|
-
const sensorsObjTemperatureCount = this.sensorsObjTemperatureCount;
|
|
2458
|
-
if (sensorsObjTemperatureCount > 0) {
|
|
2459
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
2460
|
-
this.sensorObjTemperatureServices = [];
|
|
2461
|
-
for (let i = 0; i < sensorsObjTemperatureCount; i++) {
|
|
2462
|
-
const sensorName = this.sensorsName[i];
|
|
2463
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
2464
|
-
const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
|
|
2465
|
-
sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2466
|
-
sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2467
|
-
sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2468
|
-
.onGet(async () => {
|
|
2469
|
-
const value = this.sensorsObjTemperature[i];
|
|
2470
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
|
|
2471
|
-
return value;
|
|
2472
|
-
});
|
|
2473
|
-
this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
|
|
2474
|
-
}
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
//ambient temperature
|
|
2478
|
-
const sensorsAmbTemperatureCount = this.sensorsAmbTemperatureCount;
|
|
2479
|
-
if (sensorsAmbTemperatureCount > 0) {
|
|
2480
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
2481
|
-
this.sensorAmbTemperatureServices = [];
|
|
2482
|
-
for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
|
|
2483
|
-
const sensorName = this.sensorsName[i];
|
|
2484
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
2485
|
-
const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
|
|
2486
|
-
sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2487
|
-
sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2488
|
-
sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2489
|
-
.onGet(async () => {
|
|
2490
|
-
const value = this.sensorsAmbTemperature[i];
|
|
2491
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
|
|
2492
|
-
return value;
|
|
2493
|
-
});
|
|
2494
|
-
this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
//dew point temperature
|
|
2499
|
-
const sensorsDewPointTemperatureCount = this.sensorsDewPointTemperatureCount;
|
|
2500
|
-
if (sensorsDewPointTemperatureCount > 0) {
|
|
2501
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
2502
|
-
this.sensorDewPointTemperatureServices = [];
|
|
2503
|
-
for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
|
|
2504
|
-
const sensorName = this.sensorsName[i];
|
|
2505
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
2506
|
-
const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
|
|
2507
|
-
sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2508
|
-
sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2509
|
-
sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2510
|
-
.onGet(async () => {
|
|
2511
|
-
const value = this.sensorsDewPointTemperature[i];
|
|
2512
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
|
|
2513
|
-
return value;
|
|
2514
|
-
});
|
|
2515
|
-
this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
|
|
2519
|
-
//humidity
|
|
2520
|
-
const sensorsHumidityCount = this.sensorsHumidityCount;
|
|
2521
|
-
if (sensorsHumidityCount > 0) {
|
|
2522
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
2523
|
-
this.sensorHumidityServices = [];
|
|
2524
|
-
for (let i = 0; i < sensorsHumidityCount; i++) {
|
|
2525
|
-
const sensorName = this.sensorsName[i];
|
|
2526
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
2527
|
-
const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
|
|
2528
|
-
sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2529
|
-
sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2530
|
-
sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
2531
|
-
.onGet(async () => {
|
|
2532
|
-
const value = this.sensorsHumidity[i];
|
|
2533
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
|
|
2534
|
-
return value;
|
|
2535
|
-
});
|
|
2536
|
-
this.sensorHumidityServices.push(sensorHumidityService);
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
//pressure
|
|
2541
|
-
|
|
2542
|
-
//gas
|
|
2543
|
-
|
|
2544
|
-
//carbon dioxyde
|
|
2545
|
-
const sensorsCarbonDioxydeCount = this.sensorsCarbonDioxydeCount;
|
|
2546
|
-
if (sensorsCarbonDioxydeCount > 0) {
|
|
2547
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
2548
|
-
this.sensorCarbonDioxydeServices = [];
|
|
2549
|
-
for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
|
|
2550
|
-
const sensorName = this.sensorsName[i];
|
|
2551
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
2552
|
-
const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
|
|
2553
|
-
sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2554
|
-
sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2555
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
|
|
2556
|
-
.onGet(async () => {
|
|
2557
|
-
const state = this.sensorsCarbonDioxyde[i] > 1000;
|
|
2558
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
|
|
2559
|
-
return state;
|
|
2560
|
-
});
|
|
2561
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
|
|
2562
|
-
.onGet(async () => {
|
|
2563
|
-
const value = this.sensorsCarbonDioxyde[i];
|
|
2564
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
|
|
2565
|
-
return value;
|
|
2566
|
-
});
|
|
2567
|
-
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
|
|
2568
|
-
.onGet(async () => {
|
|
2569
|
-
const value = this.sensorsCarbonDioxyde[i];
|
|
2570
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
|
|
2571
|
-
return value;
|
|
2572
|
-
});
|
|
2573
|
-
this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
//ambient light
|
|
2578
|
-
const sensorsAmbientLightCount = this.sensorsAmbientLightCount;
|
|
2579
|
-
if (sensorsAmbientLightCount > 0) {
|
|
2580
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
2581
|
-
this.sensorAmbientLightServices = [];
|
|
2582
|
-
for (let i = 0; i < sensorsAmbientLightCount; i++) {
|
|
2583
|
-
const sensorName = this.sensorsName[i];
|
|
2584
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
2585
|
-
const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
|
|
2586
|
-
sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2587
|
-
sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2588
|
-
sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
|
2589
|
-
.onGet(async () => {
|
|
2590
|
-
const value = this.sensorsAmbientLight[i];
|
|
2591
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
|
|
2592
|
-
return value;
|
|
2593
|
-
});
|
|
2594
|
-
this.sensorAmbientLightServices.push(sensorAmbientLightService);
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
//motion
|
|
2599
|
-
const sensorsMotionCount = this.sensorsMotionCount;
|
|
2600
|
-
if (sensorsMotionCount > 0) {
|
|
2601
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
2602
|
-
this.sensorMotionServices = [];
|
|
2603
|
-
for (let i = 0; i < sensorsMotionCount; i++) {
|
|
2604
|
-
const sensorName = this.sensorsName[i];
|
|
2605
|
-
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
2606
|
-
const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
|
|
2607
|
-
sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2608
|
-
sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2609
|
-
sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
|
|
2610
|
-
.onGet(async () => {
|
|
2611
|
-
const state = this.sensorsMotion[i];
|
|
2612
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
|
|
2613
|
-
return state;
|
|
2614
|
-
});
|
|
2615
|
-
this.sensorMotionServices.push(sensorMotionService);
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
2216
|
break;
|
|
2620
2217
|
case 3: //fans
|
|
2621
2218
|
if (this.fans.length > 0) {
|
|
@@ -2624,7 +2221,7 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2624
2221
|
|
|
2625
2222
|
for (let i = 0; i < this.fans.length; i++) {
|
|
2626
2223
|
const friendlyName = this.fans[i].friendlyName;
|
|
2627
|
-
const serviceName = this.
|
|
2224
|
+
const serviceName = this.fansNamePrefix ? `${accessoryName} ${friendlyName}` : friendlyName;
|
|
2628
2225
|
const fanService = accessory.addService(Service.Fanv, serviceName, `Fan ${i}`)
|
|
2629
2226
|
fanService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2630
2227
|
fanService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
@@ -2655,7 +2252,7 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2655
2252
|
// try {
|
|
2656
2253
|
// const direction = `${ApiCommands.FanDirection}${value}`;
|
|
2657
2254
|
// await this.axiosInstance(direction);
|
|
2658
|
-
// const logInfo = this.disableLogInfo ? false : this.emit('info', `${friendlyName}, set direction: ${value}
|
|
2255
|
+
// const logInfo = this.disableLogInfo ? false : this.emit('info', `${friendlyName}, set direction: ${value}`);
|
|
2659
2256
|
// } catch (error) {
|
|
2660
2257
|
// this.emit('warn', `${friendlyName}, set direction error: ${error}`);
|
|
2661
2258
|
// }
|
|
@@ -2674,7 +2271,7 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2674
2271
|
try {
|
|
2675
2272
|
const speed = `${ApiCommands.RotationSpeed}${value}`;
|
|
2676
2273
|
await this.axiosInstance(speed);
|
|
2677
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `${friendlyName}, set speed: ${value}
|
|
2274
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `${friendlyName}, set speed: ${value}`);
|
|
2678
2275
|
} catch (error) {
|
|
2679
2276
|
this.emit('warn', `${friendlyName}, set rotation speed error: ${error}`);
|
|
2680
2277
|
}
|
|
@@ -2682,217 +2279,217 @@ class TasmotaDevice extends EventEmitter {
|
|
|
2682
2279
|
this.fanServices.push(fanService);
|
|
2683
2280
|
}
|
|
2684
2281
|
}
|
|
2282
|
+
break;
|
|
2283
|
+
}
|
|
2685
2284
|
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2285
|
+
//sensors
|
|
2286
|
+
if (this.deviceType > 0 && this.sensorsCount > 0) {
|
|
2287
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Sensor Services`) : false;
|
|
2288
|
+
|
|
2289
|
+
//temperature
|
|
2290
|
+
const sensorsTemperatureCount = this.sensorsTemperatureCount;
|
|
2291
|
+
if (sensorsTemperatureCount > 0) {
|
|
2292
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
2293
|
+
this.sensorTemperatureServices = [];
|
|
2294
|
+
for (let i = 0; i < sensorsTemperatureCount; i++) {
|
|
2295
|
+
const sensorName = this.sensorsName[i];
|
|
2296
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
2297
|
+
const sensorTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Temperature Sensor ${i}`);
|
|
2298
|
+
sensorTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2299
|
+
sensorTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2300
|
+
sensorTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2301
|
+
.onGet(async () => {
|
|
2302
|
+
const value = this.sensorsTemperature[i];
|
|
2303
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} temperature: ${value} °${this.tempUnit}`);
|
|
2304
|
+
return value;
|
|
2305
|
+
});
|
|
2306
|
+
this.sensorTemperatureServices.push(sensorTemperatureService);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2710
2309
|
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2310
|
+
//reference temperature
|
|
2311
|
+
const sensorsReferenceTemperatureCount = this.sensorsReferenceTemperatureCount;
|
|
2312
|
+
if (sensorsReferenceTemperatureCount > 0) {
|
|
2313
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
2314
|
+
this.sensorReferenceTemperatureServices = [];
|
|
2315
|
+
for (let i = 0; i < sensorsReferenceTemperatureCount; i++) {
|
|
2316
|
+
const sensorName = this.sensorsName[i];
|
|
2317
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
2318
|
+
const sensorReferenceTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Reference Temperature Sensor ${i}`);
|
|
2319
|
+
sensorReferenceTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2320
|
+
sensorReferenceTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2321
|
+
sensorReferenceTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2322
|
+
.onGet(async () => {
|
|
2323
|
+
const value = this.sensorsReferenceTemperature[i];
|
|
2324
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reference temperature: ${value} °${this.tempUnit}`);
|
|
2325
|
+
return value;
|
|
2326
|
+
});
|
|
2327
|
+
this.sensorReferenceTemperatureServices.push(sensorReferenceTemperatureService);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2731
2330
|
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2331
|
+
//object temperature
|
|
2332
|
+
const sensorsObjTemperatureCount = this.sensorsObjTemperatureCount;
|
|
2333
|
+
if (sensorsObjTemperatureCount > 0) {
|
|
2334
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
2335
|
+
this.sensorObjTemperatureServices = [];
|
|
2336
|
+
for (let i = 0; i < sensorsObjTemperatureCount; i++) {
|
|
2337
|
+
const sensorName = this.sensorsName[i];
|
|
2338
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
2339
|
+
const sensorObjTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Obj Temperature Sensor ${i}`);
|
|
2340
|
+
sensorObjTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2341
|
+
sensorObjTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2342
|
+
sensorObjTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2343
|
+
.onGet(async () => {
|
|
2344
|
+
const value = this.sensorsObjTemperature[i];
|
|
2345
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} obj temperature: ${value} °${this.tempUnit}`);
|
|
2346
|
+
return value;
|
|
2347
|
+
});
|
|
2348
|
+
this.sensorObjTemperatureServices.push(sensorObjTemperatureService);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2752
2351
|
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2352
|
+
//ambient temperature
|
|
2353
|
+
const sensorsAmbTemperatureCount = this.sensorsAmbTemperatureCount;
|
|
2354
|
+
if (sensorsAmbTemperatureCount > 0) {
|
|
2355
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
2356
|
+
this.sensorAmbTemperatureServices = [];
|
|
2357
|
+
for (let i = 0; i < sensorsAmbTemperatureCount; i++) {
|
|
2358
|
+
const sensorName = this.sensorsName[i];
|
|
2359
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
2360
|
+
const sensorAmbTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Amb Temperature Sensor ${i}`);
|
|
2361
|
+
sensorAmbTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2362
|
+
sensorAmbTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2363
|
+
sensorAmbTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2364
|
+
.onGet(async () => {
|
|
2365
|
+
const value = this.sensorsAmbTemperature[i];
|
|
2366
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} amb temperature: ${value} °${this.tempUnit}`);
|
|
2367
|
+
return value;
|
|
2368
|
+
});
|
|
2369
|
+
this.sensorAmbTemperatureServices.push(sensorAmbTemperatureService);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2773
2372
|
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2373
|
+
//dew point temperature
|
|
2374
|
+
const sensorsDewPointTemperatureCount = this.sensorsDewPointTemperatureCount;
|
|
2375
|
+
if (sensorsDewPointTemperatureCount > 0) {
|
|
2376
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
2377
|
+
this.sensorDewPointTemperatureServices = [];
|
|
2378
|
+
for (let i = 0; i < sensorsDewPointTemperatureCount; i++) {
|
|
2379
|
+
const sensorName = this.sensorsName[i];
|
|
2380
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
2381
|
+
const sensorDewPointTemperatureService = accessory.addService(Service.TemperatureSensor, serviceName, `Dew Point Temperature Sensor ${i}`);
|
|
2382
|
+
sensorDewPointTemperatureService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2383
|
+
sensorDewPointTemperatureService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2384
|
+
sensorDewPointTemperatureService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
2385
|
+
.onGet(async () => {
|
|
2386
|
+
const value = this.sensorsDewPointTemperature[i];
|
|
2387
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} dew point: ${value} °${this.tempUnit}`);
|
|
2388
|
+
return value;
|
|
2389
|
+
});
|
|
2390
|
+
this.sensorDewPointTemperatureServices.push(sensorDewPointTemperatureService);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2794
2393
|
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2394
|
+
//humidity
|
|
2395
|
+
const sensorsHumidityCount = this.sensorsHumidityCount;
|
|
2396
|
+
if (sensorsHumidityCount > 0) {
|
|
2397
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
2398
|
+
this.sensorHumidityServices = [];
|
|
2399
|
+
for (let i = 0; i < sensorsHumidityCount; i++) {
|
|
2400
|
+
const sensorName = this.sensorsName[i];
|
|
2401
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
2402
|
+
const sensorHumidityService = accessory.addService(Service.HumiditySensor, serviceName, `Humidity Sensor ${i}`);
|
|
2403
|
+
sensorHumidityService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2404
|
+
sensorHumidityService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2405
|
+
sensorHumidityService.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
2406
|
+
.onGet(async () => {
|
|
2407
|
+
const value = this.sensorsHumidity[i];
|
|
2408
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} humidity: ${value} %`);
|
|
2409
|
+
return value;
|
|
2410
|
+
});
|
|
2411
|
+
this.sensorHumidityServices.push(sensorHumidityService);
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2815
2414
|
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2415
|
+
//pressure
|
|
2416
|
+
|
|
2417
|
+
//gas
|
|
2418
|
+
|
|
2419
|
+
//carbon dioxyde
|
|
2420
|
+
const sensorsCarbonDioxydeCount = this.sensorsCarbonDioxydeCount;
|
|
2421
|
+
if (sensorsCarbonDioxydeCount > 0) {
|
|
2422
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
2423
|
+
this.sensorCarbonDioxydeServices = [];
|
|
2424
|
+
for (let i = 0; i < sensorsCarbonDioxydeCount; i++) {
|
|
2425
|
+
const sensorName = this.sensorsName[i];
|
|
2426
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
2427
|
+
const sensorCarbonDioxydeService = accessory.addService(Service.CarbonDioxideSensor, serviceName, `Carbon Dioxyde Sensor ${i}`);
|
|
2428
|
+
sensorCarbonDioxydeService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2429
|
+
sensorCarbonDioxydeService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2430
|
+
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideDetected)
|
|
2431
|
+
.onGet(async () => {
|
|
2432
|
+
const state = this.sensorsCarbonDioxyde[i] > 1000;
|
|
2433
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde detected: ${state ? 'Yes' : 'No'}`);
|
|
2434
|
+
return state;
|
|
2435
|
+
});
|
|
2436
|
+
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxideLevel)
|
|
2437
|
+
.onGet(async () => {
|
|
2438
|
+
const value = this.sensorsCarbonDioxyde[i];
|
|
2439
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde level: ${value} ppm`);
|
|
2440
|
+
return value;
|
|
2441
|
+
});
|
|
2442
|
+
sensorCarbonDioxydeService.getCharacteristic(Characteristic.CarbonDioxidePeakLevel)
|
|
2443
|
+
.onGet(async () => {
|
|
2444
|
+
const value = this.sensorsCarbonDioxyde[i];
|
|
2445
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} carbon dioxyde peak level: ${value} ppm`);
|
|
2446
|
+
return value;
|
|
2447
|
+
});
|
|
2448
|
+
this.sensorCarbonDioxydeServices.push(sensorCarbonDioxydeService);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2852
2451
|
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2452
|
+
//ambient light
|
|
2453
|
+
const sensorsAmbientLightCount = this.sensorsAmbientLightCount;
|
|
2454
|
+
if (sensorsAmbientLightCount > 0) {
|
|
2455
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
2456
|
+
this.sensorAmbientLightServices = [];
|
|
2457
|
+
for (let i = 0; i < sensorsAmbientLightCount; i++) {
|
|
2458
|
+
const sensorName = this.sensorsName[i];
|
|
2459
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
2460
|
+
const sensorAmbientLightService = accessory.addService(Service.LightSensor, serviceName, `Ambient Light Sensor ${i}`);
|
|
2461
|
+
sensorAmbientLightService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2462
|
+
sensorAmbientLightService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2463
|
+
sensorAmbientLightService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
|
2464
|
+
.onGet(async () => {
|
|
2465
|
+
const value = this.sensorsAmbientLight[i];
|
|
2466
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} ambient light: ${value} lx`);
|
|
2467
|
+
return value;
|
|
2468
|
+
});
|
|
2469
|
+
this.sensorAmbientLightServices.push(sensorAmbientLightService);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2873
2472
|
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2473
|
+
//motion
|
|
2474
|
+
const sensorsMotionCount = this.sensorsMotionCount;
|
|
2475
|
+
if (sensorsMotionCount > 0) {
|
|
2476
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
2477
|
+
this.sensorMotionServices = [];
|
|
2478
|
+
for (let i = 0; i < sensorsMotionCount; i++) {
|
|
2479
|
+
const sensorName = this.sensorsName[i];
|
|
2480
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
2481
|
+
const sensorMotionService = accessory.addService(Service.MotionSensor, serviceName, `Motion Sensor ${i}`);
|
|
2482
|
+
sensorMotionService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2483
|
+
sensorMotionService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2484
|
+
sensorMotionService.getCharacteristic(Characteristic.MotionDetected)
|
|
2485
|
+
.onGet(async () => {
|
|
2486
|
+
const state = this.sensorsMotion[i];
|
|
2487
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} motion: ${state ? 'ON' : 'OFF'}`);
|
|
2488
|
+
return state;
|
|
2489
|
+
});
|
|
2490
|
+
this.sensorMotionServices.push(sensorMotionService);
|
|
2894
2491
|
}
|
|
2895
|
-
|
|
2492
|
+
}
|
|
2896
2493
|
}
|
|
2897
2494
|
|
|
2898
2495
|
return accessory;
|