homebridge-tasmota-control 1.5.1-beta.7 → 1.6.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 +6 -0
- package/index.js +5 -3
- package/package.json +1 -1
- package/src/customcharacteristics.js +198 -0
- package/src/deviceinfo.js +1 -5
- package/src/mielhvac.js +1 -1
- package/src/sensors.js +142 -28
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.6.0] - (01.06.2025)
|
|
9
|
+
|
|
10
|
+
## Changes
|
|
11
|
+
|
|
12
|
+
- added support for Energy Sensors with custom characteristics in EVE ir Controler aopp.
|
|
13
|
+
- redme updated
|
|
14
|
+
- cleanup
|
|
15
|
+
|
|
8
16
|
## [1.5.0] - (31.05.2025)
|
|
9
17
|
|
|
10
18
|
## Changes
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import Fans from './src/fans.js';
|
|
|
8
8
|
import Sensors from './src/sensors.js';
|
|
9
9
|
import ImpulseGenerator from './src/impulsegenerator.js';
|
|
10
10
|
import { PluginName, PlatformName } from './src/constants.js';
|
|
11
|
+
import CustomCharacteristics from './src/customcharacteristics.js';
|
|
11
12
|
|
|
12
13
|
class tasmotaPlatform {
|
|
13
14
|
constructor(log, config, api) {
|
|
@@ -56,7 +57,7 @@ class tasmotaPlatform {
|
|
|
56
57
|
const disableLogSuccess = device.disableLogSuccess || false;
|
|
57
58
|
const disableLogWarn = device.disableLogWarn || false;
|
|
58
59
|
const disableLogError = device.disableLogError || false;
|
|
59
|
-
const debug = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`)
|
|
60
|
+
const debug = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`);
|
|
60
61
|
const newConfig = {
|
|
61
62
|
...device,
|
|
62
63
|
user: 'removed',
|
|
@@ -71,7 +72,7 @@ class tasmotaPlatform {
|
|
|
71
72
|
const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
72
73
|
})
|
|
73
74
|
.on('debug', (debug) => {
|
|
74
|
-
const emitLog = enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
75
|
+
const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
75
76
|
})
|
|
76
77
|
.on('warn', (warn) => {
|
|
77
78
|
const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
|
|
@@ -147,7 +148,7 @@ class tasmotaPlatform {
|
|
|
147
148
|
const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
|
|
148
149
|
})
|
|
149
150
|
.on('debug', (debug) => {
|
|
150
|
-
const emitLog = enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
151
|
+
const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
151
152
|
})
|
|
152
153
|
.on('warn', (warn) => {
|
|
153
154
|
const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
|
|
@@ -189,5 +190,6 @@ class tasmotaPlatform {
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
export default (api) => {
|
|
193
|
+
CustomCharacteristics(api);
|
|
192
194
|
api.registerPlatform(PluginName, PlatformName, tasmotaPlatform);
|
|
193
195
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export default (api) => {
|
|
2
|
+
const { Service, Characteristic, Units, Formats, Perms } = api.hap;
|
|
3
|
+
|
|
4
|
+
//Envoy production/consumption characteristics
|
|
5
|
+
class Power extends Characteristic {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Power', '00000071-000B-1000-8000-0026BB765291');
|
|
8
|
+
this.setProps({
|
|
9
|
+
format: Formats.FLOAT,
|
|
10
|
+
unit: 'W',
|
|
11
|
+
maxValue: 10000,
|
|
12
|
+
minValue: -10000,
|
|
13
|
+
minStep: 0.001,
|
|
14
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
15
|
+
});
|
|
16
|
+
this.value = this.getDefaultValue();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Characteristic.Power = Power;
|
|
20
|
+
|
|
21
|
+
class ApparentPower extends Characteristic {
|
|
22
|
+
constructor() {
|
|
23
|
+
super('Apparent power', '00000072-000B-1000-8000-0026BB765291');
|
|
24
|
+
this.setProps({
|
|
25
|
+
format: Formats.FLOAT,
|
|
26
|
+
unit: 'VA',
|
|
27
|
+
maxValue: 10000,
|
|
28
|
+
minValue: -10000,
|
|
29
|
+
minStep: 0.001,
|
|
30
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
31
|
+
});
|
|
32
|
+
this.value = this.getDefaultValue();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
Characteristic.ApparentPower = ApparentPower;
|
|
36
|
+
|
|
37
|
+
class ReactivePower extends Characteristic {
|
|
38
|
+
constructor() {
|
|
39
|
+
super('Reactive power', '00000073-000B-1000-8000-0026BB765291');
|
|
40
|
+
this.setProps({
|
|
41
|
+
format: Formats.FLOAT,
|
|
42
|
+
unit: 'VAr',
|
|
43
|
+
maxValue: 10000,
|
|
44
|
+
minValue: -10000,
|
|
45
|
+
minStep: 0.001,
|
|
46
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
47
|
+
});
|
|
48
|
+
this.value = this.getDefaultValue();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
Characteristic.ReactivePower = ReactivePower;
|
|
52
|
+
|
|
53
|
+
class EnergyToday extends Characteristic {
|
|
54
|
+
constructor() {
|
|
55
|
+
super('Energy today', '00000074-000B-1000-8000-0026BB765291');
|
|
56
|
+
this.setProps({
|
|
57
|
+
format: Formats.FLOAT,
|
|
58
|
+
unit: 'kWh',
|
|
59
|
+
maxValue: 1000,
|
|
60
|
+
minValue: -1000,
|
|
61
|
+
minStep: 0.001,
|
|
62
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
63
|
+
});
|
|
64
|
+
this.value = this.getDefaultValue();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
Characteristic.EnergyToday = EnergyToday;
|
|
68
|
+
|
|
69
|
+
class EnergyLastDay extends Characteristic {
|
|
70
|
+
constructor() {
|
|
71
|
+
super('Energy last day', '00000075-000B-1000-8000-0026BB765291');
|
|
72
|
+
this.setProps({
|
|
73
|
+
format: Formats.FLOAT,
|
|
74
|
+
unit: 'kWh',
|
|
75
|
+
maxValue: 1000,
|
|
76
|
+
minValue: -1000,
|
|
77
|
+
minStep: 0.001,
|
|
78
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
79
|
+
});
|
|
80
|
+
this.value = this.getDefaultValue();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Characteristic.EnergyLastDay = EnergyLastDay;
|
|
84
|
+
|
|
85
|
+
class EnergyLifetime extends Characteristic {
|
|
86
|
+
constructor() {
|
|
87
|
+
super('Energy lifetime', '00000076-000B-1000-8000-0026BB765291');
|
|
88
|
+
this.setProps({
|
|
89
|
+
format: Formats.FLOAT,
|
|
90
|
+
unit: 'kWh',
|
|
91
|
+
maxValue: 100000000,
|
|
92
|
+
minValue: -100000000,
|
|
93
|
+
minStep: 0.001,
|
|
94
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
95
|
+
});
|
|
96
|
+
this.value = this.getDefaultValue();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
Characteristic.EnergyLifetime = EnergyLifetime;
|
|
100
|
+
|
|
101
|
+
class Current extends Characteristic {
|
|
102
|
+
constructor() {
|
|
103
|
+
super('Current', '00000077-000B-1000-8000-0026BB765291');
|
|
104
|
+
this.setProps({
|
|
105
|
+
format: Formats.FLOAT,
|
|
106
|
+
unit: 'A',
|
|
107
|
+
maxValue: 1000,
|
|
108
|
+
minValue: -1000,
|
|
109
|
+
minStep: 0.001,
|
|
110
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
111
|
+
});
|
|
112
|
+
this.value = this.getDefaultValue();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
Characteristic.Current = Current;
|
|
116
|
+
|
|
117
|
+
class Voltage extends Characteristic {
|
|
118
|
+
constructor() {
|
|
119
|
+
super('Voltage', '00000078-000B-1000-8000-0026BB765291');
|
|
120
|
+
this.setProps({
|
|
121
|
+
format: Formats.FLOAT,
|
|
122
|
+
unit: 'V',
|
|
123
|
+
maxValue: 1000,
|
|
124
|
+
minValue: 0,
|
|
125
|
+
minStep: 0.1,
|
|
126
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
127
|
+
});
|
|
128
|
+
this.value = this.getDefaultValue();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
Characteristic.Voltage = Voltage;
|
|
132
|
+
|
|
133
|
+
class Factor extends Characteristic {
|
|
134
|
+
constructor() {
|
|
135
|
+
super('Power factor', '00000079-000B-1000-8000-0026BB765291');
|
|
136
|
+
this.setProps({
|
|
137
|
+
format: Formats.FLOAT,
|
|
138
|
+
unit: 'cos φ',
|
|
139
|
+
maxValue: 1,
|
|
140
|
+
minValue: -1,
|
|
141
|
+
minStep: 0.01,
|
|
142
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
143
|
+
});
|
|
144
|
+
this.value = this.getDefaultValue();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
Characteristic.Factor = Factor;
|
|
148
|
+
|
|
149
|
+
class Freqency extends Characteristic {
|
|
150
|
+
constructor() {
|
|
151
|
+
super('Frequency', '00000080-000B-1000-8000-0026BB765291');
|
|
152
|
+
this.setProps({
|
|
153
|
+
format: Formats.FLOAT,
|
|
154
|
+
unit: 'Hz',
|
|
155
|
+
maxValue: 100,
|
|
156
|
+
minValue: 0,
|
|
157
|
+
minStep: 0.01,
|
|
158
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
159
|
+
});
|
|
160
|
+
this.value = this.getDefaultValue();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
Characteristic.Freqency = Freqency;
|
|
164
|
+
|
|
165
|
+
class ReadingTime extends Characteristic {
|
|
166
|
+
constructor() {
|
|
167
|
+
super('Reading time', '00000081-000B-1000-8000-0026BB765291');
|
|
168
|
+
this.setProps({
|
|
169
|
+
format: Formats.STRING,
|
|
170
|
+
perms: [Perms.PAIRED_READ, Perms.NOTIFY]
|
|
171
|
+
});
|
|
172
|
+
this.value = this.getDefaultValue();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
Characteristic.ReadingTime = ReadingTime;
|
|
176
|
+
|
|
177
|
+
//power production service
|
|
178
|
+
class PowerAndEnergyService extends Service {
|
|
179
|
+
constructor(displayName, subtype) {
|
|
180
|
+
super(displayName, '00000004-000A-1000-8000-0026BB765291', subtype);
|
|
181
|
+
// Mandatory Characteristics
|
|
182
|
+
this.addCharacteristic(Characteristic.Power)
|
|
183
|
+
// Optional Characteristics
|
|
184
|
+
this.addOptionalCharacteristic(Characteristic.ApparentPower);
|
|
185
|
+
this.addOptionalCharacteristic(Characteristic.ReactivePower);
|
|
186
|
+
this.addOptionalCharacteristic(Characteristic.EnergyToday);
|
|
187
|
+
this.addOptionalCharacteristic(Characteristic.EnergyLastDay);
|
|
188
|
+
this.addOptionalCharacteristic(Characteristic.EnergyLifetime);
|
|
189
|
+
this.addOptionalCharacteristic(Characteristic.Current);
|
|
190
|
+
this.addOptionalCharacteristic(Characteristic.Voltage);
|
|
191
|
+
this.addOptionalCharacteristic(Characteristic.Factor);
|
|
192
|
+
this.addOptionalCharacteristic(Characteristic.Freqency);
|
|
193
|
+
this.addOptionalCharacteristic(Characteristic.ReadingTime);
|
|
194
|
+
this.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
Service.PowerAndEnergyService = PowerAndEnergyService;
|
|
198
|
+
};
|
package/src/deviceinfo.js
CHANGED
|
@@ -54,11 +54,6 @@ class DeviceInfo extends EventEmitter {
|
|
|
54
54
|
//status SNS
|
|
55
55
|
const statusSns = deviceInfo.StatusSNS ?? {};
|
|
56
56
|
const statusSnsKeys = Object.keys(statusSns);
|
|
57
|
-
const sensorName = Object.entries(statusSns)
|
|
58
|
-
.filter(([key]) => SensorKeys.some(type => key.includes(type)))
|
|
59
|
-
.reduce((obj, [key, value]) => {
|
|
60
|
-
return key;
|
|
61
|
-
}, {});
|
|
62
57
|
|
|
63
58
|
//status STS
|
|
64
59
|
const statusSts = deviceInfo.StatusSTS ?? {};
|
|
@@ -71,6 +66,7 @@ class DeviceInfo extends EventEmitter {
|
|
|
71
66
|
const fans = statusStsKeys.includes('FanSpeed') ? types.push(3) : false;
|
|
72
67
|
const switches = !mielhvac && !lights && !fans ? types.push(1) : false
|
|
73
68
|
const sensors = statusSnsKeys.some(key => SensorKeys.includes(key)) ? types.push(4) : false;
|
|
69
|
+
const sensorName = Object.entries(statusSns).filter(([key]) => SensorKeys.some(type => key.includes(type))).reduce((obj, [key, value]) => { return key; }, {});
|
|
74
70
|
const obj = {
|
|
75
71
|
deviceTypes: types,
|
|
76
72
|
deviceName: deviceName,
|
package/src/mielhvac.js
CHANGED
|
@@ -814,7 +814,7 @@ class MiElHvac extends EventEmitter {
|
|
|
814
814
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
815
815
|
this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
|
|
816
816
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
817
|
-
this.emit('devInfo', `
|
|
817
|
+
this.emit('devInfo', `Device: MiELHVAC`);
|
|
818
818
|
this.emit('devInfo', `----------------------------------`);
|
|
819
819
|
return;
|
|
820
820
|
}
|
package/src/sensors.js
CHANGED
|
@@ -100,10 +100,9 @@ class Sensors extends EventEmitter {
|
|
|
100
100
|
//sensor
|
|
101
101
|
const obj = {
|
|
102
102
|
name: key,
|
|
103
|
-
time:
|
|
104
|
-
tempUnit:
|
|
105
|
-
pressureUnit:
|
|
106
|
-
|
|
103
|
+
time: statusSns.Time,
|
|
104
|
+
tempUnit: statusSns.TempUnit,
|
|
105
|
+
pressureUnit: statusSns.PressureUnit,
|
|
107
106
|
temperature: sensorData.Temperature,
|
|
108
107
|
referenceTemperature: sensorData.ReferenceTemperature,
|
|
109
108
|
objTemperature: sensorData.OBJTMP,
|
|
@@ -116,26 +115,28 @@ class Sensors extends EventEmitter {
|
|
|
116
115
|
ambientLight: sensorData.Ambient,
|
|
117
116
|
motion: sensorData.Motion
|
|
118
117
|
}
|
|
119
|
-
if (obj.tempUnit) {
|
|
120
|
-
obj.tempUnit =
|
|
118
|
+
if (obj.tempUnit === 'C') {
|
|
119
|
+
obj.tempUnit = '°C';
|
|
121
120
|
}
|
|
121
|
+
|
|
122
122
|
//energy
|
|
123
123
|
const obj1 = {
|
|
124
|
-
energyTotalStartTime: sensorData.TotalStartTime,
|
|
125
|
-
energyTotal: sensorData.Total,
|
|
126
|
-
energyPeriod: sensorData.Period,
|
|
127
|
-
energyYesterday: sensorData.Yesterday,
|
|
128
|
-
energyToday: sensorData.Today,
|
|
129
124
|
power: sensorData.Power,
|
|
130
125
|
apparentPower: sensorData.ApparentPower,
|
|
131
126
|
reactivePower: sensorData.ReactivePower,
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
energyToday: sensorData.Today,
|
|
128
|
+
energyLastDay: sensorData.Yesterday,
|
|
129
|
+
energyLifetime: sensorData.Total,
|
|
130
|
+
energyLifeTimeStartTime: sensorData.TotalStartTime,
|
|
131
|
+
energyPeriod: sensorData.Period,
|
|
134
132
|
current: sensorData.Current,
|
|
133
|
+
voltage: sensorData.Voltage,
|
|
134
|
+
factor: sensorData.Factor,
|
|
135
|
+
frequency: sensorData.Frequency,
|
|
135
136
|
load: sensorData.Load,
|
|
136
137
|
}
|
|
137
138
|
const sensor = key === 'ENERGY' ? { ...obj, ...obj1 } : obj;
|
|
138
|
-
this.emit('debug', `
|
|
139
|
+
const debug1 = this.enableDebugMode ? this.emit('debug', `Sensor: ${JSON.stringify(sensor, null, 2)}`) : false;
|
|
139
140
|
|
|
140
141
|
//push to array
|
|
141
142
|
this.sensors.push(sensor);
|
|
@@ -146,18 +147,33 @@ class Sensors extends EventEmitter {
|
|
|
146
147
|
if (this.sensorsCount > 0) {
|
|
147
148
|
for (let i = 0; i < this.sensorsCount; i++) {
|
|
148
149
|
const sensor = this.sensors[i];
|
|
150
|
+
|
|
149
151
|
this.sensorTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.temperature);
|
|
150
152
|
this.sensorReferenceTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.referenceTemperature);
|
|
151
153
|
this.sensorObjTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.objTemperature);
|
|
152
154
|
this.sensorAmbTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.ambTemperature);
|
|
153
155
|
this.sensorDewPointTemperatureServices?.[i]?.updateCharacteristic(Characteristic.CurrentTemperature, sensor.dewPointTemperature);
|
|
154
156
|
this.sensorHumidityServices?.[i]?.updateCharacteristic(Characteristic.CurrentRelativeHumidity, sensor.humidity);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
|
|
158
|
+
const co2Service = this.sensorCarbonDioxydeServices?.[i];
|
|
159
|
+
co2Service?.updateCharacteristic(Characteristic.CarbonDioxideDetected, sensor.carbonDioxyde > 1000);
|
|
160
|
+
co2Service?.updateCharacteristic(Characteristic.CarbonDioxideLevel, sensor.carbonDioxyde);
|
|
161
|
+
co2Service?.updateCharacteristic(Characteristic.CarbonDioxidePeakLevel, sensor.carbonDioxyde);
|
|
162
|
+
|
|
159
163
|
this.sensorAmbientLightServices?.[i]?.updateCharacteristic(Characteristic.CurrentAmbientLightLevel, sensor.ambientLight);
|
|
160
164
|
this.sensorMotionServices?.[i]?.updateCharacteristic(Characteristic.MotionDetected, sensor.motion);
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
//energy
|
|
168
|
+
const fields = [
|
|
169
|
+
'Power', 'ApparentPower', 'ReactivePower', 'EnergyToday', 'EnergyLastDay',
|
|
170
|
+
'EnergyLifetime', 'Current', 'Voltage', 'Factor', 'Frequency', 'ReadingTime'
|
|
171
|
+
];
|
|
172
|
+
const characteristic = this.sensorEnergyServices?.[i]?.Characteristic;
|
|
173
|
+
for (const key of fields) {
|
|
174
|
+
characteristic?.[key]?.updateCharacteristic(Characteristic[key], sensor[key.toLowerCase()]);
|
|
175
|
+
}
|
|
176
|
+
|
|
161
177
|
}
|
|
162
178
|
}
|
|
163
179
|
}
|
|
@@ -205,7 +221,7 @@ class Sensors extends EventEmitter {
|
|
|
205
221
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
206
222
|
this.emit('devInfo', `Serialnr: ${this.serialNumber}`)
|
|
207
223
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
208
|
-
this.emit('devInfo', `
|
|
224
|
+
this.emit('devInfo', `Sensor: ${this.info.sensorName}`);
|
|
209
225
|
this.emit('devInfo', `----------------------------------`);
|
|
210
226
|
return;
|
|
211
227
|
}
|
|
@@ -238,7 +254,7 @@ class Sensors extends EventEmitter {
|
|
|
238
254
|
let i = 0;
|
|
239
255
|
for (const sensor of this.sensors) {
|
|
240
256
|
const sensorName = sensor.name;
|
|
241
|
-
if (sensor.temperature
|
|
257
|
+
if (sensor.temperature) {
|
|
242
258
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Temperature Sensor Services`) : false;
|
|
243
259
|
this.sensorTemperatureServices = [];
|
|
244
260
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Temperature` : `${sensorName} Temperature`;
|
|
@@ -255,7 +271,7 @@ class Sensors extends EventEmitter {
|
|
|
255
271
|
}
|
|
256
272
|
|
|
257
273
|
//reference temperature
|
|
258
|
-
if (sensor.referenceTemperature
|
|
274
|
+
if (sensor.referenceTemperature) {
|
|
259
275
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Reference Temperature Sensor Services`) : false;
|
|
260
276
|
this.sensorReferenceTemperatureServices = [];
|
|
261
277
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Reference Temperature` : `${sensorName} Reference Temperature`;
|
|
@@ -272,7 +288,7 @@ class Sensors extends EventEmitter {
|
|
|
272
288
|
}
|
|
273
289
|
|
|
274
290
|
//object temperature
|
|
275
|
-
if (sensor.objTemperature
|
|
291
|
+
if (sensor.objTemperature) {
|
|
276
292
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Obj Temperature Sensor Services`) : false;
|
|
277
293
|
this.sensorObjTemperatureServices = [];
|
|
278
294
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Obj Temperature` : `${sensorName} Obj Temperature`;
|
|
@@ -289,7 +305,7 @@ class Sensors extends EventEmitter {
|
|
|
289
305
|
}
|
|
290
306
|
|
|
291
307
|
//ambient temperature
|
|
292
|
-
if (sensor.ambTemperature
|
|
308
|
+
if (sensor.ambTemperature) {
|
|
293
309
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Amb Temperature Sensor Services`) : false;
|
|
294
310
|
this.sensorAmbTemperatureServices = [];
|
|
295
311
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Amb Temperature` : `${sensorName} Amb Temperature`;
|
|
@@ -306,7 +322,7 @@ class Sensors extends EventEmitter {
|
|
|
306
322
|
}
|
|
307
323
|
|
|
308
324
|
//dew point temperature
|
|
309
|
-
if (sensor.dewPointTemperature
|
|
325
|
+
if (sensor.dewPointTemperature) {
|
|
310
326
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Dew Point Temperature Sensor Services`) : false;
|
|
311
327
|
this.sensorDewPointTemperatureServices = [];
|
|
312
328
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Dew Point` : `${sensorName} Dew Point`;
|
|
@@ -323,7 +339,7 @@ class Sensors extends EventEmitter {
|
|
|
323
339
|
}
|
|
324
340
|
|
|
325
341
|
//humidity
|
|
326
|
-
if (sensor.humidity
|
|
342
|
+
if (sensor.humidity) {
|
|
327
343
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Humidity Sensor Services`) : false;
|
|
328
344
|
this.sensorHumidityServices = [];
|
|
329
345
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Humidity` : `${sensorName} Humidity`;
|
|
@@ -344,7 +360,7 @@ class Sensors extends EventEmitter {
|
|
|
344
360
|
//gas
|
|
345
361
|
|
|
346
362
|
//carbon dioxyde
|
|
347
|
-
if (sensor.carbonDioxyde
|
|
363
|
+
if (sensor.carbonDioxyde) {
|
|
348
364
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Carbon Dioxyde Sensor Services`) : false;
|
|
349
365
|
this.sensorCarbonDioxydeServices = [];
|
|
350
366
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Carbon Dioxyde` : `${sensorName} Carbon Dioxyde`;
|
|
@@ -373,7 +389,7 @@ class Sensors extends EventEmitter {
|
|
|
373
389
|
}
|
|
374
390
|
|
|
375
391
|
//ambient light
|
|
376
|
-
if (sensor.ambientLight
|
|
392
|
+
if (sensor.ambientLight) {
|
|
377
393
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Ambient Light Sensor Services`) : false;
|
|
378
394
|
this.sensorAmbientLightServices = [];
|
|
379
395
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Ambient Light` : `${sensorName} Ambient Light`;
|
|
@@ -390,7 +406,7 @@ class Sensors extends EventEmitter {
|
|
|
390
406
|
}
|
|
391
407
|
|
|
392
408
|
//motion
|
|
393
|
-
if (sensor.motion
|
|
409
|
+
if (sensor.motion) {
|
|
394
410
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Motion Sensor Services`) : false;
|
|
395
411
|
this.sensorMotionServices = [];
|
|
396
412
|
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName} Motion` : `${sensorName} Motion`;
|
|
@@ -405,6 +421,104 @@ class Sensors extends EventEmitter {
|
|
|
405
421
|
});
|
|
406
422
|
this.sensorMotionServices.push(sensorMotionService);
|
|
407
423
|
}
|
|
424
|
+
|
|
425
|
+
//energy
|
|
426
|
+
if (sensor.name === 'ENERGY') {
|
|
427
|
+
const debug4 = this.enableDebugMode ? this.emit('debug', `Prepare Power And Energy Service`) : false;
|
|
428
|
+
this.sensorEnergyServices = [];
|
|
429
|
+
const serviceName = this.sensorsNamePrefix ? `${accessoryName} ${sensorName}` : `${sensorName} Sensor`;
|
|
430
|
+
const energyService = accessory.addService(Service.PowerAndEnergyService, serviceName, `Energy Sensor ${i}`);
|
|
431
|
+
energyService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
432
|
+
if (sensor.power) {
|
|
433
|
+
energyService.getCharacteristic(Characteristic.Power)
|
|
434
|
+
.onGet(async () => {
|
|
435
|
+
const value = sensor.power;
|
|
436
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} power: ${value} W`);
|
|
437
|
+
return value;
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (sensor.apparentPower) {
|
|
441
|
+
energyService.getCharacteristic(Characteristic.ApparentPower)
|
|
442
|
+
.onGet(async () => {
|
|
443
|
+
const value = sensor.apparentPower;
|
|
444
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} apparent power: ${value} VA`);
|
|
445
|
+
return value;
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
if (sensor.reactivePower) {
|
|
449
|
+
energyService.getCharacteristic(Characteristic.ReactivePower)
|
|
450
|
+
.onGet(async () => {
|
|
451
|
+
const value = sensor.reactivePower;
|
|
452
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} reactive power: ${value} VAr`);
|
|
453
|
+
return value;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (sensor.energyToday) {
|
|
457
|
+
energyService.getCharacteristic(Characteristic.EnergyToday)
|
|
458
|
+
.onGet(async () => {
|
|
459
|
+
const value = sensor.energyToday;
|
|
460
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy today: ${value} kWh`);
|
|
461
|
+
return value;
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
if (sensor.energyLastDay) {
|
|
465
|
+
energyService.getCharacteristic(Characteristic.EnergyLastDay)
|
|
466
|
+
.onGet(async () => {
|
|
467
|
+
const value = sensor.energyLastDay;
|
|
468
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy last day: ${value} kWh`);
|
|
469
|
+
return value;
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (sensor.energyLifetime) {
|
|
473
|
+
energyService.getCharacteristic(Characteristic.EnergyLifetime)
|
|
474
|
+
.onGet(async () => {
|
|
475
|
+
const value = sensor.energyLifetime;
|
|
476
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} energy lifetime: ${value} kWh`);
|
|
477
|
+
return value;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
if (sensor.current) {
|
|
481
|
+
energyService.getCharacteristic(Characteristic.Current)
|
|
482
|
+
.onGet(async () => {
|
|
483
|
+
const value = sensor.current;
|
|
484
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} current: ${value} A`);
|
|
485
|
+
return value;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
if (sensor.voltage) {
|
|
489
|
+
energyService.getCharacteristic(Characteristic.Voltage)
|
|
490
|
+
.onGet(async () => {
|
|
491
|
+
const value = sensor.voltage;
|
|
492
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} voltage: ${value} V`);
|
|
493
|
+
return value;
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
if (sensor.factor) {
|
|
497
|
+
energyService.getCharacteristic(Characteristic.Factor)
|
|
498
|
+
.onGet(async () => {
|
|
499
|
+
const value = sensor.factor;
|
|
500
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} power factor: ${value} cos φ`);
|
|
501
|
+
return value;
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
if (sensor.frequency) {
|
|
505
|
+
energyService.getCharacteristic(Characteristic.Freqency)
|
|
506
|
+
.onGet(async () => {
|
|
507
|
+
const value = sensor.frequency;
|
|
508
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} frequency: ${value} Hz`);
|
|
509
|
+
return value;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
if (sensor.time) {
|
|
513
|
+
energyService.getCharacteristic(Characteristic.ReadingTime)
|
|
514
|
+
.onGet(async () => {
|
|
515
|
+
const value = sensor.time;
|
|
516
|
+
const info = this.disableLogInfo ? false : this.emit('info', `sensor: ${sensorName} last report: ${value}`);
|
|
517
|
+
return value;
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
this.sensorEnergyServices.push(energyService);
|
|
521
|
+
}
|
|
408
522
|
i++;
|
|
409
523
|
}
|
|
410
524
|
}
|