matterbridge-example-dynamic-platform 1.1.5 → 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,6 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform } 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';
|
3
2
|
import { isValidBoolean, isValidNumber } from 'matterbridge/utils';
|
3
|
+
import { LocationTag } from 'matterbridge/matter';
|
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';
|
4
5
|
export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
|
5
6
|
switch;
|
6
7
|
lightOnOff;
|
@@ -25,6 +26,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
25
26
|
airPurifier;
|
26
27
|
pump;
|
27
28
|
valve;
|
29
|
+
momentarySwitch;
|
30
|
+
latchingSwitch;
|
28
31
|
switchInterval;
|
29
32
|
lightInterval;
|
30
33
|
outletInterval;
|
@@ -38,275 +41,269 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
38
41
|
smokeInterval;
|
39
42
|
airQualityInterval;
|
40
43
|
airConditionerInterval;
|
44
|
+
genericSwitchInterval;
|
45
|
+
genericSwitchLastEvent = 'Release';
|
41
46
|
bridgedDevices = new Map();
|
42
47
|
fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
|
43
48
|
constructor(matterbridge, log, config) {
|
44
49
|
super(matterbridge, log, config);
|
45
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('2.1.
|
46
|
-
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.`);
|
47
52
|
}
|
48
53
|
this.log.info('Initializing platform:', this.config.name);
|
49
54
|
}
|
50
55
|
async onStart(reason) {
|
51
56
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
52
|
-
this.switch = new MatterbridgeEndpoint([onOffSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Switch' }, this.config.debug);
|
53
|
-
this.switch
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
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);
|
59
63
|
await this.registerDevice(this.switch);
|
60
64
|
this.bridgedDevices.set(this.switch.deviceName ?? '', this.switch);
|
61
65
|
this.switch.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
62
66
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
63
67
|
});
|
64
68
|
this.switch.addCommandHandler('on', async () => {
|
65
|
-
await this.switch?.setAttribute(
|
69
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.switch.log);
|
66
70
|
this.switch?.log.info('Command on called');
|
67
71
|
});
|
68
72
|
this.switch.addCommandHandler('off', async () => {
|
69
|
-
await this.switch?.setAttribute(
|
73
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.switch.log);
|
70
74
|
this.switch?.log.info('Command off called');
|
71
75
|
});
|
72
|
-
this.lightOnOff = new MatterbridgeEndpoint([onOffLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
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();
|
79
82
|
await this.registerDevice(this.lightOnOff);
|
80
83
|
this.bridgedDevices.set(this.lightOnOff.deviceName ?? '', this.lightOnOff);
|
81
84
|
this.lightOnOff.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
82
85
|
this.lightOnOff?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
83
86
|
});
|
84
87
|
this.lightOnOff.addCommandHandler('on', async () => {
|
85
|
-
await this.lightOnOff?.setAttribute(
|
88
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightOnOff?.log);
|
86
89
|
this.lightOnOff?.log.info('Command on called');
|
87
90
|
});
|
88
91
|
this.lightOnOff.addCommandHandler('off', async () => {
|
89
|
-
await this.lightOnOff?.setAttribute(
|
92
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff?.log);
|
90
93
|
this.lightOnOff?.log.info('Command off called');
|
91
94
|
});
|
92
|
-
this.dimmer = new MatterbridgeEndpoint([dimmableLight, bridgedNode, powerSource], { uniqueStorageKey: 'Dimmer' }, this.config.debug);
|
93
|
-
this.dimmer
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
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);
|
100
102
|
await this.registerDevice(this.dimmer);
|
101
103
|
this.bridgedDevices.set(this.dimmer.deviceName ?? '', this.dimmer);
|
102
104
|
this.dimmer.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
103
105
|
this.dimmer?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
104
106
|
});
|
105
107
|
this.dimmer.addCommandHandler('on', async () => {
|
106
|
-
await this.dimmer?.setAttribute(
|
108
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.dimmer.log);
|
107
109
|
this.dimmer?.log.info('Command on called');
|
108
110
|
});
|
109
111
|
this.dimmer.addCommandHandler('off', async () => {
|
110
|
-
await this.dimmer?.setAttribute(
|
112
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
111
113
|
this.dimmer?.log.info('Command off called');
|
112
114
|
});
|
113
115
|
this.dimmer.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
114
|
-
await this.dimmer?.setAttribute(
|
116
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
115
117
|
this.dimmer?.log.debug(`Command moveToLevel called request: ${level}`);
|
116
118
|
});
|
117
119
|
this.dimmer.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
118
|
-
await this.dimmer?.setAttribute(
|
120
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
119
121
|
this.dimmer?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
120
122
|
});
|
121
|
-
this.light = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug);
|
122
|
-
this.light
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
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);
|
130
131
|
await this.registerDevice(this.light);
|
131
132
|
this.bridgedDevices.set(this.light.deviceName ?? '', this.light);
|
132
133
|
this.light.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
133
134
|
this.light?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
134
135
|
});
|
135
136
|
this.light.addCommandHandler('on', async () => {
|
136
|
-
await this.light?.setAttribute(
|
137
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.light?.log);
|
137
138
|
this.light?.log.info('Command on called');
|
138
139
|
});
|
139
140
|
this.light.addCommandHandler('off', async () => {
|
140
|
-
await this.light?.setAttribute(
|
141
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light?.log);
|
141
142
|
this.light?.log.info('Command off called');
|
142
143
|
});
|
143
144
|
this.light.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
144
|
-
await this.light?.setAttribute(
|
145
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light?.log);
|
145
146
|
this.light?.log.debug(`Command moveToLevel called request: ${level}`);
|
146
147
|
});
|
147
148
|
this.light.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
148
|
-
await this.light?.setAttribute(
|
149
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light?.log);
|
149
150
|
this.light?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
150
151
|
});
|
151
152
|
this.light.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
152
|
-
await this.light?.setAttribute(
|
153
|
-
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);
|
154
155
|
this.light?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
155
156
|
});
|
156
157
|
this.light.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation } }) => {
|
157
|
-
await this.light?.setAttribute(
|
158
|
-
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);
|
159
160
|
this.light?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}`);
|
160
161
|
});
|
161
162
|
this.light.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
162
|
-
await this.light?.setAttribute(
|
163
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.light?.log);
|
163
164
|
this.light?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
164
165
|
});
|
165
166
|
this.light.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
166
|
-
await this.light?.setAttribute(
|
167
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.light?.log);
|
167
168
|
this.light?.log.debug(`Command moveToSaturation called request: saturation ${saturation}}`);
|
168
169
|
});
|
169
170
|
this.light.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
170
|
-
await this.light?.setAttribute(
|
171
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.light?.log);
|
171
172
|
this.light?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
172
173
|
});
|
173
|
-
this.lightHS = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (HS, CT)' }, this.config.debug);
|
174
|
-
this.lightHS
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
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();
|
182
182
|
await this.registerDevice(this.lightHS);
|
183
183
|
this.bridgedDevices.set(this.lightHS.deviceName ?? '', this.lightHS);
|
184
184
|
this.lightHS.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
185
185
|
this.lightHS?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
186
186
|
});
|
187
187
|
this.lightHS.addCommandHandler('on', async () => {
|
188
|
-
await this.lightHS?.setAttribute(
|
188
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightHS?.log);
|
189
189
|
this.lightHS?.log.info('Command on called');
|
190
190
|
});
|
191
191
|
this.lightHS.addCommandHandler('off', async () => {
|
192
|
-
await this.lightHS?.setAttribute(
|
192
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightHS?.log);
|
193
193
|
this.lightHS?.log.info('Command off called');
|
194
194
|
});
|
195
195
|
this.lightHS.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
196
|
-
await this.lightHS?.setAttribute(
|
196
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS?.log);
|
197
197
|
this.lightHS?.log.debug(`Command moveToLevel called request: ${level}`);
|
198
198
|
});
|
199
199
|
this.lightHS.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
200
|
-
await this.lightHS?.setAttribute(
|
200
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS?.log);
|
201
201
|
this.lightHS?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
202
202
|
});
|
203
203
|
this.lightHS.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation } }) => {
|
204
|
-
await this.lightHS?.setAttribute(
|
205
|
-
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);
|
206
206
|
this.lightHS?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}}`);
|
207
207
|
});
|
208
208
|
this.lightHS.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
209
|
-
await this.lightHS?.setAttribute(
|
209
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentHue', hue, this.lightHS?.log);
|
210
210
|
this.lightHS?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
211
211
|
});
|
212
212
|
this.lightHS.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
213
|
-
await this.lightHS?.setAttribute(
|
213
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'currentSaturation', saturation, this.lightHS?.log);
|
214
214
|
this.lightHS?.log.debug(`Command moveToSaturation called request: saturation ${saturation}`);
|
215
215
|
});
|
216
216
|
this.lightHS.addCommandHandler('moveToColorTemperature', async ({ request: colorTemperatureMireds }) => {
|
217
217
|
this.lightHS?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
218
218
|
});
|
219
|
-
this.lightXY = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug);
|
220
|
-
this.lightXY
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
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();
|
228
227
|
await this.registerDevice(this.lightXY);
|
229
228
|
this.bridgedDevices.set(this.lightXY.deviceName ?? '', this.lightXY);
|
230
229
|
this.lightXY.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
231
230
|
this.lightXY?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
232
231
|
});
|
233
232
|
this.lightXY.addCommandHandler('on', async () => {
|
234
|
-
await this.lightXY?.setAttribute(
|
233
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightXY?.log);
|
235
234
|
this.lightXY?.log.info('Command on called');
|
236
235
|
});
|
237
236
|
this.lightXY.addCommandHandler('off', async () => {
|
238
|
-
await this.lightXY?.setAttribute(
|
237
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightXY?.log);
|
239
238
|
this.lightXY?.log.info('Command off called');
|
240
239
|
});
|
241
240
|
this.lightXY.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
242
|
-
await this.lightXY?.setAttribute(
|
241
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY?.log);
|
243
242
|
this.lightXY?.log.debug(`Command moveToLevel called request: ${level}`);
|
244
243
|
});
|
245
244
|
this.lightXY.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
246
|
-
await this.lightXY?.setAttribute(
|
245
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY?.log);
|
247
246
|
this.lightXY?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
248
247
|
});
|
249
248
|
this.lightXY.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
250
|
-
await this.lightXY?.setAttribute(
|
251
|
-
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);
|
252
251
|
this.lightXY?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
253
252
|
});
|
254
253
|
this.lightXY.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
255
|
-
await this.lightXY?.setAttribute(
|
254
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightXY?.log);
|
256
255
|
this.lightXY?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
257
256
|
});
|
258
|
-
this.lightCT = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (CT)' }, this.config.debug);
|
259
|
-
this.lightCT
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
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);
|
267
265
|
await this.registerDevice(this.lightCT);
|
268
266
|
this.bridgedDevices.set(this.lightCT.deviceName ?? '', this.lightCT);
|
269
267
|
this.lightCT.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
270
268
|
this.lightCT?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
271
269
|
});
|
272
270
|
this.lightCT.addCommandHandler('on', async () => {
|
273
|
-
await this.lightCT?.setAttribute(
|
271
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightCT?.log);
|
274
272
|
this.lightCT?.log.info('Command on called');
|
275
273
|
});
|
276
274
|
this.lightCT.addCommandHandler('off', async () => {
|
277
|
-
await this.lightCT?.setAttribute(
|
275
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightCT?.log);
|
278
276
|
this.lightCT?.log.info('Command off called');
|
279
277
|
});
|
280
278
|
this.lightCT.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
281
|
-
await this.lightCT?.setAttribute(
|
279
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT?.log);
|
282
280
|
this.lightCT?.log.debug(`Command moveToLevel called request: ${level}`);
|
283
281
|
});
|
284
282
|
this.lightCT.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
285
|
-
await this.lightCT?.setAttribute(
|
283
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT?.log);
|
286
284
|
this.lightCT?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
287
285
|
});
|
288
286
|
this.lightCT.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
289
|
-
await this.lightCT?.setAttribute(
|
287
|
+
await this.lightCT?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightCT?.log);
|
290
288
|
this.lightCT?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
291
289
|
});
|
292
|
-
this.outlet = new MatterbridgeEndpoint([onOffOutlet, bridgedNode, powerSource], { uniqueStorageKey: 'Outlet' }, this.config.debug);
|
293
|
-
this.outlet
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
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();
|
299
296
|
await this.registerDevice(this.outlet);
|
300
297
|
this.bridgedDevices.set(this.outlet.deviceName ?? '', this.outlet);
|
301
298
|
this.outlet.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
302
299
|
this.outlet?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
303
300
|
});
|
304
301
|
this.outlet.addCommandHandler('on', async () => {
|
305
|
-
await this.outlet?.setAttribute(
|
302
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.outlet?.log);
|
306
303
|
this.outlet?.log.info('Command on called');
|
307
304
|
});
|
308
305
|
this.outlet.addCommandHandler('off', async () => {
|
309
|
-
await this.outlet?.setAttribute(
|
306
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet?.log);
|
310
307
|
this.outlet?.log.info('Command off called');
|
311
308
|
});
|
312
309
|
this.cover = new MatterbridgeEndpoint([coverDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Cover' }, this.config.debug);
|
@@ -318,7 +315,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
318
315
|
this.cover.createDefaultPowerSourceRechargeableBatteryClusterServer(86);
|
319
316
|
await this.registerDevice(this.cover);
|
320
317
|
this.bridgedDevices.set(this.cover.deviceName ?? '', this.cover);
|
321
|
-
this.cover.subscribeAttribute(
|
318
|
+
this.cover.subscribeAttribute(WindowCovering.Cluster.id, 'mode', (newValue, oldValue) => {
|
322
319
|
this.cover?.log.info(`Attribute mode changed from ${oldValue} to ${newValue}. Reverse: ${newValue.motorDirectionReversed}. Calibration: ${newValue.calibrationMode}. Maintenance: ${newValue.maintenanceMode}. LED: ${newValue.ledFeedback}`);
|
323
320
|
}, this.cover.log);
|
324
321
|
this.cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -340,41 +337,42 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
340
337
|
await this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
341
338
|
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called`);
|
342
339
|
});
|
343
|
-
this.lock = new MatterbridgeEndpoint([doorLockDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Lock' }, this.config.debug);
|
344
|
-
this.lock
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
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);
|
349
345
|
await this.registerDevice(this.lock);
|
350
346
|
this.bridgedDevices.set(this.lock.deviceName ?? '', this.lock);
|
351
347
|
this.lock.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
352
348
|
this.lock?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
353
349
|
});
|
354
350
|
this.lock.addCommandHandler('lockDoor', async () => {
|
355
|
-
await this.lock?.setAttribute(
|
351
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked, this.lock?.log);
|
356
352
|
this.lock?.log.info('Command lockDoor called');
|
357
353
|
});
|
358
354
|
this.lock.addCommandHandler('unlockDoor', async () => {
|
359
|
-
await this.lock?.setAttribute(
|
355
|
+
await this.lock?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Unlocked, this.lock?.log);
|
360
356
|
this.lock?.log.info('Command unlockDoor called');
|
361
357
|
});
|
362
|
-
this.thermoAuto = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (AutoMode)' }, this.config.debug);
|
363
|
-
this.thermoAuto
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
this.thermoAuto
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
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();
|
378
376
|
await this.registerDevice(this.thermoAuto);
|
379
377
|
this.bridgedDevices.set(this.thermoAuto.deviceName ?? '', this.thermoAuto);
|
380
378
|
this.thermoAuto.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -407,23 +405,24 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
407
405
|
this.thermoAuto.subscribeAttribute(ThermostatCluster.id, 'occupiedCoolingSetpoint', async (value) => {
|
408
406
|
this.thermoAuto?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
409
407
|
}, this.thermoAuto.log);
|
410
|
-
this.thermoHeat = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Heat)' }, this.config.debug);
|
411
|
-
this.thermoHeat
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
this.thermoHeat
|
417
|
-
|
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], {
|
418
416
|
tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }],
|
419
|
-
})
|
420
|
-
|
421
|
-
|
422
|
-
|
417
|
+
})
|
418
|
+
.createDefaultIdentifyClusterServer()
|
419
|
+
.createDefaultTemperatureMeasurementClusterServer(21 * 100);
|
420
|
+
this.thermoHeat
|
421
|
+
.addChildDeviceType('TemperatureOUT', [temperatureSensor], {
|
423
422
|
tagList: [{ mfgCode: null, namespaceId: LocationTag.Outdoor.namespaceId, tag: LocationTag.Outdoor.tag, label: null }],
|
424
|
-
})
|
425
|
-
|
426
|
-
|
423
|
+
})
|
424
|
+
.createDefaultIdentifyClusterServer()
|
425
|
+
.createDefaultTemperatureMeasurementClusterServer(15 * 100);
|
427
426
|
await this.registerDevice(this.thermoHeat);
|
428
427
|
this.bridgedDevices.set(this.thermoHeat.deviceName ?? '', this.thermoHeat);
|
429
428
|
this.thermoHeat.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -439,13 +438,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
439
438
|
this.thermoHeat.subscribeAttribute(ThermostatCluster.id, 'occupiedHeatingSetpoint', async (value) => {
|
440
439
|
this.thermoHeat?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
441
440
|
}, this.thermoHeat.log);
|
442
|
-
this.thermoCool = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Cool)' }, this.config.debug)
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
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);
|
449
447
|
await this.registerDevice(this.thermoCool);
|
450
448
|
this.bridgedDevices.set(this.thermoCool.deviceName ?? '', this.thermoCool);
|
451
449
|
this.thermoCool.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -463,54 +461,54 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
463
461
|
}, this.thermoCool.log);
|
464
462
|
this.airPurifier = new MatterbridgeEndpoint([airPurifier, temperatureSensor, humiditySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air purifier' }, this.config.debug);
|
465
463
|
this.airPurifier.log.logName = 'Air purifier';
|
466
|
-
this.airPurifier
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
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();
|
472
471
|
await this.registerDevice(this.airPurifier);
|
473
472
|
this.bridgedDevices.set(this.airPurifier.deviceName ?? '', this.airPurifier);
|
474
473
|
this.airPurifier.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
475
474
|
this.airPurifier?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
476
475
|
});
|
477
|
-
this.airPurifier.subscribeAttribute(
|
476
|
+
this.airPurifier.subscribeAttribute(FanControl.Cluster.id, 'fanMode', async (newValue, oldValue) => {
|
478
477
|
this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]}`);
|
479
478
|
if (newValue === FanControl.FanMode.Off) {
|
480
|
-
await this.airPurifier?.setAttribute(
|
479
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.airPurifier?.log);
|
481
480
|
}
|
482
481
|
else if (newValue === FanControl.FanMode.Low) {
|
483
|
-
await this.airPurifier?.setAttribute(
|
482
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.airPurifier?.log);
|
484
483
|
}
|
485
484
|
else if (newValue === FanControl.FanMode.Medium) {
|
486
|
-
await this.airPurifier?.setAttribute(
|
485
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.airPurifier?.log);
|
487
486
|
}
|
488
487
|
else if (newValue === FanControl.FanMode.High) {
|
489
|
-
await this.airPurifier?.setAttribute(
|
488
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.airPurifier?.log);
|
490
489
|
}
|
491
490
|
else if (newValue === FanControl.FanMode.On) {
|
492
|
-
await this.airPurifier?.setAttribute(
|
491
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.airPurifier?.log);
|
493
492
|
}
|
494
493
|
else if (newValue === FanControl.FanMode.Auto) {
|
495
|
-
await this.airPurifier?.setAttribute(
|
494
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.airPurifier?.log);
|
496
495
|
}
|
497
496
|
}, this.airPurifier.log);
|
498
|
-
this.airPurifier.subscribeAttribute(
|
497
|
+
this.airPurifier.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', async (newValue, oldValue) => {
|
499
498
|
this.fan?.log.info(`Percent setting changed from ${oldValue} to ${newValue}`);
|
500
499
|
if (isValidNumber(newValue, 0, 100))
|
501
|
-
await this.airPurifier?.setAttribute(
|
500
|
+
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
502
501
|
}, this.airPurifier.log);
|
503
|
-
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air conditioner' }, this.config.debug)
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
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();
|
514
512
|
await this.registerDevice(this.airConditioner);
|
515
513
|
this.bridgedDevices.set(this.airConditioner.deviceName ?? '', this.airConditioner);
|
516
514
|
this.airConditioner.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -518,30 +516,29 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
518
516
|
});
|
519
517
|
this.airConditioner.addCommandHandler('on', async () => {
|
520
518
|
this.airConditioner?.log.info('Command on called');
|
521
|
-
await this.airConditioner?.setAttribute(
|
522
|
-
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);
|
523
521
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 20 * 100, this.airConditioner?.log);
|
524
|
-
await this.airConditioner?.setAttribute(
|
522
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
|
525
523
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner?.log);
|
526
|
-
await this.airConditioner?.setAttribute(
|
527
|
-
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);
|
528
526
|
});
|
529
527
|
this.airConditioner.addCommandHandler('off', async () => {
|
530
528
|
this.airConditioner?.log.info('Command off called');
|
531
|
-
await this.airConditioner?.setAttribute(
|
529
|
+
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.airConditioner?.log);
|
532
530
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', null, this.airConditioner?.log);
|
533
|
-
await this.airConditioner?.setAttribute(
|
531
|
+
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', null, this.airConditioner?.log);
|
534
532
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
|
535
|
-
await this.airConditioner?.setAttribute(
|
536
|
-
await this.airConditioner?.setAttribute(
|
537
|
-
});
|
538
|
-
this.pump = new MatterbridgeEndpoint([pumpDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Pump' }, this.config.debug)
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
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();
|
545
542
|
await this.registerDevice(this.pump);
|
546
543
|
this.bridgedDevices.set(this.pump.deviceName ?? '', this.pump);
|
547
544
|
this.pump.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -549,97 +546,91 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
549
546
|
});
|
550
547
|
this.pump.addCommandHandler('on', async () => {
|
551
548
|
this.pump?.log.info('Command on called');
|
552
|
-
await this.pump?.setAttribute(
|
549
|
+
await this.pump?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.pump?.log);
|
553
550
|
});
|
554
551
|
this.pump.addCommandHandler('off', async () => {
|
555
552
|
this.pump?.log.info('Command off called');
|
556
|
-
await this.pump?.setAttribute(
|
553
|
+
await this.pump?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.pump?.log);
|
557
554
|
});
|
558
|
-
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();
|
559
560
|
this.valve.log.logName = 'Water valve';
|
560
|
-
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);
|
561
|
-
this.valve.createDefaultIdentifyClusterServer();
|
562
|
-
this.valve.createDefaultValveConfigurationAndControlClusterServer();
|
563
|
-
this.valve.createDefaultPowerSourceWiredClusterServer();
|
564
561
|
await this.registerDevice(this.valve);
|
565
562
|
this.bridgedDevices.set(this.valve.deviceName ?? '', this.valve);
|
566
563
|
this.valve.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
567
564
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
568
565
|
});
|
569
|
-
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
570
|
-
|
571
|
-
|
572
|
-
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();
|
573
569
|
await this.registerDevice(this.fan);
|
574
570
|
this.bridgedDevices.set(this.fan.deviceName ?? '', this.fan);
|
575
|
-
this.fan.subscribeAttribute(
|
571
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'fanMode', async (newValue, oldValue) => {
|
576
572
|
this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]}`);
|
577
573
|
if (newValue === FanControl.FanMode.Off) {
|
578
|
-
await this.fan?.setAttribute(
|
574
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 0, this.fan?.log);
|
579
575
|
}
|
580
576
|
else if (newValue === FanControl.FanMode.Low) {
|
581
|
-
await this.fan?.setAttribute(
|
577
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 33, this.fan?.log);
|
582
578
|
}
|
583
579
|
else if (newValue === FanControl.FanMode.Medium) {
|
584
|
-
await this.fan?.setAttribute(
|
580
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 66, this.fan?.log);
|
585
581
|
}
|
586
582
|
else if (newValue === FanControl.FanMode.High) {
|
587
|
-
await this.fan?.setAttribute(
|
583
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fan?.log);
|
588
584
|
}
|
589
585
|
else if (newValue === FanControl.FanMode.On) {
|
590
|
-
await this.fan?.setAttribute(
|
586
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 100, this.fan?.log);
|
591
587
|
}
|
592
588
|
else if (newValue === FanControl.FanMode.Auto) {
|
593
|
-
await this.fan?.setAttribute(
|
589
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fan?.log);
|
594
590
|
}
|
595
591
|
}, this.fan.log);
|
596
|
-
this.fan.subscribeAttribute(
|
592
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'percentSetting', async (newValue, oldValue) => {
|
597
593
|
this.fan?.log.info(`Percent setting changed from ${oldValue} to ${newValue}`);
|
598
594
|
if (isValidNumber(newValue, 0, 100))
|
599
|
-
await this.fan?.setAttribute(
|
595
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fan?.log);
|
600
596
|
}, this.fan.log);
|
601
|
-
this.fan.subscribeAttribute(
|
597
|
+
this.fan.subscribeAttribute(FanControl.Cluster.id, 'speedSetting', async (newValue, oldValue) => {
|
602
598
|
this.fan?.log.info(`Speed setting changed from ${oldValue} to ${newValue}`);
|
603
599
|
if (isValidNumber(newValue, 0, 100))
|
604
|
-
await this.fan?.setAttribute(
|
600
|
+
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedCurrent', newValue, this.fan?.log);
|
605
601
|
}, this.fan.log);
|
606
|
-
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
this.waterLeak
|
611
|
-
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);
|
612
607
|
this.bridgedDevices.set(this.waterLeak.deviceName ?? '', this.waterLeak);
|
613
|
-
await this.waterLeak.setAttribute(
|
614
|
-
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
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();
|
619
613
|
await this.registerDevice(this.waterFreeze);
|
620
614
|
this.bridgedDevices.set(this.waterFreeze.deviceName ?? '', this.waterFreeze);
|
621
|
-
await this.waterFreeze.setAttribute(
|
622
|
-
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
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();
|
628
621
|
await this.registerDevice(this.rain);
|
629
622
|
this.bridgedDevices.set(this.rain.deviceName ?? '', this.rain);
|
630
|
-
this.smoke = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
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);
|
636
628
|
await this.registerDevice(this.smoke);
|
637
629
|
this.bridgedDevices.set(this.smoke.deviceName ?? '', this.smoke);
|
638
|
-
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
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([
|
643
634
|
TemperatureMeasurement.Cluster.id,
|
644
635
|
RelativeHumidityMeasurement.Cluster.id,
|
645
636
|
CarbonMonoxideConcentrationMeasurement.Cluster.id,
|
@@ -668,222 +659,286 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
668
659
|
await this.airQuality.setAttribute(Pm10ConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
|
669
660
|
await this.airQuality.setAttribute(RadonConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.airQuality.log);
|
670
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);
|
671
676
|
}
|
672
677
|
async onConfigure() {
|
673
678
|
await super.onConfigure();
|
674
679
|
this.log.info('onConfigure called');
|
675
|
-
await this.switch?.setAttribute(
|
680
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.switch.log);
|
676
681
|
this.switch?.log.info('Set switch initial onOff to false');
|
677
|
-
this.
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
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);
|
685
692
|
this.lightOnOff?.log.info('Set light initial onOff to false.');
|
686
|
-
await this.dimmer?.setAttribute(
|
687
|
-
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);
|
688
695
|
this.dimmer?.log.info(`Set dimmer initial onOff to false, currentLevel to 1.`);
|
689
|
-
await this.light?.setAttribute(
|
690
|
-
await this.light?.setAttribute(
|
691
|
-
await this.light?.setAttribute(
|
692
|
-
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);
|
693
700
|
await this.light?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
694
701
|
this.light?.log.info('Set light initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
695
|
-
await this.lightXY?.setAttribute(
|
696
|
-
await this.lightXY?.setAttribute(
|
697
|
-
await this.lightXY?.setAttribute(
|
698
|
-
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);
|
699
706
|
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.CurrentXAndCurrentY);
|
700
707
|
this.lightXY?.log.info('Set light XY initial onOff to true, currentLevel to 254, X to 0.7006 and Y to 0.2993.');
|
701
|
-
await this.lightHS?.setAttribute(
|
702
|
-
await this.lightHS?.setAttribute(
|
703
|
-
await this.lightHS?.setAttribute(
|
704
|
-
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);
|
705
712
|
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
706
713
|
this.lightHS?.log.info('Set light HS initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
707
|
-
await this.lightCT?.setAttribute(
|
708
|
-
await this.lightCT?.setAttribute(
|
709
|
-
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);
|
710
717
|
await this.lightCT?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
711
718
|
this.lightCT?.log.info('Set light CT initial onOff to true, currentLevel to 128, colorTemperatureMireds to 250.');
|
712
|
-
this.
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
level
|
717
|
-
|
718
|
-
level
|
719
|
-
|
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
|
-
|
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
|
+
}
|
747
756
|
}
|
748
|
-
}
|
749
|
-
}
|
750
|
-
await this.outlet?.setAttribute(
|
757
|
+
}, 60 * 1000 + 200);
|
758
|
+
}
|
759
|
+
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet.log);
|
751
760
|
this.outlet?.log.info('Set outlet initial onOff to false');
|
752
|
-
this.
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
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
|
+
}
|
759
770
|
await this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
760
771
|
this.cover?.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
761
|
-
this.
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
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);
|
772
785
|
this.lock?.log.info('Set lock initial lockState to Locked');
|
773
|
-
this.
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
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
|
+
}
|
780
795
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'localTemperature', 16 * 100, this.thermoAuto.log);
|
781
796
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'systemMode', Thermostat.SystemMode.Auto, this.thermoAuto.log);
|
782
797
|
this.thermoAuto?.log.info('Set thermostat initial localTemperature to 16°C and mode Auto');
|
783
798
|
const temperature = this.thermoAuto?.getChildEndpointByName('Temperature');
|
784
|
-
await temperature?.setAttribute(
|
799
|
+
await temperature?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 16 * 100, this.thermoAuto?.log);
|
785
800
|
const humidity = this.thermoAuto?.getChildEndpointByName('Humidity');
|
786
801
|
await humidity?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.thermoAuto?.log);
|
787
802
|
const flow = this.thermoAuto?.getChildEndpointByName('Flow');
|
788
|
-
await flow?.setAttribute(
|
803
|
+
await flow?.setAttribute(FlowMeasurement.Cluster.id, 'measuredValue', 10, this.thermoAuto?.log);
|
789
804
|
this.thermoAuto?.log.info('Set thermostat ext temperature to 16°C, ext humidity to 50% and ext valve flow to 10');
|
790
|
-
this.
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
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);
|
813
830
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 2000, this.airConditioner.log);
|
814
|
-
this.
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
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
|
+
}
|
824
843
|
this.fan?.log.info('Set fan initial fanMode to Auto, percentCurrent and percentSetting to 50 and speedCurrent and speedSetting to 50');
|
825
|
-
await this.fan?.setAttribute(
|
826
|
-
await this.fan?.setAttribute(
|
827
|
-
await this.fan?.setAttribute(
|
828
|
-
await this.fan?.setAttribute(
|
829
|
-
await this.fan?.setAttribute(
|
830
|
-
this.
|
831
|
-
|
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
|
-
|
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
|
+
}
|
887
942
|
}
|
888
943
|
async onShutdown(reason) {
|
889
944
|
clearInterval(this.switchInterval);
|
@@ -899,6 +954,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
899
954
|
clearInterval(this.smokeInterval);
|
900
955
|
clearInterval(this.airQualityInterval);
|
901
956
|
clearInterval(this.airConditionerInterval);
|
957
|
+
clearInterval(this.genericSwitchInterval);
|
902
958
|
await super.onShutdown(reason);
|
903
959
|
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
904
960
|
if (this.config.unregisterOnShutdown === true)
|