matterbridge-example-dynamic-platform 1.1.6 → 1.1.7-dev.1
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/dist/platform.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airConditioner, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, } from 'matterbridge';
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airConditioner, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, genericSwitch, } from 'matterbridge';
|
2
2
|
import { isValidBoolean, isValidNumber } from 'matterbridge/utils';
|
3
3
|
import { LocationTag } from 'matterbridge/matter';
|
4
|
-
import {
|
4
|
+
import { PowerSource, BooleanState, OnOff, LevelControl, AirQuality, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, FlowMeasurement, ColorControl, DoorLock, FanControl, FormaldehydeConcentrationMeasurement, NitrogenDioxideConcentrationMeasurement, OzoneConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, TemperatureMeasurement, Thermostat, ThermostatCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, } from 'matterbridge/matter/clusters';
|
5
5
|
export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
|
6
6
|
switch;
|
7
7
|
lightOnOff;
|
@@ -26,6 +26,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
26
26
|
airPurifier;
|
27
27
|
pump;
|
28
28
|
valve;
|
29
|
+
momentarySwitch;
|
30
|
+
latchingSwitch;
|
29
31
|
switchInterval;
|
30
32
|
lightInterval;
|
31
33
|
outletInterval;
|
@@ -39,275 +41,269 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
39
41
|
smokeInterval;
|
40
42
|
airQualityInterval;
|
41
43
|
airConditionerInterval;
|
44
|
+
genericSwitchInterval;
|
45
|
+
genericSwitchLastEvent = 'Release';
|
42
46
|
bridgedDevices = new Map();
|
43
47
|
fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
|
44
48
|
constructor(matterbridge, log, config) {
|
45
49
|
super(matterbridge, log, config);
|
46
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('2.1.
|
47
|
-
throw new Error(`This plugin requires Matterbridge version >= "2.1.
|
50
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('2.1.5')) {
|
51
|
+
throw new Error(`This plugin requires Matterbridge version >= "2.1.5". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
|
48
52
|
}
|
49
53
|
this.log.info('Initializing platform:', this.config.name);
|
50
54
|
}
|
51
55
|
async onStart(reason) {
|
52
56
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
53
|
-
this.switch = new MatterbridgeEndpoint([onOffSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Switch' }, this.config.debug);
|
54
|
-
this.switch
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
this.switch.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
57
|
+
this.switch = new MatterbridgeEndpoint([onOffSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Switch' }, this.config.debug).createDefaultIdentifyClusterServer();
|
58
|
+
this.switch
|
59
|
+
.createDefaultGroupsClusterServer()
|
60
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Switch', '0x23452164', 0xfff1, 'Matterbridge', 'Matterbridge Switch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
61
|
+
.createDefaultOnOffClusterServer()
|
62
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
60
63
|
await this.registerDevice(this.switch);
|
61
64
|
this.bridgedDevices.set(this.switch.deviceName ?? '', this.switch);
|
62
65
|
this.switch.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
63
66
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
64
67
|
});
|
65
68
|
this.switch.addCommandHandler('on', async () => {
|
66
|
-
await this.switch?.setAttribute(
|
69
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.switch.log);
|
67
70
|
this.switch?.log.info('Command on called');
|
68
71
|
});
|
69
72
|
this.switch.addCommandHandler('off', async () => {
|
70
|
-
await this.switch?.setAttribute(
|
73
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.switch.log);
|
71
74
|
this.switch?.log.info('Command off called');
|
72
75
|
});
|
73
|
-
this.lightOnOff = new MatterbridgeEndpoint([onOffLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
this.lightOnOff.createDefaultPowerSourceWiredClusterServer();
|
76
|
+
this.lightOnOff = new MatterbridgeEndpoint([onOffLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug)
|
77
|
+
.createDefaultIdentifyClusterServer()
|
78
|
+
.createDefaultGroupsClusterServer()
|
79
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (on/off)', '0x2342375564', 0xfff1, 'Matterbridge', 'Matterbridge Light on/off', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
80
|
+
.createDefaultOnOffClusterServer()
|
81
|
+
.createDefaultPowerSourceWiredClusterServer();
|
80
82
|
await this.registerDevice(this.lightOnOff);
|
81
83
|
this.bridgedDevices.set(this.lightOnOff.deviceName ?? '', this.lightOnOff);
|
82
84
|
this.lightOnOff.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
83
85
|
this.lightOnOff?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
84
86
|
});
|
85
87
|
this.lightOnOff.addCommandHandler('on', async () => {
|
86
|
-
await this.lightOnOff?.setAttribute(
|
88
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightOnOff?.log);
|
87
89
|
this.lightOnOff?.log.info('Command on called');
|
88
90
|
});
|
89
91
|
this.lightOnOff.addCommandHandler('off', async () => {
|
90
|
-
await this.lightOnOff?.setAttribute(
|
92
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff?.log);
|
91
93
|
this.lightOnOff?.log.info('Command off called');
|
92
94
|
});
|
93
|
-
this.dimmer = new MatterbridgeEndpoint([dimmableLight, bridgedNode, powerSource], { uniqueStorageKey: 'Dimmer' }, this.config.debug);
|
94
|
-
this.dimmer
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
this.dimmer.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
95
|
+
this.dimmer = new MatterbridgeEndpoint([dimmableLight, bridgedNode, powerSource], { uniqueStorageKey: 'Dimmer' }, this.config.debug).createDefaultIdentifyClusterServer();
|
96
|
+
this.dimmer
|
97
|
+
.createDefaultGroupsClusterServer()
|
98
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer', '0x234554564', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
99
|
+
.createDefaultOnOffClusterServer()
|
100
|
+
.createDefaultLevelControlClusterServer()
|
101
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
101
102
|
await this.registerDevice(this.dimmer);
|
102
103
|
this.bridgedDevices.set(this.dimmer.deviceName ?? '', this.dimmer);
|
103
104
|
this.dimmer.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
104
105
|
this.dimmer?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
105
106
|
});
|
106
107
|
this.dimmer.addCommandHandler('on', async () => {
|
107
|
-
await this.dimmer?.setAttribute(
|
108
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.dimmer.log);
|
108
109
|
this.dimmer?.log.info('Command on called');
|
109
110
|
});
|
110
111
|
this.dimmer.addCommandHandler('off', async () => {
|
111
|
-
await this.dimmer?.setAttribute(
|
112
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
112
113
|
this.dimmer?.log.info('Command off called');
|
113
114
|
});
|
114
115
|
this.dimmer.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
115
|
-
await this.dimmer?.setAttribute(
|
116
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
116
117
|
this.dimmer?.log.debug(`Command moveToLevel called request: ${level}`);
|
117
118
|
});
|
118
119
|
this.dimmer.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
119
|
-
await this.dimmer?.setAttribute(
|
120
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
120
121
|
this.dimmer?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
121
122
|
});
|
122
|
-
this.light = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug);
|
123
|
-
this.light
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
this.light.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
123
|
+
this.light = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
124
|
+
this.light
|
125
|
+
.createDefaultGroupsClusterServer()
|
126
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (XY, HS and CT)', '0x23480564', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
127
|
+
.createDefaultOnOffClusterServer()
|
128
|
+
.createDefaultLevelControlClusterServer()
|
129
|
+
.createDefaultColorControlClusterServer()
|
130
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
131
131
|
await this.registerDevice(this.light);
|
132
132
|
this.bridgedDevices.set(this.light.deviceName ?? '', this.light);
|
133
133
|
this.light.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
134
134
|
this.light?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
135
135
|
});
|
136
136
|
this.light.addCommandHandler('on', async () => {
|
137
|
-
await this.light?.setAttribute(
|
137
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.light?.log);
|
138
138
|
this.light?.log.info('Command on called');
|
139
139
|
});
|
140
140
|
this.light.addCommandHandler('off', async () => {
|
141
|
-
await this.light?.setAttribute(
|
141
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light?.log);
|
142
142
|
this.light?.log.info('Command off called');
|
143
143
|
});
|
144
144
|
this.light.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
145
|
-
await this.light?.setAttribute(
|
145
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light?.log);
|
146
146
|
this.light?.log.debug(`Command moveToLevel called request: ${level}`);
|
147
147
|
});
|
148
148
|
this.light.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
149
|
-
await this.light?.setAttribute(
|
149
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light?.log);
|
150
150
|
this.light?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
151
151
|
});
|
152
152
|
this.light.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
153
|
-
await this.light?.setAttribute(
|
154
|
-
await this.light?.setAttribute(
|
153
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentX', colorX, this.light?.log);
|
154
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentY', colorY, this.light?.log);
|
155
155
|
this.light?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
156
156
|
});
|
157
157
|
this.light.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation } }) => {
|
158
|
-
await this.light?.setAttribute(
|
159
|
-
await this.light?.setAttribute(
|
158
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.light?.log);
|
159
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.light?.log);
|
160
160
|
this.light?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}`);
|
161
161
|
});
|
162
162
|
this.light.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
163
|
-
await this.light?.setAttribute(
|
163
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.light?.log);
|
164
164
|
this.light?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
165
165
|
});
|
166
166
|
this.light.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
167
|
-
await this.light?.setAttribute(
|
167
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.light?.log);
|
168
168
|
this.light?.log.debug(`Command moveToSaturation called request: saturation ${saturation}}`);
|
169
169
|
});
|
170
170
|
this.light.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
171
|
-
await this.light?.setAttribute(
|
171
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.light?.log);
|
172
172
|
this.light?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
173
173
|
});
|
174
|
-
this.lightHS = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (HS, CT)' }, this.config.debug);
|
175
|
-
this.lightHS
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
this.lightHS.createDefaultPowerSourceWiredClusterServer();
|
174
|
+
this.lightHS = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (HS, CT)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
175
|
+
this.lightHS
|
176
|
+
.createDefaultGroupsClusterServer()
|
177
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (HS, CT)', '0x25097564', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
178
|
+
.createDefaultOnOffClusterServer()
|
179
|
+
.createDefaultLevelControlClusterServer()
|
180
|
+
.createHsColorControlClusterServer()
|
181
|
+
.createDefaultPowerSourceWiredClusterServer();
|
183
182
|
await this.registerDevice(this.lightHS);
|
184
183
|
this.bridgedDevices.set(this.lightHS.deviceName ?? '', this.lightHS);
|
185
184
|
this.lightHS.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
186
185
|
this.lightHS?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
187
186
|
});
|
188
187
|
this.lightHS.addCommandHandler('on', async () => {
|
189
|
-
await this.lightHS?.setAttribute(
|
188
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightHS?.log);
|
190
189
|
this.lightHS?.log.info('Command on called');
|
191
190
|
});
|
192
191
|
this.lightHS.addCommandHandler('off', async () => {
|
193
|
-
await this.lightHS?.setAttribute(
|
192
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightHS?.log);
|
194
193
|
this.lightHS?.log.info('Command off called');
|
195
194
|
});
|
196
195
|
this.lightHS.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
197
|
-
await this.lightHS?.setAttribute(
|
196
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS?.log);
|
198
197
|
this.lightHS?.log.debug(`Command moveToLevel called request: ${level}`);
|
199
198
|
});
|
200
199
|
this.lightHS.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
201
|
-
await this.lightHS?.setAttribute(
|
200
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS?.log);
|
202
201
|
this.lightHS?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
203
202
|
});
|
204
203
|
this.lightHS.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation } }) => {
|
205
|
-
await this.lightHS?.setAttribute(
|
206
|
-
await this.lightHS?.setAttribute(
|
204
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.lightHS?.log);
|
205
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.lightHS?.log);
|
207
206
|
this.lightHS?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}}`);
|
208
207
|
});
|
209
208
|
this.lightHS.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
210
|
-
await this.lightHS?.setAttribute(
|
209
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.lightHS?.log);
|
211
210
|
this.lightHS?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
212
211
|
});
|
213
212
|
this.lightHS.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
214
|
-
await this.lightHS?.setAttribute(
|
213
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.lightHS?.log);
|
215
214
|
this.lightHS?.log.debug(`Command moveToSaturation called request: saturation ${saturation}`);
|
216
215
|
});
|
217
216
|
this.lightHS.addCommandHandler('moveToColorTemperature', async ({ request: colorTemperatureMireds }) => {
|
218
217
|
this.lightHS?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
219
218
|
});
|
220
|
-
this.lightXY = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug);
|
221
|
-
this.lightXY
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
this.lightXY.createDefaultPowerSourceWiredClusterServer();
|
219
|
+
this.lightXY = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
220
|
+
this.lightXY
|
221
|
+
.createDefaultGroupsClusterServer()
|
222
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (XY, CT)', '0x23497564', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
223
|
+
.createDefaultOnOffClusterServer()
|
224
|
+
.createDefaultLevelControlClusterServer()
|
225
|
+
.createXyColorControlClusterServer()
|
226
|
+
.createDefaultPowerSourceWiredClusterServer();
|
229
227
|
await this.registerDevice(this.lightXY);
|
230
228
|
this.bridgedDevices.set(this.lightXY.deviceName ?? '', this.lightXY);
|
231
229
|
this.lightXY.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
232
230
|
this.lightXY?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
233
231
|
});
|
234
232
|
this.lightXY.addCommandHandler('on', async () => {
|
235
|
-
await this.lightXY?.setAttribute(
|
233
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightXY?.log);
|
236
234
|
this.lightXY?.log.info('Command on called');
|
237
235
|
});
|
238
236
|
this.lightXY.addCommandHandler('off', async () => {
|
239
|
-
await this.lightXY?.setAttribute(
|
237
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightXY?.log);
|
240
238
|
this.lightXY?.log.info('Command off called');
|
241
239
|
});
|
242
240
|
this.lightXY.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
243
|
-
await this.lightXY?.setAttribute(
|
241
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY?.log);
|
244
242
|
this.lightXY?.log.debug(`Command moveToLevel called request: ${level}`);
|
245
243
|
});
|
246
244
|
this.lightXY.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
247
|
-
await this.lightXY?.setAttribute(
|
245
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY?.log);
|
248
246
|
this.lightXY?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
249
247
|
});
|
250
248
|
this.lightXY.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
251
|
-
await this.lightXY?.setAttribute(
|
252
|
-
await this.lightXY?.setAttribute(
|
249
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'currentX', colorX, this.lightXY?.log);
|
250
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'currentY', colorY, this.lightXY?.log);
|
253
251
|
this.lightXY?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
254
252
|
});
|
255
253
|
this.lightXY.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
256
|
-
await this.lightXY?.setAttribute(
|
254
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightXY?.log);
|
257
255
|
this.lightXY?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
258
256
|
});
|
259
|
-
this.lightCT = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (CT)' }, this.config.debug);
|
260
|
-
this.lightCT
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
this.lightCT.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
257
|
+
this.lightCT = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (CT)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
258
|
+
this.lightCT
|
259
|
+
.createDefaultGroupsClusterServer()
|
260
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (CT)', '0x23480749', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
261
|
+
.createDefaultOnOffClusterServer()
|
262
|
+
.createDefaultLevelControlClusterServer()
|
263
|
+
.createCtColorControlClusterServer()
|
264
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
268
265
|
await this.registerDevice(this.lightCT);
|
269
266
|
this.bridgedDevices.set(this.lightCT.deviceName ?? '', this.lightCT);
|
270
267
|
this.lightCT.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
271
268
|
this.lightCT?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
272
269
|
});
|
273
270
|
this.lightCT.addCommandHandler('on', async () => {
|
274
|
-
await this.lightCT?.setAttribute(
|
271
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightCT?.log);
|
275
272
|
this.lightCT?.log.info('Command on called');
|
276
273
|
});
|
277
274
|
this.lightCT.addCommandHandler('off', async () => {
|
278
|
-
await this.lightCT?.setAttribute(
|
275
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightCT?.log);
|
279
276
|
this.lightCT?.log.info('Command off called');
|
280
277
|
});
|
281
278
|
this.lightCT.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
282
|
-
await this.lightCT?.setAttribute(
|
279
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT?.log);
|
283
280
|
this.lightCT?.log.debug(`Command moveToLevel called request: ${level}`);
|
284
281
|
});
|
285
282
|
this.lightCT.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
286
|
-
await this.lightCT?.setAttribute(
|
283
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT?.log);
|
287
284
|
this.lightCT?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
288
285
|
});
|
289
286
|
this.lightCT.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
290
|
-
await this.lightCT?.setAttribute(
|
287
|
+
await this.lightCT?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightCT?.log);
|
291
288
|
this.lightCT?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
292
289
|
});
|
293
|
-
this.outlet = new MatterbridgeEndpoint([onOffOutlet, bridgedNode, powerSource], { uniqueStorageKey: 'Outlet' }, this.config.debug);
|
294
|
-
this.outlet
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
this.outlet.createDefaultPowerSourceWiredClusterServer();
|
290
|
+
this.outlet = new MatterbridgeEndpoint([onOffOutlet, bridgedNode, powerSource], { uniqueStorageKey: 'Outlet' }, this.config.debug).createDefaultIdentifyClusterServer();
|
291
|
+
this.outlet
|
292
|
+
.createDefaultGroupsClusterServer()
|
293
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Outlet', '0x29252164', 0xfff1, 'Matterbridge', 'Matterbridge Outlet', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
294
|
+
.createDefaultOnOffClusterServer()
|
295
|
+
.createDefaultPowerSourceWiredClusterServer();
|
300
296
|
await this.registerDevice(this.outlet);
|
301
297
|
this.bridgedDevices.set(this.outlet.deviceName ?? '', this.outlet);
|
302
298
|
this.outlet.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
303
299
|
this.outlet?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
304
300
|
});
|
305
301
|
this.outlet.addCommandHandler('on', async () => {
|
306
|
-
await this.outlet?.setAttribute(
|
302
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.outlet?.log);
|
307
303
|
this.outlet?.log.info('Command on called');
|
308
304
|
});
|
309
305
|
this.outlet.addCommandHandler('off', async () => {
|
310
|
-
await this.outlet?.setAttribute(
|
306
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet?.log);
|
311
307
|
this.outlet?.log.info('Command off called');
|
312
308
|
});
|
313
309
|
this.cover = new MatterbridgeEndpoint([coverDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Cover' }, this.config.debug);
|
@@ -319,7 +315,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
319
315
|
this.cover.createDefaultPowerSourceRechargeableBatteryClusterServer(86);
|
320
316
|
await this.registerDevice(this.cover);
|
321
317
|
this.bridgedDevices.set(this.cover.deviceName ?? '', this.cover);
|
322
|
-
this.cover.subscribeAttribute(
|
318
|
+
this.cover.subscribeAttribute(WindowCovering.Cluster.id, 'mode', (newValue, oldValue) => {
|
323
319
|
this.cover?.log.info(`Attribute mode changed from ${oldValue} to ${newValue}. Reverse: ${newValue.motorDirectionReversed}. Calibration: ${newValue.calibrationMode}. Maintenance: ${newValue.maintenanceMode}. LED: ${newValue.ledFeedback}`);
|
324
320
|
}, this.cover.log);
|
325
321
|
this.cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -341,41 +337,42 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
341
337
|
await this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
342
338
|
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called`);
|
343
339
|
});
|
344
|
-
this.lock = new MatterbridgeEndpoint([doorLockDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Lock' }, this.config.debug);
|
345
|
-
this.lock
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
this.lock.createDefaultPowerSourceRechargeableBatteryClusterServer(30);
|
340
|
+
this.lock = new MatterbridgeEndpoint([doorLockDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Lock' }, this.config.debug).createDefaultIdentifyClusterServer();
|
341
|
+
this.lock
|
342
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Lock', '0x96352164', 0xfff1, 'Matterbridge', 'Matterbridge Lock', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
343
|
+
.createDefaultDoorLockClusterServer()
|
344
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(30);
|
350
345
|
await this.registerDevice(this.lock);
|
351
346
|
this.bridgedDevices.set(this.lock.deviceName ?? '', this.lock);
|
352
347
|
this.lock.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
353
348
|
this.lock?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
354
349
|
});
|
355
350
|
this.lock.addCommandHandler('lockDoor', async () => {
|
356
|
-
await this.lock?.setAttribute(
|
351
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked, this.lock?.log);
|
357
352
|
this.lock?.log.info('Command lockDoor called');
|
358
353
|
});
|
359
354
|
this.lock.addCommandHandler('unlockDoor', async () => {
|
360
|
-
await this.lock?.setAttribute(
|
355
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Unlocked, this.lock?.log);
|
361
356
|
this.lock?.log.info('Command unlockDoor called');
|
362
357
|
});
|
363
|
-
this.thermoAuto = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (AutoMode)' }, this.config.debug);
|
364
|
-
this.thermoAuto
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
this.thermoAuto
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
358
|
+
this.thermoAuto = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (AutoMode)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
359
|
+
this.thermoAuto
|
360
|
+
.createDefaultGroupsClusterServer()
|
361
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (AutoMode)', '0x96382164A', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
362
|
+
.createDefaultThermostatClusterServer(20, 18, 22)
|
363
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
364
|
+
this.thermoAuto
|
365
|
+
.addChildDeviceType('Flow', flowSensor)
|
366
|
+
.createDefaultFlowMeasurementClusterServer(1 * 10)
|
367
|
+
.addRequiredClusterServers();
|
368
|
+
this.thermoAuto
|
369
|
+
.addChildDeviceType('Temperature', temperatureSensor)
|
370
|
+
.createDefaultTemperatureMeasurementClusterServer(21 * 100)
|
371
|
+
.addRequiredClusterServers();
|
372
|
+
this.thermoAuto
|
373
|
+
.addChildDeviceType('Humidity', humiditySensor)
|
374
|
+
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
375
|
+
.addRequiredClusterServers();
|
379
376
|
await this.registerDevice(this.thermoAuto);
|
380
377
|
this.bridgedDevices.set(this.thermoAuto.deviceName ?? '', this.thermoAuto);
|
381
378
|
this.thermoAuto.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -408,23 +405,24 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
408
405
|
this.thermoAuto.subscribeAttribute(ThermostatCluster.id, 'occupiedCoolingSetpoint', async (value) => {
|
409
406
|
this.thermoAuto?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
410
407
|
}, this.thermoAuto.log);
|
411
|
-
this.thermoHeat = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Heat)' }, this.config.debug);
|
412
|
-
this.thermoHeat
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
this.thermoHeat
|
418
|
-
|
408
|
+
this.thermoHeat = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Heat)' }, this.config.debug).createDefaultIdentifyClusterServer();
|
409
|
+
this.thermoHeat
|
410
|
+
.createDefaultGroupsClusterServer()
|
411
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Heat)', '0x96382164H', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
412
|
+
.createDefaultHeatingThermostatClusterServer(20, 18, 5, 35)
|
413
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
414
|
+
this.thermoHeat
|
415
|
+
.addChildDeviceType('TemperatureIN', [temperatureSensor], {
|
419
416
|
tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }],
|
420
|
-
})
|
421
|
-
|
422
|
-
|
423
|
-
|
417
|
+
})
|
418
|
+
.createDefaultIdentifyClusterServer()
|
419
|
+
.createDefaultTemperatureMeasurementClusterServer(21 * 100);
|
420
|
+
this.thermoHeat
|
421
|
+
.addChildDeviceType('TemperatureOUT', [temperatureSensor], {
|
424
422
|
tagList: [{ mfgCode: null, namespaceId: LocationTag.Outdoor.namespaceId, tag: LocationTag.Outdoor.tag, label: null }],
|
425
|
-
})
|
426
|
-
|
427
|
-
|
423
|
+
})
|
424
|
+
.createDefaultIdentifyClusterServer()
|
425
|
+
.createDefaultTemperatureMeasurementClusterServer(15 * 100);
|
428
426
|
await this.registerDevice(this.thermoHeat);
|
429
427
|
this.bridgedDevices.set(this.thermoHeat.deviceName ?? '', this.thermoHeat);
|
430
428
|
this.thermoHeat.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -440,13 +438,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
440
438
|
this.thermoHeat.subscribeAttribute(ThermostatCluster.id, 'occupiedHeatingSetpoint', async (value) => {
|
441
439
|
this.thermoHeat?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
442
440
|
}, this.thermoHeat.log);
|
443
|
-
this.thermoCool = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Cool)' }, this.config.debug)
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
this.thermoCool.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
441
|
+
this.thermoCool = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Cool)' }, this.config.debug)
|
442
|
+
.createDefaultIdentifyClusterServer()
|
443
|
+
.createDefaultGroupsClusterServer()
|
444
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Thermostat (Cool)', '0x96382164C', 0xfff1, 'Matterbridge', 'Matterbridge Thermostat', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
445
|
+
.createDefaultCoolingThermostatClusterServer(20, 18, 5, 35)
|
446
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
450
447
|
await this.registerDevice(this.thermoCool);
|
451
448
|
this.bridgedDevices.set(this.thermoCool.deviceName ?? '', this.thermoCool);
|
452
449
|
this.thermoCool.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -464,54 +461,54 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
464
461
|
}, this.thermoCool.log);
|
465
462
|
this.airPurifier = new MatterbridgeEndpoint([airPurifier, temperatureSensor, humiditySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air purifier' }, this.config.debug);
|
466
463
|
this.airPurifier.log.logName = 'Air purifier';
|
467
|
-
this.airPurifier
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
464
|
+
this.airPurifier
|
465
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Air purifier', '0x96584864AP', 0xfff1, 'Matterbridge', 'Matterbridge Air purifier', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
466
|
+
.createDefaultIdentifyClusterServer()
|
467
|
+
.createDefaultFanControlClusterServer()
|
468
|
+
.createDefaultTemperatureMeasurementClusterServer(20 * 100)
|
469
|
+
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
470
|
+
.createDefaultPowerSourceWiredClusterServer();
|
473
471
|
await this.registerDevice(this.airPurifier);
|
474
472
|
this.bridgedDevices.set(this.airPurifier.deviceName ?? '', this.airPurifier);
|
475
473
|
this.airPurifier.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
476
474
|
this.airPurifier?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
477
475
|
});
|
478
|
-
this.airPurifier.subscribeAttribute(
|
476
|
+
this.airPurifier.subscribeAttribute(FanControl.Cluster.id, 'fanMode', async (newValue, oldValue) => {
|
479
477
|
this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]}`);
|
480
478
|
if (newValue === FanControl.FanMode.Off) {
|
481
|
-
await this.airPurifier?.setAttribute(
|
479
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.airPurifier?.log);
|
482
480
|
}
|
483
481
|
else if (newValue === FanControl.FanMode.Low) {
|
484
|
-
await this.airPurifier?.setAttribute(
|
482
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.airPurifier?.log);
|
485
483
|
}
|
486
484
|
else if (newValue === FanControl.FanMode.Medium) {
|
487
|
-
await this.airPurifier?.setAttribute(
|
485
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.airPurifier?.log);
|
488
486
|
}
|
489
487
|
else if (newValue === FanControl.FanMode.High) {
|
490
|
-
await this.airPurifier?.setAttribute(
|
488
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.airPurifier?.log);
|
491
489
|
}
|
492
490
|
else if (newValue === FanControl.FanMode.On) {
|
493
|
-
await this.airPurifier?.setAttribute(
|
491
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.airPurifier?.log);
|
494
492
|
}
|
495
493
|
else if (newValue === FanControl.FanMode.Auto) {
|
496
|
-
await this.airPurifier?.setAttribute(
|
494
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.airPurifier?.log);
|
497
495
|
}
|
498
496
|
}, this.airPurifier.log);
|
499
|
-
this.airPurifier.subscribeAttribute(
|
497
|
+
this.airPurifier.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', async (newValue, oldValue) => {
|
500
498
|
this.fan?.log.info(`Percent setting changed from ${oldValue} to ${newValue}`);
|
501
499
|
if (isValidNumber(newValue, 0, 100))
|
502
|
-
await this.airPurifier?.setAttribute(
|
500
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
503
501
|
}, this.airPurifier.log);
|
504
|
-
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air conditioner' }, this.config.debug)
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
this.airConditioner.addRequiredClusterServers();
|
502
|
+
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air conditioner' }, this.config.debug)
|
503
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Air conditioner', '0x96382864AC', 0xfff1, 'Matterbridge', 'Matterbridge Air conditioner', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
504
|
+
.createDefaultIdentifyClusterServer()
|
505
|
+
.createDeadFrontOnOffClusterServer(true)
|
506
|
+
.createDefaultThermostatClusterServer(20, 18, 22)
|
507
|
+
.createDefaultFanControlClusterServer(FanControl.FanMode.Auto)
|
508
|
+
.createDefaultTemperatureMeasurementClusterServer(20 * 100)
|
509
|
+
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
510
|
+
.createDefaultPowerSourceWiredClusterServer()
|
511
|
+
.addRequiredClusterServers();
|
515
512
|
await this.registerDevice(this.airConditioner);
|
516
513
|
this.bridgedDevices.set(this.airConditioner.deviceName ?? '', this.airConditioner);
|
517
514
|
this.airConditioner.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -519,30 +516,29 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
519
516
|
});
|
520
517
|
this.airConditioner.addCommandHandler('on', async () => {
|
521
518
|
this.airConditioner?.log.info('Command on called');
|
522
|
-
await this.airConditioner?.setAttribute(
|
523
|
-
await this.airConditioner?.setAttribute(
|
519
|
+
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.airConditioner?.log);
|
520
|
+
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.airConditioner?.log);
|
524
521
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 20 * 100, this.airConditioner?.log);
|
525
|
-
await this.airConditioner?.setAttribute(
|
522
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
|
526
523
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner?.log);
|
527
|
-
await this.airConditioner?.setAttribute(
|
528
|
-
await this.airConditioner?.setAttribute(
|
524
|
+
await this.airConditioner?.setAttribute(FanControl.Cluster.id, 'speedSetting', 50, this.airConditioner?.log);
|
525
|
+
await this.airConditioner?.setAttribute(FanControl.Cluster.id, 'percentSetting', 50, this.airConditioner?.log);
|
529
526
|
});
|
530
527
|
this.airConditioner.addCommandHandler('off', async () => {
|
531
528
|
this.airConditioner?.log.info('Command off called');
|
532
|
-
await this.airConditioner?.setAttribute(
|
529
|
+
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.airConditioner?.log);
|
533
530
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', null, this.airConditioner?.log);
|
534
|
-
await this.airConditioner?.setAttribute(
|
531
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', null, this.airConditioner?.log);
|
535
532
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
|
536
|
-
await this.airConditioner?.setAttribute(
|
537
|
-
await this.airConditioner?.setAttribute(
|
538
|
-
});
|
539
|
-
this.pump = new MatterbridgeEndpoint([pumpDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Pump' }, this.config.debug)
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
this.pump.createDefaultPowerSourceWiredClusterServer();
|
533
|
+
await this.airConditioner?.setAttribute(FanControl.Cluster.id, 'speedSetting', null, this.airConditioner?.log);
|
534
|
+
await this.airConditioner?.setAttribute(FanControl.Cluster.id, 'percentSetting', null, this.airConditioner?.log);
|
535
|
+
});
|
536
|
+
this.pump = new MatterbridgeEndpoint([pumpDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Pump' }, this.config.debug)
|
537
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Pump', '0x96382864PUMP', 0xfff1, 'Matterbridge', 'Matterbridge Pump', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
538
|
+
.createDefaultIdentifyClusterServer()
|
539
|
+
.createDefaultOnOffClusterServer(true)
|
540
|
+
.createDefaultPumpConfigurationAndControlClusterServer()
|
541
|
+
.createDefaultPowerSourceWiredClusterServer();
|
546
542
|
await this.registerDevice(this.pump);
|
547
543
|
this.bridgedDevices.set(this.pump.deviceName ?? '', this.pump);
|
548
544
|
this.pump.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -550,97 +546,91 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
550
546
|
});
|
551
547
|
this.pump.addCommandHandler('on', async () => {
|
552
548
|
this.pump?.log.info('Command on called');
|
553
|
-
await this.pump?.setAttribute(
|
549
|
+
await this.pump?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.pump?.log);
|
554
550
|
});
|
555
551
|
this.pump.addCommandHandler('off', async () => {
|
556
552
|
this.pump?.log.info('Command off called');
|
557
|
-
await this.pump?.setAttribute(
|
553
|
+
await this.pump?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.pump?.log);
|
558
554
|
});
|
559
|
-
this.valve = new MatterbridgeEndpoint([waterValve, bridgedNode, powerSource], { uniqueStorageKey: 'Water valve' }, this.config.debug)
|
555
|
+
this.valve = new MatterbridgeEndpoint([waterValve, bridgedNode, powerSource], { uniqueStorageKey: 'Water valve' }, this.config.debug)
|
556
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Water valve', '0x96382864WV', 0xfff1, 'Matterbridge', 'Matterbridge Water valve', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
557
|
+
.createDefaultIdentifyClusterServer()
|
558
|
+
.createDefaultValveConfigurationAndControlClusterServer()
|
559
|
+
.createDefaultPowerSourceWiredClusterServer();
|
560
560
|
this.valve.log.logName = 'Water valve';
|
561
|
-
this.valve.createDefaultBridgedDeviceBasicInformationClusterServer('Water valve', '0x96382864WV', 0xfff1, 'Matterbridge', 'Matterbridge Water valve', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion);
|
562
|
-
this.valve.createDefaultIdentifyClusterServer();
|
563
|
-
this.valve.createDefaultValveConfigurationAndControlClusterServer();
|
564
|
-
this.valve.createDefaultPowerSourceWiredClusterServer();
|
565
561
|
await this.registerDevice(this.valve);
|
566
562
|
this.bridgedDevices.set(this.valve.deviceName ?? '', this.valve);
|
567
563
|
this.valve.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
568
564
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
569
565
|
});
|
570
|
-
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
571
|
-
|
572
|
-
|
573
|
-
this.fan.addRequiredClusterServers();
|
566
|
+
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
567
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan', 'serial_980545631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
568
|
+
.addRequiredClusterServers();
|
574
569
|
await this.registerDevice(this.fan);
|
575
570
|
this.bridgedDevices.set(this.fan.deviceName ?? '', this.fan);
|
576
|
-
this.fan.subscribeAttribute(
|
571
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'fanMode', async (newValue, oldValue) => {
|
577
572
|
this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]}`);
|
578
573
|
if (newValue === FanControl.FanMode.Off) {
|
579
|
-
await this.fan?.setAttribute(
|
574
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fan?.log);
|
580
575
|
}
|
581
576
|
else if (newValue === FanControl.FanMode.Low) {
|
582
|
-
await this.fan?.setAttribute(
|
577
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.fan?.log);
|
583
578
|
}
|
584
579
|
else if (newValue === FanControl.FanMode.Medium) {
|
585
|
-
await this.fan?.setAttribute(
|
580
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.fan?.log);
|
586
581
|
}
|
587
582
|
else if (newValue === FanControl.FanMode.High) {
|
588
|
-
await this.fan?.setAttribute(
|
583
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fan?.log);
|
589
584
|
}
|
590
585
|
else if (newValue === FanControl.FanMode.On) {
|
591
|
-
await this.fan?.setAttribute(
|
586
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fan?.log);
|
592
587
|
}
|
593
588
|
else if (newValue === FanControl.FanMode.Auto) {
|
594
|
-
await this.fan?.setAttribute(
|
589
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fan?.log);
|
595
590
|
}
|
596
591
|
}, this.fan.log);
|
597
|
-
this.fan.subscribeAttribute(
|
592
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', async (newValue, oldValue) => {
|
598
593
|
this.fan?.log.info(`Percent setting changed from ${oldValue} to ${newValue}`);
|
599
594
|
if (isValidNumber(newValue, 0, 100))
|
600
|
-
await this.fan?.setAttribute(
|
595
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fan?.log);
|
601
596
|
}, this.fan.log);
|
602
|
-
this.fan.subscribeAttribute(
|
597
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'speedSetting', async (newValue, oldValue) => {
|
603
598
|
this.fan?.log.info(`Speed setting changed from ${oldValue} to ${newValue}`);
|
604
599
|
if (isValidNumber(newValue, 0, 100))
|
605
|
-
await this.fan?.setAttribute(
|
600
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedCurrent', newValue, this.fan?.log);
|
606
601
|
}, this.fan.log);
|
607
|
-
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
this.waterLeak
|
612
|
-
await this.registerDevice(this.waterLeak);
|
602
|
+
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
603
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Water leak detector', 'serial_98745631222', 0xfff1, 'Matterbridge', 'Matterbridge WaterLeakDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
604
|
+
.addRequiredClusterServers()
|
605
|
+
.addOptionalClusterServers();
|
606
|
+
this.registerDevice(this.waterLeak);
|
613
607
|
this.bridgedDevices.set(this.waterLeak.deviceName ?? '', this.waterLeak);
|
614
|
-
await this.waterLeak.setAttribute(
|
615
|
-
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
this.waterFreeze.addOptionalClusterServers();
|
608
|
+
await this.waterLeak.setAttribute(BooleanState.Cluster.id, 'stateValue', false, this.waterLeak.log);
|
609
|
+
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
610
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Water freeze detector', 'serial_98745631223', 0xfff1, 'Matterbridge', 'Matterbridge WaterFreezeDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
611
|
+
.addRequiredClusterServers()
|
612
|
+
.addOptionalClusterServers();
|
620
613
|
await this.registerDevice(this.waterFreeze);
|
621
614
|
this.bridgedDevices.set(this.waterFreeze.deviceName ?? '', this.waterFreeze);
|
622
|
-
await this.waterFreeze.setAttribute(
|
623
|
-
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
this.rain.createDefaultBooleanStateConfigurationClusterServer();
|
615
|
+
await this.waterFreeze.setAttribute(BooleanState.Cluster.id, 'stateValue', false, this.waterFreeze.log);
|
616
|
+
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
617
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Rain sensor', 'serial_98745631224', 0xfff1, 'Matterbridge', 'Matterbridge RainSensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
618
|
+
.createDefaultIdentifyClusterServer()
|
619
|
+
.createDefaultBooleanStateClusterServer(false)
|
620
|
+
.createDefaultBooleanStateConfigurationClusterServer();
|
629
621
|
await this.registerDevice(this.rain);
|
630
622
|
this.bridgedDevices.set(this.rain.deviceName ?? '', this.rain);
|
631
|
-
this.smoke = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
this.smoke.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
623
|
+
this.smoke = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
|
624
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Smoke alarm sensor', 'serial_94745631225', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
625
|
+
.createDefaultIdentifyClusterServer()
|
626
|
+
.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
|
627
|
+
.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
637
628
|
await this.registerDevice(this.smoke);
|
638
629
|
this.bridgedDevices.set(this.smoke.deviceName ?? '', this.smoke);
|
639
|
-
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
this.airQuality.addClusterServers([
|
630
|
+
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
631
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Air quality sensor', 'serial_987484318322', 0xfff1, 'Matterbridge', 'Matterbridge Air Quality Sensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
632
|
+
.addRequiredClusterServers()
|
633
|
+
.addClusterServers([
|
644
634
|
TemperatureMeasurement.Cluster.id,
|
645
635
|
RelativeHumidityMeasurement.Cluster.id,
|
646
636
|
CarbonMonoxideConcentrationMeasurement.Cluster.id,
|
@@ -669,222 +659,286 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
669
659
|
await this.airQuality.setAttribute(Pm10ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
|
670
660
|
await this.airQuality.setAttribute(RadonConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
|
671
661
|
await this.airQuality.setAttribute(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
|
662
|
+
this.momentarySwitch = new MatterbridgeEndpoint([genericSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Momentary switch' }, this.config.debug)
|
663
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Momentary switch', 'serial_947942331225', 0xfff1, 'Matterbridge', 'Matterbridge MomentarySwitch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
664
|
+
.createDefaultIdentifyClusterServer()
|
665
|
+
.createDefaultSwitchClusterServer()
|
666
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(50, PowerSource.BatChargeLevel.Ok, 2900, 'CR2450', 1);
|
667
|
+
await this.registerDevice(this.momentarySwitch);
|
668
|
+
this.bridgedDevices.set(this.momentarySwitch.deviceName ?? '', this.momentarySwitch);
|
669
|
+
this.latchingSwitch = new MatterbridgeEndpoint([genericSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Latching switch' }, this.config.debug)
|
670
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Latching switch', 'serial_947442331225', 0xfff1, 'Matterbridge', 'Matterbridge LatchingSwitch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
671
|
+
.createDefaultIdentifyClusterServer()
|
672
|
+
.createDefaultLatchingSwitchClusterServer()
|
673
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(10, PowerSource.BatChargeLevel.Critical, 2850, 'CR2032', 1);
|
674
|
+
await this.registerDevice(this.latchingSwitch);
|
675
|
+
this.bridgedDevices.set(this.latchingSwitch.deviceName ?? '', this.latchingSwitch);
|
672
676
|
}
|
673
677
|
async onConfigure() {
|
674
678
|
await super.onConfigure();
|
675
679
|
this.log.info('onConfigure called');
|
676
|
-
await this.switch?.setAttribute(
|
680
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.switch.log);
|
677
681
|
this.switch?.log.info('Set switch initial onOff to false');
|
678
|
-
this.
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
682
|
+
if (this.config.useInterval) {
|
683
|
+
this.switchInterval = setInterval(async () => {
|
684
|
+
const status = this.switch?.getAttribute(OnOff.Cluster.id, 'onOff', this.switch.log);
|
685
|
+
if (isValidBoolean(status)) {
|
686
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', !status, this.switch.log);
|
687
|
+
this.switch?.log.info(`Set switch onOff to ${!status}`);
|
688
|
+
}
|
689
|
+
}, 60 * 1000 + 100);
|
690
|
+
}
|
691
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff.log);
|
686
692
|
this.lightOnOff?.log.info('Set light initial onOff to false.');
|
687
|
-
await this.dimmer?.setAttribute(
|
688
|
-
await this.dimmer?.setAttribute(
|
693
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
694
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 1, this.dimmer.log);
|
689
695
|
this.dimmer?.log.info(`Set dimmer initial onOff to false, currentLevel to 1.`);
|
690
|
-
await this.light?.setAttribute(
|
691
|
-
await this.light?.setAttribute(
|
692
|
-
await this.light?.setAttribute(
|
693
|
-
await this.light?.setAttribute(
|
696
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light.log);
|
697
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 200, this.light.log);
|
698
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentHue', 0, this.light.log);
|
699
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', 128, this.light.log);
|
694
700
|
await this.light?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
695
701
|
this.light?.log.info('Set light initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
696
|
-
await this.lightXY?.setAttribute(
|
697
|
-
await this.lightXY?.setAttribute(
|
698
|
-
await this.lightXY?.setAttribute(
|
699
|
-
await this.lightXY?.setAttribute(
|
702
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightXY.log);
|
703
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 254, this.lightXY.log);
|
704
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'currentX', 0.7006 * 65536, this.lightXY.log);
|
705
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'currentY', 0.2993 * 65536, this.lightXY.log);
|
700
706
|
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.CurrentXAndCurrentY);
|
701
707
|
this.lightXY?.log.info('Set light XY initial onOff to true, currentLevel to 254, X to 0.7006 and Y to 0.2993.');
|
702
|
-
await this.lightHS?.setAttribute(
|
703
|
-
await this.lightHS?.setAttribute(
|
704
|
-
await this.lightHS?.setAttribute(
|
705
|
-
await this.lightHS?.setAttribute(
|
708
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightHS.log);
|
709
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 1, this.lightHS.log);
|
710
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentHue', 0, this.lightHS.log);
|
711
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', 128, this.lightHS.log);
|
706
712
|
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
707
713
|
this.lightHS?.log.info('Set light HS initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
708
|
-
await this.lightCT?.setAttribute(
|
709
|
-
await this.lightCT?.setAttribute(
|
710
|
-
await this.lightCT?.setAttribute(
|
714
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightCT.log);
|
715
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 128, this.lightCT.log);
|
716
|
+
await this.lightCT?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', 250, this.lightCT.log);
|
711
717
|
await this.lightCT?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
712
718
|
this.lightCT?.log.info('Set light CT initial onOff to true, currentLevel to 128, colorTemperatureMireds to 250.');
|
713
|
-
this.
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
level
|
718
|
-
|
719
|
-
level
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
719
|
+
if (this.config.useInterval) {
|
720
|
+
this.lightInterval = setInterval(async () => {
|
721
|
+
const state = this.light?.getAttribute(OnOff.Cluster.id, 'onOff', this.light.log);
|
722
|
+
let level = this.light?.getAttribute(LevelControl.Cluster.id, 'currentLevel', this.light.log);
|
723
|
+
if (isValidBoolean(state) && isValidNumber(level, 0, 254)) {
|
724
|
+
level += 10;
|
725
|
+
if (level >= 250) {
|
726
|
+
level = 1;
|
727
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff.log);
|
728
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
729
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light.log);
|
730
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightXY.log);
|
731
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightHS.log);
|
732
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightCT.log);
|
733
|
+
this.log.info('Set lights onOff to false');
|
734
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
735
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light.log);
|
736
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY.log);
|
737
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS.log);
|
738
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT.log);
|
739
|
+
this.log.info(`Set lights currentLevel to ${level}`);
|
740
|
+
}
|
741
|
+
else {
|
742
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightOnOff?.log);
|
743
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.dimmer.log);
|
744
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.light.log);
|
745
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightXY.log);
|
746
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightHS.log);
|
747
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightCT.log);
|
748
|
+
this.log.info('Set lights onOff to true');
|
749
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
750
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light.log);
|
751
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY.log);
|
752
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS.log);
|
753
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT.log);
|
754
|
+
this.log.info(`Set lights currentLevel to ${level}`);
|
755
|
+
}
|
748
756
|
}
|
749
|
-
}
|
750
|
-
}
|
751
|
-
await this.outlet?.setAttribute(
|
757
|
+
}, 60 * 1000 + 200);
|
758
|
+
}
|
759
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet.log);
|
752
760
|
this.outlet?.log.info('Set outlet initial onOff to false');
|
753
|
-
this.
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
761
|
+
if (this.config.useInterval) {
|
762
|
+
this.outletInterval = setInterval(async () => {
|
763
|
+
const state = this.outlet?.getAttribute(OnOff.Cluster.id, 'onOff', this.outlet.log);
|
764
|
+
if (isValidBoolean(state)) {
|
765
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', !state, this.outlet.log);
|
766
|
+
this.outlet?.log.info(`Set outlet onOff to ${!state}`);
|
767
|
+
}
|
768
|
+
}, 60 * 1000 + 300);
|
769
|
+
}
|
760
770
|
await this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
761
771
|
this.cover?.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
762
|
-
this.
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
772
|
+
if (this.config.useInterval) {
|
773
|
+
this.coverInterval = setInterval(async () => {
|
774
|
+
let position = this.cover?.getAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', this.cover.log);
|
775
|
+
if (isValidNumber(position, 0, 10000)) {
|
776
|
+
position = position > 9000 ? 0 : position + 1000;
|
777
|
+
await this.cover?.setAttribute(WindowCovering.Cluster.id, 'targetPositionLiftPercent100ths', position, this.cover.log);
|
778
|
+
await this.cover?.setAttribute(WindowCovering.Cluster.id, 'currentPositionLiftPercent100ths', position, this.cover.log);
|
779
|
+
await this.cover?.setAttribute(WindowCovering.Cluster.id, 'operationalStatus', { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped }, this.cover.log);
|
780
|
+
this.cover?.log.info(`Set cover current and target positionLiftPercent100ths to ${position} and operationalStatus to Stopped`);
|
781
|
+
}
|
782
|
+
}, 60 * 1000 + 400);
|
783
|
+
}
|
784
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked, this.lock.log);
|
773
785
|
this.lock?.log.info('Set lock initial lockState to Locked');
|
774
|
-
this.
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
786
|
+
if (this.config.useInterval) {
|
787
|
+
this.lockInterval = setInterval(async () => {
|
788
|
+
const status = this.lock?.getAttribute(DoorLock.Cluster.id, 'lockState', this.lock.log);
|
789
|
+
if (isValidNumber(status, DoorLock.LockState.Locked, DoorLock.LockState.Unlocked)) {
|
790
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', status === DoorLock.LockState.Locked ? DoorLock.LockState.Unlocked : DoorLock.LockState.Locked, this.lock.log);
|
791
|
+
this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Unlocked' : 'Locked'}`);
|
792
|
+
}
|
793
|
+
}, 60 * 1000 + 500);
|
794
|
+
}
|
781
795
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'localTemperature', 16 * 100, this.thermoAuto.log);
|
782
796
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'systemMode', Thermostat.SystemMode.Auto, this.thermoAuto.log);
|
783
797
|
this.thermoAuto?.log.info('Set thermostat initial localTemperature to 16°C and mode Auto');
|
784
798
|
const temperature = this.thermoAuto?.getChildEndpointByName('Temperature');
|
785
|
-
await temperature?.setAttribute(
|
799
|
+
await temperature?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 16 * 100, this.thermoAuto?.log);
|
786
800
|
const humidity = this.thermoAuto?.getChildEndpointByName('Humidity');
|
787
801
|
await humidity?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.thermoAuto?.log);
|
788
802
|
const flow = this.thermoAuto?.getChildEndpointByName('Flow');
|
789
|
-
await flow?.setAttribute(
|
803
|
+
await flow?.setAttribute(FlowMeasurement.Cluster.id, 'measuredValue', 10, this.thermoAuto?.log);
|
790
804
|
this.thermoAuto?.log.info('Set thermostat ext temperature to 16°C, ext humidity to 50% and ext valve flow to 10');
|
791
|
-
this.
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
805
|
+
if (this.config.useInterval) {
|
806
|
+
this.thermoInterval = setInterval(async () => {
|
807
|
+
let temperature = this.thermoAuto?.getAttribute(ThermostatCluster.id, 'localTemperature', this.thermoAuto.log);
|
808
|
+
if (isValidNumber(temperature, 1600, 2400)) {
|
809
|
+
temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
|
810
|
+
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoAuto.log);
|
811
|
+
await this.thermoHeat?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoHeat.log);
|
812
|
+
const tempIn = this.thermoHeat?.getChildEndpointByName('TemperatureIN');
|
813
|
+
await tempIn?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', temperature - 50, this.thermoHeat?.log);
|
814
|
+
const tempOut = this.thermoHeat?.getChildEndpointByName('TemperatureOUT');
|
815
|
+
await tempOut?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', temperature - 400, this.thermoHeat?.log);
|
816
|
+
await this.thermoCool?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoCool.log);
|
817
|
+
const temp = this.thermoCool?.getChildEndpointByName('Temperature');
|
818
|
+
await temp?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', temperature, this.thermoCool?.log);
|
819
|
+
const humidity = this.thermoCool?.getChildEndpointByName('Humidity');
|
820
|
+
await humidity?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.thermoCool?.log);
|
821
|
+
const flow = this.thermoCool?.getChildEndpointByName('Flow');
|
822
|
+
await flow?.setAttribute(FlowMeasurement.Cluster.id, 'measuredValue', 10, this.thermoCool?.log);
|
823
|
+
this.thermoAuto?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
824
|
+
this.thermoHeat?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
825
|
+
this.thermoCool?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
826
|
+
}
|
827
|
+
}, 60 * 1000 + 600);
|
828
|
+
}
|
829
|
+
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.airConditioner.log);
|
814
830
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 2000, this.airConditioner.log);
|
815
|
-
this.
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
831
|
+
if (this.config.useInterval) {
|
832
|
+
this.airConditionerInterval = setInterval(async () => {
|
833
|
+
let temperature = this.airConditioner?.getAttribute(ThermostatCluster.id, 'localTemperature', this.airConditioner.log);
|
834
|
+
if (isValidNumber(temperature, 1600, 2400)) {
|
835
|
+
temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
|
836
|
+
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.airConditioner.log);
|
837
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', temperature, this.airConditioner.log);
|
838
|
+
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner.log);
|
839
|
+
this.airConditioner?.log.info(`Set airConditioner localTemperature to ${temperature / 100}°C`);
|
840
|
+
}
|
841
|
+
}, 60 * 1000 + 550);
|
842
|
+
}
|
825
843
|
this.fan?.log.info('Set fan initial fanMode to Auto, percentCurrent and percentSetting to 50 and speedCurrent and speedSetting to 50');
|
826
|
-
await this.fan?.setAttribute(
|
827
|
-
await this.fan?.setAttribute(
|
828
|
-
await this.fan?.setAttribute(
|
829
|
-
await this.fan?.setAttribute(
|
830
|
-
await this.fan?.setAttribute(
|
831
|
-
this.
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
844
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'fanMode', FanControl.FanMode.Auto, this.fan.log);
|
845
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fan.log);
|
846
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentSetting', 50, this.fan.log);
|
847
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedCurrent', 50, this.fan.log);
|
848
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedSetting', 50, this.fan.log);
|
849
|
+
if (this.config.useInterval) {
|
850
|
+
this.fanInterval = setInterval(async () => {
|
851
|
+
const mode = this.fan?.getAttribute(FanControl.Cluster.id, 'fanMode', this.fan.log);
|
852
|
+
let value = this.fan?.getAttribute(FanControl.Cluster.id, 'percentCurrent', this.fan.log);
|
853
|
+
if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
|
854
|
+
value = value + 10 >= 100 ? 0 : value + 10;
|
855
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', value, this.fan.log);
|
856
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentSetting', value, this.fan.log);
|
857
|
+
this.fan?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
|
858
|
+
}
|
859
|
+
}, 60 * 1000 + 700);
|
860
|
+
}
|
861
|
+
await this.waterLeak?.setAttribute(BooleanState.Cluster.id, 'stateValue', false, this.waterLeak.log);
|
862
|
+
if (this.config.useInterval) {
|
863
|
+
this.waterLeakInterval = setInterval(async () => {
|
864
|
+
let value = this.waterLeak?.getAttribute(BooleanState.Cluster.id, 'stateValue', this.waterLeak.log);
|
865
|
+
if (isValidBoolean(value)) {
|
866
|
+
value = !value;
|
867
|
+
await this.waterLeak?.setAttribute(BooleanState.Cluster.id, 'stateValue', value, this.waterLeak.log);
|
868
|
+
this.waterLeak?.log.info(`Set waterLeak stateValue to ${value}`);
|
869
|
+
}
|
870
|
+
}, 60 * 1000 + 800);
|
871
|
+
}
|
872
|
+
await this.waterFreeze?.setAttribute(BooleanState.Cluster.id, 'stateValue', false, this.waterFreeze.log);
|
873
|
+
if (this.config.useInterval) {
|
874
|
+
this.waterFreezeInterval = setInterval(async () => {
|
875
|
+
let value = this.waterFreeze?.getAttribute(BooleanState.Cluster.id, 'stateValue', this.waterFreeze.log);
|
876
|
+
if (isValidBoolean(value)) {
|
877
|
+
value = !value;
|
878
|
+
await this.waterFreeze?.setAttribute(BooleanState.Cluster.id, 'stateValue', value, this.waterFreeze.log);
|
879
|
+
this.waterFreeze?.log.info(`Set waterFreeze stateValue to ${value}`);
|
880
|
+
}
|
881
|
+
}, 60 * 1000 + 900);
|
882
|
+
}
|
883
|
+
await this.rain?.setAttribute(BooleanState.Cluster.id, 'stateValue', false, this.rain.log);
|
884
|
+
if (this.config.useInterval) {
|
885
|
+
this.rainInterval = setInterval(async () => {
|
886
|
+
let value = this.rain?.getAttribute(BooleanState.Cluster.id, 'stateValue', this.rain.log);
|
887
|
+
if (isValidBoolean(value)) {
|
888
|
+
value = !value;
|
889
|
+
await this.rain?.setAttribute(BooleanState.Cluster.id, 'stateValue', value, this.rain.log);
|
890
|
+
this.rain?.log.info(`Set rain stateValue to ${value}`);
|
891
|
+
}
|
892
|
+
}, 60 * 1000 + 1000);
|
893
|
+
}
|
894
|
+
await this.smoke?.setAttribute(SmokeCoAlarm.Cluster.id, 'smokeState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
|
895
|
+
await this.smoke?.setAttribute(SmokeCoAlarm.Cluster.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
|
896
|
+
if (this.config.useInterval) {
|
897
|
+
this.smokeInterval = setInterval(async () => {
|
898
|
+
let value = this.smoke?.getAttribute(SmokeCoAlarm.Cluster.id, 'smokeState', this.smoke.log);
|
899
|
+
if (isValidNumber(value, SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Critical)) {
|
900
|
+
value = value === SmokeCoAlarm.AlarmState.Normal ? SmokeCoAlarm.AlarmState.Critical : SmokeCoAlarm.AlarmState.Normal;
|
901
|
+
await this.smoke?.setAttribute(SmokeCoAlarm.Cluster.id, 'smokeState', value, this.smoke.log);
|
902
|
+
await this.smoke?.setAttribute(SmokeCoAlarm.Cluster.id, 'coState', value, this.smoke.log);
|
903
|
+
this.smoke?.log.info(`Set smoke smokeState and coState to ${value}`);
|
904
|
+
}
|
905
|
+
}, 60 * 1000 + 1100);
|
906
|
+
}
|
907
|
+
this.airQuality?.setAttribute(AirQuality.Cluster.id, 'airQuality', AirQuality.AirQualityEnum.Good, this.airQuality.log);
|
908
|
+
if (this.config.useInterval) {
|
909
|
+
this.airQualityInterval = setInterval(async () => {
|
910
|
+
let value = this.airQuality?.getAttribute(AirQuality.Cluster.id, 'airQuality', this.airQuality?.log);
|
911
|
+
if (isValidNumber(value, AirQuality.AirQualityEnum.Good, AirQuality.AirQualityEnum.ExtremelyPoor)) {
|
912
|
+
value = value >= AirQuality.AirQualityEnum.ExtremelyPoor ? AirQuality.AirQualityEnum.Good : value + 1;
|
913
|
+
await this.airQuality?.setAttribute(AirQuality.Cluster.id, 'airQuality', value, this.airQuality.log);
|
914
|
+
this.airQuality?.log.info(`Set air quality to ${value}`);
|
915
|
+
}
|
916
|
+
}, 60 * 1000 + 1100);
|
917
|
+
}
|
918
|
+
if (this.config.useInterval) {
|
919
|
+
this.genericSwitchInterval = setInterval(async () => {
|
920
|
+
if (this.genericSwitchLastEvent === 'Release') {
|
921
|
+
await this.momentarySwitch?.triggerSwitchEvent('Single', this.momentarySwitch?.log);
|
922
|
+
this.genericSwitchLastEvent = 'Single';
|
923
|
+
}
|
924
|
+
else if (this.genericSwitchLastEvent === 'Single') {
|
925
|
+
await this.momentarySwitch?.triggerSwitchEvent('Double', this.momentarySwitch?.log);
|
926
|
+
this.genericSwitchLastEvent = 'Double';
|
927
|
+
}
|
928
|
+
else if (this.genericSwitchLastEvent === 'Double') {
|
929
|
+
await this.momentarySwitch?.triggerSwitchEvent('Long', this.momentarySwitch?.log);
|
930
|
+
this.genericSwitchLastEvent = 'Long';
|
931
|
+
}
|
932
|
+
else if (this.genericSwitchLastEvent === 'Long') {
|
933
|
+
await this.latchingSwitch?.triggerSwitchEvent('Press', this.latchingSwitch?.log);
|
934
|
+
this.genericSwitchLastEvent = 'Press';
|
935
|
+
}
|
936
|
+
else if (this.genericSwitchLastEvent === 'Press') {
|
937
|
+
await this.latchingSwitch?.triggerSwitchEvent('Release', this.latchingSwitch?.log);
|
938
|
+
this.genericSwitchLastEvent = 'Release';
|
939
|
+
}
|
940
|
+
}, 60 * 1000 + 1900);
|
941
|
+
}
|
888
942
|
}
|
889
943
|
async onShutdown(reason) {
|
890
944
|
clearInterval(this.switchInterval);
|
@@ -900,6 +954,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
900
954
|
clearInterval(this.smokeInterval);
|
901
955
|
clearInterval(this.airQualityInterval);
|
902
956
|
clearInterval(this.airConditionerInterval);
|
957
|
+
clearInterval(this.genericSwitchInterval);
|
903
958
|
await super.onShutdown(reason);
|
904
959
|
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
905
960
|
if (this.config.unregisterOnShutdown === true)
|