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 { AirQuality, AirQualityCluster, BooleanStateCluster, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, ColorControl, ColorControlCluster, DoorLock, DoorLockCluster, FanControl, FanControlCluster, FlowMeasurementCluster, FormaldehydeConcentrationMeasurement, LevelControlCluster, NitrogenDioxideConcentrationMeasurement, OnOffCluster, OzoneConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, SmokeCoAlarmCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, WindowCoveringCluster, airConditioner, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, LocationTag, airPurifier, pumpDevice, waterValve, } from 'matterbridge';
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.0')) {
46
- throw new Error(`This plugin requires Matterbridge version >= "2.1.0". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
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.log.logName = 'Switch';
54
- this.switch.createDefaultIdentifyClusterServer();
55
- this.switch.createDefaultGroupsClusterServer();
56
- this.switch.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);
57
- this.switch.createDefaultOnOffClusterServer();
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(OnOffCluster.id, 'onOff', true, this.switch.log);
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(OnOffCluster.id, 'onOff', false, this.switch.log);
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
- this.lightOnOff.log.logName = 'Light (on/off)';
74
- this.lightOnOff.createDefaultIdentifyClusterServer();
75
- this.lightOnOff.createDefaultGroupsClusterServer();
76
- this.lightOnOff.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);
77
- this.lightOnOff.createDefaultOnOffClusterServer();
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(OnOffCluster.id, 'onOff', true, this.lightOnOff?.log);
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(OnOffCluster.id, 'onOff', false, this.lightOnOff?.log);
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.log.logName = 'Dimmer';
94
- this.dimmer.createDefaultIdentifyClusterServer();
95
- this.dimmer.createDefaultGroupsClusterServer();
96
- this.dimmer.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);
97
- this.dimmer.createDefaultOnOffClusterServer();
98
- this.dimmer.createDefaultLevelControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.dimmer.log);
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(OnOffCluster.id, 'onOff', false, this.dimmer.log);
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(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
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(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
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.log.logName = 'Light (XY, HS and CT)';
123
- this.light.createDefaultIdentifyClusterServer();
124
- this.light.createDefaultGroupsClusterServer();
125
- this.light.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);
126
- this.light.createDefaultOnOffClusterServer();
127
- this.light.createDefaultLevelControlClusterServer();
128
- this.light.createDefaultColorControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.light?.log);
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(OnOffCluster.id, 'onOff', false, this.light?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.light?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.light?.log);
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(ColorControlCluster.id, 'currentX', colorX, this.light?.log);
153
- await this.light?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.light?.log);
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(ColorControlCluster.id, 'currentHue', hue, this.light?.log);
158
- await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.light?.log);
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(ColorControlCluster.id, 'currentHue', hue, this.light?.log);
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(ColorControlCluster.id, 'currentSaturation', saturation, this.light?.log);
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(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.light?.log);
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.log.logName = 'Light (HS, CT)';
175
- this.lightHS.createDefaultIdentifyClusterServer();
176
- this.lightHS.createDefaultGroupsClusterServer();
177
- this.lightHS.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
- this.lightHS.createDefaultOnOffClusterServer();
179
- this.lightHS.createDefaultLevelControlClusterServer();
180
- this.lightHS.createHsColorControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.lightHS?.log);
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(OnOffCluster.id, 'onOff', false, this.lightHS?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log);
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(ColorControlCluster.id, 'currentHue', hue, this.lightHS?.log);
205
- await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.lightHS?.log);
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(ColorControlCluster.id, 'currentHue', hue, this.lightHS?.log);
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(ColorControlCluster.id, 'currentSaturation', saturation, this.lightHS?.log);
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.log.logName = 'Light (XY, CT)';
221
- this.lightXY.createDefaultIdentifyClusterServer();
222
- this.lightXY.createDefaultGroupsClusterServer();
223
- this.lightXY.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);
224
- this.lightXY.createDefaultOnOffClusterServer();
225
- this.lightXY.createDefaultLevelControlClusterServer();
226
- this.lightXY.createXyColorControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.lightXY?.log);
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(OnOffCluster.id, 'onOff', false, this.lightXY?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log);
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(ColorControlCluster.id, 'currentX', colorX, this.lightXY?.log);
251
- await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.lightXY?.log);
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(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightXY?.log);
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.log.logName = 'Light (CT)';
260
- this.lightCT.createDefaultIdentifyClusterServer();
261
- this.lightCT.createDefaultGroupsClusterServer();
262
- this.lightCT.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);
263
- this.lightCT.createDefaultOnOffClusterServer();
264
- this.lightCT.createDefaultLevelControlClusterServer();
265
- this.lightCT.createCtColorControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.lightCT?.log);
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(OnOffCluster.id, 'onOff', false, this.lightCT?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log);
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(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log);
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(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightCT?.log);
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.log.logName = 'Outlet';
294
- this.outlet.createDefaultIdentifyClusterServer();
295
- this.outlet.createDefaultGroupsClusterServer();
296
- this.outlet.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);
297
- this.outlet.createDefaultOnOffClusterServer();
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(OnOffCluster.id, 'onOff', true, this.outlet?.log);
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(OnOffCluster.id, 'onOff', false, this.outlet?.log);
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(WindowCoveringCluster.id, 'mode', (newValue, oldValue) => {
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.log.logName = 'Lock';
345
- this.lock.createDefaultIdentifyClusterServer();
346
- this.lock.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);
347
- this.lock.createDefaultDoorLockClusterServer();
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(DoorLockCluster.id, 'lockState', DoorLock.LockState.Locked, this.lock?.log);
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(DoorLockCluster.id, 'lockState', DoorLock.LockState.Unlocked, this.lock?.log);
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.log.logName = 'Thermostat (AutoMode)';
364
- this.thermoAuto.createDefaultIdentifyClusterServer();
365
- this.thermoAuto.createDefaultGroupsClusterServer();
366
- this.thermoAuto.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);
367
- this.thermoAuto.createDefaultThermostatClusterServer(20, 18, 22);
368
- this.thermoAuto.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
369
- const flowChild = this.thermoAuto.addChildDeviceType('Flow', flowSensor);
370
- flowChild.createDefaultFlowMeasurementClusterServer(1 * 10);
371
- flowChild.addRequiredClusterServers();
372
- const tempChild = this.thermoAuto.addChildDeviceType('Temperature', temperatureSensor);
373
- tempChild.createDefaultTemperatureMeasurementClusterServer(21 * 100);
374
- tempChild.addRequiredClusterServers();
375
- const humidityChild = this.thermoAuto.addChildDeviceType('Humidity', humiditySensor);
376
- humidityChild.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100);
377
- humidityChild.addRequiredClusterServers();
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.log.logName = 'Thermostat (Heat)';
412
- this.thermoHeat.createDefaultIdentifyClusterServer();
413
- this.thermoHeat.createDefaultGroupsClusterServer();
414
- this.thermoHeat.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);
415
- this.thermoHeat.createDefaultHeatingThermostatClusterServer(20, 18, 5, 35);
416
- this.thermoHeat.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
417
- const heatTempIN = this.thermoHeat.addChildDeviceType('TemperatureIN', [temperatureSensor], {
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
- heatTempIN.createDefaultIdentifyClusterServer();
421
- heatTempIN.createDefaultTemperatureMeasurementClusterServer(21 * 100);
422
- const heatTempOUT = this.thermoHeat.addChildDeviceType('TemperatureOUT', [temperatureSensor], {
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
- heatTempOUT.createDefaultIdentifyClusterServer();
426
- heatTempOUT.createDefaultTemperatureMeasurementClusterServer(15 * 100);
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
- this.thermoCool.log.logName = 'Thermostat (Cool)';
444
- this.thermoCool.createDefaultIdentifyClusterServer();
445
- this.thermoCool.createDefaultGroupsClusterServer();
446
- this.thermoCool.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);
447
- this.thermoCool.createDefaultCoolingThermostatClusterServer(20, 18, 5, 35);
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.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);
467
- this.airPurifier.createDefaultIdentifyClusterServer();
468
- this.airPurifier.createDefaultFanControlClusterServer();
469
- this.airPurifier.createDefaultTemperatureMeasurementClusterServer(20 * 100);
470
- this.airPurifier.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100);
471
- this.airPurifier.createDefaultPowerSourceWiredClusterServer();
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(FanControlCluster.id, 'fanMode', async (newValue, oldValue) => {
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(FanControlCluster.id, 'percentCurrent', 0, this.airPurifier?.log);
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(FanControlCluster.id, 'percentCurrent', 33, this.airPurifier?.log);
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(FanControlCluster.id, 'percentCurrent', 66, this.airPurifier?.log);
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(FanControlCluster.id, 'percentCurrent', 100, this.airPurifier?.log);
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(FanControlCluster.id, 'percentCurrent', 100, this.airPurifier?.log);
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(FanControlCluster.id, 'percentCurrent', 50, this.airPurifier?.log);
494
+ await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.airPurifier?.log);
496
495
  }
497
496
  }, this.airPurifier.log);
498
- this.airPurifier.subscribeAttribute(FanControlCluster.id, 'percentSetting', async (newValue, oldValue) => {
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(FanControlCluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
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
- this.airConditioner.log.logName = 'Air conditioner';
505
- this.airConditioner.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);
506
- this.airConditioner.createDefaultIdentifyClusterServer();
507
- this.airConditioner.createDeadFrontOnOffClusterServer(true);
508
- this.airConditioner.createDefaultThermostatClusterServer(20, 18, 22);
509
- this.airConditioner.createDefaultFanControlClusterServer(FanControl.FanMode.Auto);
510
- this.airConditioner.createDefaultTemperatureMeasurementClusterServer(20 * 100);
511
- this.airConditioner.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100);
512
- this.airConditioner.createDefaultPowerSourceWiredClusterServer();
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(OnOffCluster.id, 'onOff', true, this.airConditioner?.log);
522
- await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner?.log);
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(TemperatureMeasurementCluster.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
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(FanControlCluster.id, 'speedSetting', 50, this.airConditioner?.log);
527
- await this.airConditioner?.setAttribute(FanControlCluster.id, 'percentSetting', 50, this.airConditioner?.log);
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(OnOffCluster.id, 'onOff', false, this.airConditioner?.log);
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(TemperatureMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
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(FanControlCluster.id, 'speedSetting', null, this.airConditioner?.log);
536
- await this.airConditioner?.setAttribute(FanControlCluster.id, 'percentSetting', null, this.airConditioner?.log);
537
- });
538
- this.pump = new MatterbridgeEndpoint([pumpDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Pump' }, this.config.debug);
539
- this.pump.log.logName = 'Pump';
540
- this.pump.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);
541
- this.pump.createDefaultIdentifyClusterServer();
542
- this.pump.createDefaultOnOffClusterServer(true);
543
- this.pump.createDefaultPumpConfigurationAndControlClusterServer();
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(OnOffCluster.id, 'onOff', true, this.pump?.log);
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(OnOffCluster.id, 'onOff', false, this.pump?.log);
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
- this.fan.log.logName = 'Fan';
571
- this.fan.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);
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(FanControlCluster.id, 'fanMode', async (newValue, oldValue) => {
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(FanControlCluster.id, 'percentCurrent', 0, this.fan?.log);
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(FanControlCluster.id, 'percentCurrent', 33, this.fan?.log);
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(FanControlCluster.id, 'percentCurrent', 66, this.fan?.log);
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(FanControlCluster.id, 'percentCurrent', 100, this.fan?.log);
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(FanControlCluster.id, 'percentCurrent', 100, this.fan?.log);
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(FanControlCluster.id, 'percentCurrent', 50, this.fan?.log);
589
+ await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', 50, this.fan?.log);
594
590
  }
595
591
  }, this.fan.log);
596
- this.fan.subscribeAttribute(FanControlCluster.id, 'percentSetting', async (newValue, oldValue) => {
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(FanControlCluster.id, 'percentCurrent', newValue, this.fan?.log);
595
+ await this.fan?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.fan?.log);
600
596
  }, this.fan.log);
601
- this.fan.subscribeAttribute(FanControlCluster.id, 'speedSetting', async (newValue, oldValue) => {
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(FanControlCluster.id, 'speedCurrent', newValue, this.fan?.log);
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
- this.waterLeak.log.logName = 'Water leak detector';
608
- this.waterLeak.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);
609
- this.waterLeak.addRequiredClusterServers();
610
- this.waterLeak.addOptionalClusterServers();
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(BooleanStateCluster.id, 'stateValue', false, this.waterLeak.log);
614
- this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug);
615
- this.waterFreeze.log.logName = 'Water freeze detector';
616
- this.waterFreeze.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);
617
- this.waterFreeze.addRequiredClusterServers();
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(BooleanStateCluster.id, 'stateValue', false, this.waterFreeze.log);
622
- this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug);
623
- this.rain.log.logName = 'Rain sensor';
624
- this.rain.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);
625
- this.rain.createDefaultIdentifyClusterServer();
626
- this.rain.createDefaultBooleanStateClusterServer(false);
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
- this.smoke.log.logName = 'Smoke alarm sensor';
632
- this.smoke.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);
633
- this.smoke.createDefaultIdentifyClusterServer();
634
- this.smoke.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal);
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
- this.airQuality.log.logName = 'Air quality Sensor';
640
- this.airQuality.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);
641
- this.airQuality.addRequiredClusterServers();
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(OnOffCluster.id, 'onOff', false, this.switch.log);
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.switchInterval = setInterval(async () => {
678
- const status = this.switch?.getAttribute(OnOffCluster.id, 'onOff', this.switch.log);
679
- if (isValidBoolean(status)) {
680
- await this.switch?.setAttribute(OnOffCluster.id, 'onOff', !status, this.switch.log);
681
- this.switch?.log.info(`Set switch onOff to ${!status}`);
682
- }
683
- }, 60 * 1000 + 100);
684
- await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightOnOff.log);
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(OnOffCluster.id, 'onOff', false, this.dimmer.log);
687
- await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', 1, this.dimmer.log);
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(OnOffCluster.id, 'onOff', false, this.light.log);
690
- await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', 1, this.light.log);
691
- await this.light?.setAttribute(ColorControlCluster.id, 'currentHue', 0, this.light.log);
692
- await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', 128, this.light.log);
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(OnOffCluster.id, 'onOff', true, this.lightXY.log);
696
- await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', 254, this.lightXY.log);
697
- await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentX', 0.7006 * 65536, this.lightXY.log);
698
- await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentY', 0.2993 * 65536, this.lightXY.log);
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(OnOffCluster.id, 'onOff', false, this.lightHS.log);
702
- await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', 1, this.lightHS.log);
703
- await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentHue', 0, this.lightHS.log);
704
- await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', 128, this.lightHS.log);
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(OnOffCluster.id, 'onOff', true, this.lightCT.log);
708
- await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', 128, this.lightCT.log);
709
- await this.lightCT?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds', 250, this.lightCT.log);
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.lightInterval = setInterval(async () => {
713
- const state = this.light?.getAttribute(OnOffCluster.id, 'onOff', this.light.log);
714
- let level = this.light?.getAttribute(LevelControlCluster.id, 'currentLevel', this.light.log);
715
- if (isValidBoolean(state) && isValidNumber(level, 0, 254)) {
716
- level += 10;
717
- if (level >= 230) {
718
- level = 1;
719
- await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightOnOff.log);
720
- await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', false, this.dimmer.log);
721
- await this.light?.setAttribute(OnOffCluster.id, 'onOff', false, this.light.log);
722
- await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightXY.log);
723
- await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightHS.log);
724
- await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightCT.log);
725
- this.log.info('Set lights onOff to false');
726
- await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
727
- await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light.log);
728
- await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY.log);
729
- await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS.log);
730
- await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT.log);
731
- this.log.info(`Set lights currentLevel to ${level}`);
732
- }
733
- else {
734
- await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightOnOff?.log);
735
- await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', true, this.dimmer.log);
736
- await this.light?.setAttribute(OnOffCluster.id, 'onOff', true, this.light.log);
737
- await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightXY.log);
738
- await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightHS.log);
739
- await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightCT.log);
740
- this.log.info('Set lights onOff to true');
741
- await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
742
- await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light.log);
743
- await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY.log);
744
- await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS.log);
745
- await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT.log);
746
- this.log.info(`Set lights currentLevel to ${level}`);
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
- }, 60 * 1000 + 200);
750
- await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', false, this.outlet.log);
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.outletInterval = setInterval(async () => {
753
- const state = this.outlet?.getAttribute(OnOffCluster.id, 'onOff', this.outlet.log);
754
- if (isValidBoolean(state)) {
755
- await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', !state, this.outlet.log);
756
- this.outlet?.log.info(`Set outlet onOff to ${!state}`);
757
- }
758
- }, 60 * 1000 + 300);
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.coverInterval = setInterval(async () => {
762
- let position = this.cover?.getAttribute(WindowCoveringCluster.id, 'currentPositionLiftPercent100ths', this.cover.log);
763
- if (isValidNumber(position, 0, 10000)) {
764
- position = position > 9000 ? 0 : position + 1000;
765
- await this.cover?.setAttribute(WindowCoveringCluster.id, 'targetPositionLiftPercent100ths', position, this.cover.log);
766
- await this.cover?.setAttribute(WindowCoveringCluster.id, 'currentPositionLiftPercent100ths', position, this.cover.log);
767
- await this.cover?.setAttribute(WindowCoveringCluster.id, 'operationalStatus', { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped }, this.cover.log);
768
- this.cover?.log.info(`Set cover current and target positionLiftPercent100ths to ${position} and operationalStatus to Stopped`);
769
- }
770
- }, 60 * 1000 + 400);
771
- await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Locked, this.lock.log);
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.lockInterval = setInterval(async () => {
774
- const status = this.lock?.getAttribute(DoorLockCluster.id, 'lockState', this.lock.log);
775
- if (isValidNumber(status, DoorLock.LockState.Locked, DoorLock.LockState.Unlocked)) {
776
- await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', status === DoorLock.LockState.Locked ? DoorLock.LockState.Unlocked : DoorLock.LockState.Locked, this.lock.log);
777
- this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Unlocked' : 'Locked'}`);
778
- }
779
- }, 60 * 1000 + 500);
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(TemperatureMeasurementCluster.id, 'measuredValue', 16 * 100, this.thermoAuto?.log);
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(FlowMeasurementCluster.id, 'measuredValue', 10, this.thermoAuto?.log);
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.thermoInterval = setInterval(async () => {
791
- let temperature = this.thermoAuto?.getAttribute(ThermostatCluster.id, 'localTemperature', this.thermoAuto.log);
792
- if (isValidNumber(temperature, 1600, 2400)) {
793
- temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
794
- await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoAuto.log);
795
- await this.thermoHeat?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoHeat.log);
796
- const tempIn = this.thermoHeat?.getChildEndpointByName('TemperatureIN');
797
- await tempIn?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', temperature - 50, this.thermoHeat?.log);
798
- const tempOut = this.thermoHeat?.getChildEndpointByName('TemperatureOUT');
799
- await tempOut?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', temperature - 400, this.thermoHeat?.log);
800
- await this.thermoCool?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoCool.log);
801
- const temp = this.thermoCool?.getChildEndpointByName('Temperature');
802
- await temp?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', temperature, this.thermoCool?.log);
803
- const humidity = this.thermoCool?.getChildEndpointByName('Humidity');
804
- await humidity?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.thermoCool?.log);
805
- const flow = this.thermoCool?.getChildEndpointByName('Flow');
806
- await flow?.setAttribute(FlowMeasurementCluster.id, 'measuredValue', 10, this.thermoCool?.log);
807
- this.thermoAuto?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
808
- this.thermoHeat?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
809
- this.thermoCool?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
810
- }
811
- }, 60 * 1000 + 600);
812
- await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner.log);
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.airConditionerInterval = setInterval(async () => {
815
- let temperature = this.airConditioner?.getAttribute(ThermostatCluster.id, 'localTemperature', this.airConditioner.log);
816
- if (isValidNumber(temperature, 1600, 2400)) {
817
- temperature = temperature + 100 > 2400 ? 1600 : temperature + 100;
818
- await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.airConditioner.log);
819
- await this.airConditioner?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', temperature, this.airConditioner.log);
820
- await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner.log);
821
- this.airConditioner?.log.info(`Set airConditioner localTemperature to ${temperature / 100}°C`);
822
- }
823
- }, 60 * 1000 + 550);
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(FanControlCluster.id, 'fanMode', FanControl.FanMode.Auto, this.fan.log);
826
- await this.fan?.setAttribute(FanControlCluster.id, 'percentCurrent', 50, this.fan.log);
827
- await this.fan?.setAttribute(FanControlCluster.id, 'percentSetting', 50, this.fan.log);
828
- await this.fan?.setAttribute(FanControlCluster.id, 'speedCurrent', 50, this.fan.log);
829
- await this.fan?.setAttribute(FanControlCluster.id, 'speedSetting', 50, this.fan.log);
830
- this.fanInterval = setInterval(async () => {
831
- const mode = this.fan?.getAttribute(FanControlCluster.id, 'fanMode', this.fan.log);
832
- let value = this.fan?.getAttribute(FanControlCluster.id, 'percentCurrent', this.fan.log);
833
- if (isValidNumber(mode, FanControl.FanMode.Off, FanControl.FanMode.Auto) && mode === FanControl.FanMode.Auto && isValidNumber(value, 0, 100)) {
834
- value = value + 10 >= 100 ? 0 : value + 10;
835
- await this.fan?.setAttribute(FanControlCluster.id, 'percentCurrent', value, this.fan.log);
836
- await this.fan?.setAttribute(FanControlCluster.id, 'percentSetting', value, this.fan.log);
837
- this.fan?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
838
- }
839
- }, 60 * 1000 + 700);
840
- await this.waterLeak?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterLeak.log);
841
- this.waterLeakInterval = setInterval(async () => {
842
- let value = this.waterLeak?.getAttribute(BooleanStateCluster.id, 'stateValue', this.waterLeak.log);
843
- if (isValidBoolean(value)) {
844
- value = !value;
845
- await this.waterLeak?.setAttribute(BooleanStateCluster.id, 'stateValue', value, this.waterLeak.log);
846
- this.waterLeak?.log.info(`Set waterLeak stateValue to ${value}`);
847
- }
848
- }, 60 * 1000 + 800);
849
- await this.waterFreeze?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterFreeze.log);
850
- this.waterFreezeInterval = setInterval(async () => {
851
- let value = this.waterFreeze?.getAttribute(BooleanStateCluster.id, 'stateValue', this.waterFreeze.log);
852
- if (isValidBoolean(value)) {
853
- value = !value;
854
- await this.waterFreeze?.setAttribute(BooleanStateCluster.id, 'stateValue', value, this.waterFreeze.log);
855
- this.waterFreeze?.log.info(`Set waterFreeze stateValue to ${value}`);
856
- }
857
- }, 60 * 1000 + 900);
858
- await this.rain?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.rain.log);
859
- this.rainInterval = setInterval(async () => {
860
- let value = this.rain?.getAttribute(BooleanStateCluster.id, 'stateValue', this.rain.log);
861
- if (isValidBoolean(value)) {
862
- value = !value;
863
- await this.rain?.setAttribute(BooleanStateCluster.id, 'stateValue', value, this.rain.log);
864
- this.rain?.log.info(`Set rain stateValue to ${value}`);
865
- }
866
- }, 60 * 1000 + 1000);
867
- await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'smokeState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
868
- await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
869
- this.smokeInterval = setInterval(async () => {
870
- let value = this.smoke?.getAttribute(SmokeCoAlarmCluster.id, 'smokeState', this.smoke.log);
871
- if (isValidNumber(value, SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Critical)) {
872
- value = value === SmokeCoAlarm.AlarmState.Normal ? SmokeCoAlarm.AlarmState.Critical : SmokeCoAlarm.AlarmState.Normal;
873
- await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'smokeState', value, this.smoke.log);
874
- await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'coState', value, this.smoke.log);
875
- this.smoke?.log.info(`Set smoke smokeState and coState to ${value}`);
876
- }
877
- }, 60 * 1000 + 1100);
878
- this.airQuality?.setAttribute(AirQualityCluster.id, 'airQuality', AirQuality.AirQualityEnum.Good, this.airQuality.log);
879
- this.airQualityInterval = setInterval(async () => {
880
- let value = this.airQuality?.getAttribute(AirQualityCluster.id, 'airQuality', this.airQuality?.log);
881
- if (isValidNumber(value, AirQuality.AirQualityEnum.Good, AirQuality.AirQualityEnum.ExtremelyPoor)) {
882
- value = value >= AirQuality.AirQualityEnum.ExtremelyPoor ? AirQuality.AirQualityEnum.Good : value + 1;
883
- await this.airQuality?.setAttribute(AirQualityCluster.id, 'airQuality', value, this.airQuality.log);
884
- this.airQuality?.log.info(`Set air quality to ${value}`);
885
- }
886
- }, 60 * 1000 + 1100);
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)