matterbridge-example-dynamic-platform 1.1.6 → 1.1.7-dev.2

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