matterbridge-example-dynamic-platform 1.1.4 → 1.1.5-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.js +0 -10
- package/dist/platform.js +140 -232
- package/npm-shrinkwrap.json +35 -5
- package/package.json +1 -2
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/platform.d.ts +0 -49
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js.map +0 -1
package/dist/platform.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
import { /* MatterbridgeEndpoint as */ MatterbridgeDevice, MatterbridgeDynamicPlatform } from 'matterbridge';
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airConditioner, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, } from 'matterbridge';
|
3
2
|
import { isValidBoolean, isValidNumber } from 'matterbridge/utils';
|
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
5
|
export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
|
5
6
|
switch;
|
6
7
|
lightOnOff;
|
@@ -40,33 +41,21 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
40
41
|
airConditionerInterval;
|
41
42
|
bridgedDevices = new Map();
|
42
43
|
fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
|
43
|
-
async createMutableDevice(definition, options = {}, debug = false) {
|
44
|
-
let device;
|
45
|
-
if (this.matterbridge.edge === true)
|
46
|
-
device = new MatterbridgeEndpoint(definition, options, debug);
|
47
|
-
else
|
48
|
-
device = new MatterbridgeDevice(definition, options, debug);
|
49
|
-
return device;
|
50
|
-
}
|
51
44
|
constructor(matterbridge, log, config) {
|
52
45
|
super(matterbridge, log, config);
|
53
|
-
|
54
|
-
|
55
|
-
throw new Error(`This plugin requires Matterbridge version >= "1.6.7". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
|
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.`);
|
56
48
|
}
|
57
49
|
this.log.info('Initializing platform:', this.config.name);
|
58
50
|
}
|
59
51
|
async onStart(reason) {
|
60
52
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
61
|
-
|
62
|
-
this.switch = await this.createMutableDevice([onOffSwitch, bridgedNode], { uniqueStorageKey: 'Switch' }, this.config.debug);
|
53
|
+
this.switch = new MatterbridgeEndpoint([onOffSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Switch' }, this.config.debug);
|
63
54
|
this.switch.log.logName = 'Switch';
|
64
55
|
this.switch.createDefaultIdentifyClusterServer();
|
65
56
|
this.switch.createDefaultGroupsClusterServer();
|
66
|
-
this.switch.createDefaultScenesClusterServer();
|
67
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);
|
68
58
|
this.switch.createDefaultOnOffClusterServer();
|
69
|
-
this.switch.addDeviceType(powerSource);
|
70
59
|
this.switch.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
71
60
|
await this.registerDevice(this.switch);
|
72
61
|
this.bridgedDevices.set(this.switch.deviceName ?? '', this.switch);
|
@@ -74,22 +63,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
74
63
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
75
64
|
});
|
76
65
|
this.switch.addCommandHandler('on', async () => {
|
77
|
-
await this.switch?.setAttribute(OnOffCluster.id, 'onOff', true, this.switch.log
|
66
|
+
await this.switch?.setAttribute(OnOffCluster.id, 'onOff', true, this.switch.log);
|
78
67
|
this.switch?.log.info('Command on called');
|
79
68
|
});
|
80
69
|
this.switch.addCommandHandler('off', async () => {
|
81
|
-
await this.switch?.setAttribute(OnOffCluster.id, 'onOff', false, this.switch.log
|
70
|
+
await this.switch?.setAttribute(OnOffCluster.id, 'onOff', false, this.switch.log);
|
82
71
|
this.switch?.log.info('Command off called');
|
83
72
|
});
|
84
|
-
|
85
|
-
this.lightOnOff = await this.createMutableDevice([onOffLight, bridgedNode], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug);
|
73
|
+
this.lightOnOff = new MatterbridgeEndpoint([onOffLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug);
|
86
74
|
this.lightOnOff.log.logName = 'Light (on/off)';
|
87
75
|
this.lightOnOff.createDefaultIdentifyClusterServer();
|
88
76
|
this.lightOnOff.createDefaultGroupsClusterServer();
|
89
|
-
this.lightOnOff.createDefaultScenesClusterServer();
|
90
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);
|
91
78
|
this.lightOnOff.createDefaultOnOffClusterServer();
|
92
|
-
this.lightOnOff.addDeviceType(powerSource);
|
93
79
|
this.lightOnOff.createDefaultPowerSourceWiredClusterServer();
|
94
80
|
await this.registerDevice(this.lightOnOff);
|
95
81
|
this.bridgedDevices.set(this.lightOnOff.deviceName ?? '', this.lightOnOff);
|
@@ -97,23 +83,20 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
97
83
|
this.lightOnOff?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
98
84
|
});
|
99
85
|
this.lightOnOff.addCommandHandler('on', async () => {
|
100
|
-
await this.
|
86
|
+
await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightOnOff?.log);
|
101
87
|
this.lightOnOff?.log.info('Command on called');
|
102
88
|
});
|
103
89
|
this.lightOnOff.addCommandHandler('off', async () => {
|
104
|
-
await this.
|
90
|
+
await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightOnOff?.log);
|
105
91
|
this.lightOnOff?.log.info('Command off called');
|
106
92
|
});
|
107
|
-
|
108
|
-
this.dimmer = await this.createMutableDevice([dimmableLight, bridgedNode], { uniqueStorageKey: 'Dimmer' }, this.config.debug);
|
93
|
+
this.dimmer = new MatterbridgeEndpoint([dimmableLight, bridgedNode, powerSource], { uniqueStorageKey: 'Dimmer' }, this.config.debug);
|
109
94
|
this.dimmer.log.logName = 'Dimmer';
|
110
95
|
this.dimmer.createDefaultIdentifyClusterServer();
|
111
96
|
this.dimmer.createDefaultGroupsClusterServer();
|
112
|
-
this.dimmer.createDefaultScenesClusterServer();
|
113
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);
|
114
98
|
this.dimmer.createDefaultOnOffClusterServer();
|
115
99
|
this.dimmer.createDefaultLevelControlClusterServer();
|
116
|
-
this.dimmer.addDeviceType(powerSource);
|
117
100
|
this.dimmer.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
118
101
|
await this.registerDevice(this.dimmer);
|
119
102
|
this.bridgedDevices.set(this.dimmer.deviceName ?? '', this.dimmer);
|
@@ -121,32 +104,29 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
121
104
|
this.dimmer?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
122
105
|
});
|
123
106
|
this.dimmer.addCommandHandler('on', async () => {
|
124
|
-
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', true, this.dimmer.log
|
107
|
+
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', true, this.dimmer.log);
|
125
108
|
this.dimmer?.log.info('Command on called');
|
126
109
|
});
|
127
110
|
this.dimmer.addCommandHandler('off', async () => {
|
128
|
-
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', false, this.dimmer.log
|
111
|
+
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', false, this.dimmer.log);
|
129
112
|
this.dimmer?.log.info('Command off called');
|
130
113
|
});
|
131
114
|
this.dimmer.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
132
|
-
await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log
|
115
|
+
await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
|
133
116
|
this.dimmer?.log.debug(`Command moveToLevel called request: ${level}`);
|
134
117
|
});
|
135
118
|
this.dimmer.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
136
|
-
await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log
|
119
|
+
await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.dimmer.log);
|
137
120
|
this.dimmer?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
138
121
|
});
|
139
|
-
|
140
|
-
this.light = await this.createMutableDevice([colorTemperatureLight, bridgedNode], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug);
|
122
|
+
this.light = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug);
|
141
123
|
this.light.log.logName = 'Light (XY, HS and CT)';
|
142
124
|
this.light.createDefaultIdentifyClusterServer();
|
143
125
|
this.light.createDefaultGroupsClusterServer();
|
144
|
-
this.light.createDefaultScenesClusterServer();
|
145
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);
|
146
127
|
this.light.createDefaultOnOffClusterServer();
|
147
128
|
this.light.createDefaultLevelControlClusterServer();
|
148
129
|
this.light.createDefaultColorControlClusterServer();
|
149
|
-
this.light.addDeviceType(powerSource);
|
150
130
|
this.light.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
151
131
|
await this.registerDevice(this.light);
|
152
132
|
this.bridgedDevices.set(this.light.deviceName ?? '', this.light);
|
@@ -154,55 +134,51 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
154
134
|
this.light?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
155
135
|
});
|
156
136
|
this.light.addCommandHandler('on', async () => {
|
157
|
-
await this.light?.setAttribute(OnOffCluster.id, 'onOff', true, this.light?.log
|
137
|
+
await this.light?.setAttribute(OnOffCluster.id, 'onOff', true, this.light?.log);
|
158
138
|
this.light?.log.info('Command on called');
|
159
139
|
});
|
160
140
|
this.light.addCommandHandler('off', async () => {
|
161
|
-
await this.light?.setAttribute(OnOffCluster.id, 'onOff', false, this.light?.log
|
141
|
+
await this.light?.setAttribute(OnOffCluster.id, 'onOff', false, this.light?.log);
|
162
142
|
this.light?.log.info('Command off called');
|
163
143
|
});
|
164
144
|
this.light.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
165
|
-
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light?.log
|
145
|
+
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light?.log);
|
166
146
|
this.light?.log.debug(`Command moveToLevel called request: ${level}`);
|
167
147
|
});
|
168
148
|
this.light.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
169
|
-
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light?.log
|
149
|
+
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.light?.log);
|
170
150
|
this.light?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
171
151
|
});
|
172
152
|
this.light.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
173
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentX', colorX, this.light?.log
|
174
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.light?.log
|
153
|
+
await this.light?.setAttribute(ColorControlCluster.id, 'currentX', colorX, this.light?.log);
|
154
|
+
await this.light?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.light?.log);
|
175
155
|
this.light?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
176
156
|
});
|
177
|
-
this.light.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation }
|
178
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.light?.log
|
179
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.light?.log
|
180
|
-
this.light?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}
|
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);
|
160
|
+
this.light?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}`);
|
181
161
|
});
|
182
|
-
this.light.addCommandHandler('moveToHue', async ({ request: { hue }
|
183
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.light?.log
|
184
|
-
this.light?.log.debug(`Command moveToHue called request: hue ${hue}
|
162
|
+
this.light.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
163
|
+
await this.light?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.light?.log);
|
164
|
+
this.light?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
185
165
|
});
|
186
|
-
this.light.addCommandHandler('moveToSaturation', async ({ request: { saturation }
|
187
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.light?.log
|
188
|
-
this.light?.log.debug(`Command moveToSaturation called request: saturation ${saturation}
|
166
|
+
this.light.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
167
|
+
await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.light?.log);
|
168
|
+
this.light?.log.debug(`Command moveToSaturation called request: saturation ${saturation}}`);
|
189
169
|
});
|
190
|
-
this.light.addCommandHandler('moveToColorTemperature', async ({ request
|
191
|
-
await this.light?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds',
|
192
|
-
this.light?.log.debug(`Command moveToColorTemperature called request: ${
|
170
|
+
this.light.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
171
|
+
await this.light?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.light?.log);
|
172
|
+
this.light?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
193
173
|
});
|
194
|
-
|
195
|
-
this.lightHS = await this.createMutableDevice([colorTemperatureLight, bridgedNode], { uniqueStorageKey: 'Light (HS, CT)' }, this.config.debug);
|
174
|
+
this.lightHS = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (HS, CT)' }, this.config.debug);
|
196
175
|
this.lightHS.log.logName = 'Light (HS, CT)';
|
197
176
|
this.lightHS.createDefaultIdentifyClusterServer();
|
198
177
|
this.lightHS.createDefaultGroupsClusterServer();
|
199
|
-
this.lightHS.createDefaultScenesClusterServer();
|
200
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);
|
201
179
|
this.lightHS.createDefaultOnOffClusterServer();
|
202
180
|
this.lightHS.createDefaultLevelControlClusterServer();
|
203
181
|
this.lightHS.createHsColorControlClusterServer();
|
204
|
-
// await this.lightHS.configureColorControlCluster(true, false, false, ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
205
|
-
this.lightHS.addDeviceType(powerSource);
|
206
182
|
this.lightHS.createDefaultPowerSourceWiredClusterServer();
|
207
183
|
await this.registerDevice(this.lightHS);
|
208
184
|
this.bridgedDevices.set(this.lightHS.deviceName ?? '', this.lightHS);
|
@@ -210,49 +186,45 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
210
186
|
this.lightHS?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
211
187
|
});
|
212
188
|
this.lightHS.addCommandHandler('on', async () => {
|
213
|
-
await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightHS?.log
|
189
|
+
await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightHS?.log);
|
214
190
|
this.lightHS?.log.info('Command on called');
|
215
191
|
});
|
216
192
|
this.lightHS.addCommandHandler('off', async () => {
|
217
|
-
await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightHS?.log
|
193
|
+
await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightHS?.log);
|
218
194
|
this.lightHS?.log.info('Command off called');
|
219
195
|
});
|
220
|
-
this.lightHS.addCommandHandler('moveToLevel', async ({ request: { level }
|
221
|
-
await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log
|
222
|
-
this.lightHS?.log.debug(`Command moveToLevel called request: ${level}
|
196
|
+
this.lightHS.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
197
|
+
await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log);
|
198
|
+
this.lightHS?.log.debug(`Command moveToLevel called request: ${level}`);
|
223
199
|
});
|
224
|
-
this.lightHS.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level }
|
225
|
-
await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log
|
226
|
-
this.lightHS?.log.debug(`Command moveToLevelWithOnOff called request: ${level}
|
200
|
+
this.lightHS.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
201
|
+
await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightHS?.log);
|
202
|
+
this.lightHS?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
227
203
|
});
|
228
|
-
this.lightHS.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation }
|
229
|
-
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.lightHS?.log
|
230
|
-
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.lightHS?.log
|
231
|
-
this.lightHS?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}
|
204
|
+
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);
|
207
|
+
this.lightHS?.log.debug(`Command moveToHueAndSaturation called request: hue ${hue} saturation ${saturation}}`);
|
232
208
|
});
|
233
|
-
this.lightHS.addCommandHandler('moveToHue', async ({ request: { hue }
|
234
|
-
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.lightHS?.log
|
235
|
-
this.lightHS?.log.debug(`Command moveToHue called request: hue ${hue}
|
209
|
+
this.lightHS.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
210
|
+
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentHue', hue, this.lightHS?.log);
|
211
|
+
this.lightHS?.log.debug(`Command moveToHue called request: hue ${hue}`);
|
236
212
|
});
|
237
|
-
this.lightHS.addCommandHandler('moveToSaturation', async ({ request: { saturation }
|
238
|
-
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.lightHS?.log
|
239
|
-
this.lightHS?.log.debug(`Command moveToSaturation called request: saturation ${saturation}
|
213
|
+
this.lightHS.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
214
|
+
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', saturation, this.lightHS?.log);
|
215
|
+
this.lightHS?.log.debug(`Command moveToSaturation called request: saturation ${saturation}`);
|
240
216
|
});
|
241
|
-
this.lightHS.addCommandHandler('moveToColorTemperature', async ({ request
|
242
|
-
|
243
|
-
this.light?.log.debug(`Command moveToColorTemperature called request: ${request.colorTemperatureMireds} attributes: ${attributes.colorTemperatureMireds?.getLocal()}`);
|
217
|
+
this.lightHS.addCommandHandler('moveToColorTemperature', async ({ request: colorTemperatureMireds }) => {
|
218
|
+
this.lightHS?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
244
219
|
});
|
245
|
-
|
246
|
-
this.lightXY = await this.createMutableDevice([colorTemperatureLight, bridgedNode], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug);
|
220
|
+
this.lightXY = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug);
|
247
221
|
this.lightXY.log.logName = 'Light (XY, CT)';
|
248
222
|
this.lightXY.createDefaultIdentifyClusterServer();
|
249
223
|
this.lightXY.createDefaultGroupsClusterServer();
|
250
|
-
this.lightXY.createDefaultScenesClusterServer();
|
251
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);
|
252
225
|
this.lightXY.createDefaultOnOffClusterServer();
|
253
226
|
this.lightXY.createDefaultLevelControlClusterServer();
|
254
227
|
this.lightXY.createXyColorControlClusterServer();
|
255
|
-
this.lightXY.addDeviceType(powerSource);
|
256
228
|
this.lightXY.createDefaultPowerSourceWiredClusterServer();
|
257
229
|
await this.registerDevice(this.lightXY);
|
258
230
|
this.bridgedDevices.set(this.lightXY.deviceName ?? '', this.lightXY);
|
@@ -260,42 +232,38 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
260
232
|
this.lightXY?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
261
233
|
});
|
262
234
|
this.lightXY.addCommandHandler('on', async () => {
|
263
|
-
await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightXY?.log
|
235
|
+
await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightXY?.log);
|
264
236
|
this.lightXY?.log.info('Command on called');
|
265
237
|
});
|
266
238
|
this.lightXY.addCommandHandler('off', async () => {
|
267
|
-
await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightXY?.log
|
239
|
+
await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightXY?.log);
|
268
240
|
this.lightXY?.log.info('Command off called');
|
269
241
|
});
|
270
242
|
this.lightXY.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
271
|
-
await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log
|
243
|
+
await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log);
|
272
244
|
this.lightXY?.log.debug(`Command moveToLevel called request: ${level}`);
|
273
245
|
});
|
274
246
|
this.lightXY.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
275
|
-
await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log
|
247
|
+
await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightXY?.log);
|
276
248
|
this.lightXY?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
277
249
|
});
|
278
250
|
this.lightXY.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
279
|
-
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentX', colorX, this.
|
280
|
-
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.
|
251
|
+
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentX', colorX, this.lightXY?.log);
|
252
|
+
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentY', colorY, this.lightXY?.log);
|
281
253
|
this.lightXY?.log.debug(`Command moveToColor called request: X ${colorX / 65536} Y ${colorY / 65536}`);
|
282
254
|
});
|
283
|
-
this.lightXY.addCommandHandler('moveToColorTemperature', async ({ request
|
284
|
-
await this.
|
285
|
-
this.
|
255
|
+
this.lightXY.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
256
|
+
await this.lightXY?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightXY?.log);
|
257
|
+
this.lightXY?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
286
258
|
});
|
287
|
-
|
288
|
-
this.lightCT = await this.createMutableDevice([colorTemperatureLight, bridgedNode], { uniqueStorageKey: 'Light (CT)' }, this.config.debug);
|
259
|
+
this.lightCT = new MatterbridgeEndpoint([colorTemperatureLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (CT)' }, this.config.debug);
|
289
260
|
this.lightCT.log.logName = 'Light (CT)';
|
290
261
|
this.lightCT.createDefaultIdentifyClusterServer();
|
291
262
|
this.lightCT.createDefaultGroupsClusterServer();
|
292
|
-
this.lightCT.createDefaultScenesClusterServer();
|
293
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);
|
294
264
|
this.lightCT.createDefaultOnOffClusterServer();
|
295
265
|
this.lightCT.createDefaultLevelControlClusterServer();
|
296
266
|
this.lightCT.createCtColorControlClusterServer();
|
297
|
-
// await this.lightCT.configureColorControlCluster(false, false, true, ColorControl.ColorMode.ColorTemperatureMireds);
|
298
|
-
this.lightCT.addDeviceType(powerSource);
|
299
267
|
this.lightCT.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
300
268
|
await this.registerDevice(this.lightCT);
|
301
269
|
this.bridgedDevices.set(this.lightCT.deviceName ?? '', this.lightCT);
|
@@ -303,34 +271,31 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
303
271
|
this.lightCT?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
304
272
|
});
|
305
273
|
this.lightCT.addCommandHandler('on', async () => {
|
306
|
-
await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightCT?.log
|
274
|
+
await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightCT?.log);
|
307
275
|
this.lightCT?.log.info('Command on called');
|
308
276
|
});
|
309
277
|
this.lightCT.addCommandHandler('off', async () => {
|
310
|
-
await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightCT?.log
|
278
|
+
await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightCT?.log);
|
311
279
|
this.lightCT?.log.info('Command off called');
|
312
280
|
});
|
313
281
|
this.lightCT.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
314
|
-
await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log
|
282
|
+
await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log);
|
315
283
|
this.lightCT?.log.debug(`Command moveToLevel called request: ${level}`);
|
316
284
|
});
|
317
285
|
this.lightCT.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
318
|
-
await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log
|
286
|
+
await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', level, this.lightCT?.log);
|
319
287
|
this.lightCT?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
320
288
|
});
|
321
|
-
this.lightCT.addCommandHandler('moveToColorTemperature', async ({ request }) => {
|
322
|
-
await this.lightCT?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds',
|
323
|
-
this.lightCT?.log.debug(`Command moveToColorTemperature called request: ${
|
289
|
+
this.lightCT.addCommandHandler('moveToColorTemperature', async ({ request: { colorTemperatureMireds } }) => {
|
290
|
+
await this.lightCT?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightCT?.log);
|
291
|
+
this.lightCT?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
324
292
|
});
|
325
|
-
|
326
|
-
this.outlet = await this.createMutableDevice([onOffOutlet, bridgedNode], { uniqueStorageKey: 'Outlet' }, this.config.debug);
|
293
|
+
this.outlet = new MatterbridgeEndpoint([onOffOutlet, bridgedNode, powerSource], { uniqueStorageKey: 'Outlet' }, this.config.debug);
|
327
294
|
this.outlet.log.logName = 'Outlet';
|
328
295
|
this.outlet.createDefaultIdentifyClusterServer();
|
329
296
|
this.outlet.createDefaultGroupsClusterServer();
|
330
|
-
this.outlet.createDefaultScenesClusterServer();
|
331
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);
|
332
298
|
this.outlet.createDefaultOnOffClusterServer();
|
333
|
-
this.outlet.addDeviceType(powerSource);
|
334
299
|
this.outlet.createDefaultPowerSourceWiredClusterServer();
|
335
300
|
await this.registerDevice(this.outlet);
|
336
301
|
this.bridgedDevices.set(this.outlet.deviceName ?? '', this.outlet);
|
@@ -338,23 +303,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
338
303
|
this.outlet?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
339
304
|
});
|
340
305
|
this.outlet.addCommandHandler('on', async () => {
|
341
|
-
await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', true, this.outlet?.log
|
306
|
+
await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', true, this.outlet?.log);
|
342
307
|
this.outlet?.log.info('Command on called');
|
343
308
|
});
|
344
309
|
this.outlet.addCommandHandler('off', async () => {
|
345
|
-
await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', false, this.outlet?.log
|
310
|
+
await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', false, this.outlet?.log);
|
346
311
|
this.outlet?.log.info('Command off called');
|
347
312
|
});
|
348
|
-
|
349
|
-
// Matter uses 10000 = fully closed 0 = fully opened
|
350
|
-
this.cover = await this.createMutableDevice([coverDevice, bridgedNode], { uniqueStorageKey: 'Cover' }, this.config.debug);
|
313
|
+
this.cover = new MatterbridgeEndpoint([coverDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Cover' }, this.config.debug);
|
351
314
|
this.cover.log.logName = 'Cover';
|
352
315
|
this.cover.createDefaultIdentifyClusterServer();
|
353
316
|
this.cover.createDefaultGroupsClusterServer();
|
354
|
-
this.cover.createDefaultScenesClusterServer();
|
355
317
|
this.cover.createDefaultBridgedDeviceBasicInformationClusterServer('Cover', '0x01020564', 0xfff1, 'Matterbridge', 'Matterbridge Cover', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion);
|
356
318
|
this.cover.createDefaultWindowCoveringClusterServer();
|
357
|
-
this.cover.addDeviceType(powerSource);
|
358
319
|
this.cover.createDefaultPowerSourceRechargeableBatteryClusterServer(86);
|
359
320
|
await this.registerDevice(this.cover);
|
360
321
|
this.bridgedDevices.set(this.cover.deviceName ?? '', this.cover);
|
@@ -380,13 +341,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
380
341
|
await this.cover?.setWindowCoveringCurrentTargetStatus(liftPercent100thsValue, liftPercent100thsValue, WindowCovering.MovementStatus.Stopped);
|
381
342
|
this.cover?.log.info(`Command goToLiftPercentage ${liftPercent100thsValue} called`);
|
382
343
|
});
|
383
|
-
|
384
|
-
this.lock = await this.createMutableDevice([doorLockDevice, bridgedNode], { uniqueStorageKey: 'Lock' }, this.config.debug);
|
344
|
+
this.lock = new MatterbridgeEndpoint([doorLockDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Lock' }, this.config.debug);
|
385
345
|
this.lock.log.logName = 'Lock';
|
386
346
|
this.lock.createDefaultIdentifyClusterServer();
|
387
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);
|
388
348
|
this.lock.createDefaultDoorLockClusterServer();
|
389
|
-
this.lock.addDeviceType(powerSource);
|
390
349
|
this.lock.createDefaultPowerSourceRechargeableBatteryClusterServer(30);
|
391
350
|
await this.registerDevice(this.lock);
|
392
351
|
this.bridgedDevices.set(this.lock.deviceName ?? '', this.lock);
|
@@ -394,29 +353,29 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
394
353
|
this.lock?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
395
354
|
});
|
396
355
|
this.lock.addCommandHandler('lockDoor', async () => {
|
397
|
-
await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Locked, this.lock?.log
|
356
|
+
await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Locked, this.lock?.log);
|
398
357
|
this.lock?.log.info('Command lockDoor called');
|
399
358
|
});
|
400
359
|
this.lock.addCommandHandler('unlockDoor', async () => {
|
401
|
-
await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Unlocked, this.lock?.log
|
360
|
+
await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Unlocked, this.lock?.log);
|
402
361
|
this.lock?.log.info('Command unlockDoor called');
|
403
362
|
});
|
404
|
-
|
405
|
-
this.thermoAuto = await this.createMutableDevice([thermostatDevice, bridgedNode], { uniqueStorageKey: 'Thermostat (AutoMode)' }, this.config.debug);
|
363
|
+
this.thermoAuto = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (AutoMode)' }, this.config.debug);
|
406
364
|
this.thermoAuto.log.logName = 'Thermostat (AutoMode)';
|
407
365
|
this.thermoAuto.createDefaultIdentifyClusterServer();
|
408
366
|
this.thermoAuto.createDefaultGroupsClusterServer();
|
409
|
-
this.thermoAuto.createDefaultScenesClusterServer();
|
410
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);
|
411
368
|
this.thermoAuto.createDefaultThermostatClusterServer(20, 18, 22);
|
412
|
-
this.thermoAuto.addDeviceType(powerSource);
|
413
369
|
this.thermoAuto.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
414
|
-
const flowChild = this.thermoAuto.
|
415
|
-
flowChild.
|
416
|
-
|
417
|
-
tempChild.
|
418
|
-
|
419
|
-
|
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();
|
420
379
|
await this.registerDevice(this.thermoAuto);
|
421
380
|
this.bridgedDevices.set(this.thermoAuto.deviceName ?? '', this.thermoAuto);
|
422
381
|
this.thermoAuto.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
@@ -442,22 +401,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
442
401
|
this.thermoAuto.subscribeAttribute(ThermostatCluster.id, 'systemMode', async (value) => {
|
443
402
|
const lookupSystemMode = ['Off', 'Auto', '', 'Cool', 'Heat', 'EmergencyHeat', 'Precooling', 'FanOnly', 'Dry', 'Sleep'];
|
444
403
|
this.thermoAuto?.log.info('Subscribe systemMode called with:', lookupSystemMode[value]);
|
445
|
-
}, this.thermoAuto.log
|
404
|
+
}, this.thermoAuto.log);
|
446
405
|
this.thermoAuto.subscribeAttribute(ThermostatCluster.id, 'occupiedHeatingSetpoint', async (value) => {
|
447
406
|
this.thermoAuto?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
448
|
-
}, this.thermoAuto.log
|
407
|
+
}, this.thermoAuto.log);
|
449
408
|
this.thermoAuto.subscribeAttribute(ThermostatCluster.id, 'occupiedCoolingSetpoint', async (value) => {
|
450
409
|
this.thermoAuto?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
451
|
-
}, this.thermoAuto.log
|
452
|
-
|
453
|
-
this.thermoHeat = await this.createMutableDevice([thermostatDevice, bridgedNode], { uniqueStorageKey: 'Thermostat (Heat)' }, this.config.debug);
|
410
|
+
}, this.thermoAuto.log);
|
411
|
+
this.thermoHeat = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Heat)' }, this.config.debug);
|
454
412
|
this.thermoHeat.log.logName = 'Thermostat (Heat)';
|
455
413
|
this.thermoHeat.createDefaultIdentifyClusterServer();
|
456
414
|
this.thermoHeat.createDefaultGroupsClusterServer();
|
457
|
-
this.thermoHeat.createDefaultScenesClusterServer();
|
458
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);
|
459
416
|
this.thermoHeat.createDefaultHeatingThermostatClusterServer(20, 18, 5, 35);
|
460
|
-
this.thermoHeat.addDeviceType(powerSource);
|
461
417
|
this.thermoHeat.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
462
418
|
const heatTempIN = this.thermoHeat.addChildDeviceType('TemperatureIN', [temperatureSensor], {
|
463
419
|
tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }],
|
@@ -484,15 +440,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
484
440
|
this.thermoHeat.subscribeAttribute(ThermostatCluster.id, 'occupiedHeatingSetpoint', async (value) => {
|
485
441
|
this.thermoHeat?.log.info('Subscribe occupiedHeatingSetpoint called with:', value / 100);
|
486
442
|
}, this.thermoHeat.log);
|
487
|
-
|
488
|
-
this.thermoCool = await this.createMutableDevice([thermostatDevice, bridgedNode], { uniqueStorageKey: 'Thermostat (Cool)' }, this.config.debug);
|
443
|
+
this.thermoCool = new MatterbridgeEndpoint([thermostatDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Thermostat (Cool)' }, this.config.debug);
|
489
444
|
this.thermoCool.log.logName = 'Thermostat (Cool)';
|
490
445
|
this.thermoCool.createDefaultIdentifyClusterServer();
|
491
446
|
this.thermoCool.createDefaultGroupsClusterServer();
|
492
|
-
this.thermoCool.createDefaultScenesClusterServer();
|
493
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);
|
494
448
|
this.thermoCool.createDefaultCoolingThermostatClusterServer(20, 18, 5, 35);
|
495
|
-
this.thermoCool.addDeviceType(powerSource);
|
496
449
|
this.thermoCool.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
497
450
|
await this.registerDevice(this.thermoCool);
|
498
451
|
this.bridgedDevices.set(this.thermoCool.deviceName ?? '', this.thermoCool);
|
@@ -509,22 +462,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
509
462
|
this.thermoCool.subscribeAttribute(ThermostatCluster.id, 'occupiedCoolingSetpoint', async (value) => {
|
510
463
|
this.thermoCool?.log.info('Subscribe occupiedCoolingSetpoint called with:', value / 100);
|
511
464
|
}, this.thermoCool.log);
|
512
|
-
|
513
|
-
this.airPurifier = await this.createMutableDevice([airPurifier, temperatureSensor, humiditySensor, bridgedNode], { uniqueStorageKey: 'Air purifier' }, this.config.debug);
|
465
|
+
this.airPurifier = new MatterbridgeEndpoint([airPurifier, temperatureSensor, humiditySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air purifier' }, this.config.debug);
|
514
466
|
this.airPurifier.log.logName = 'Air purifier';
|
515
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);
|
516
468
|
this.airPurifier.createDefaultIdentifyClusterServer();
|
517
469
|
this.airPurifier.createDefaultFanControlClusterServer();
|
518
470
|
this.airPurifier.createDefaultTemperatureMeasurementClusterServer(20 * 100);
|
519
471
|
this.airPurifier.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100);
|
520
|
-
this.airPurifier.addDeviceType(powerSource);
|
521
472
|
this.airPurifier.createDefaultPowerSourceWiredClusterServer();
|
522
473
|
await this.registerDevice(this.airPurifier);
|
523
474
|
this.bridgedDevices.set(this.airPurifier.deviceName ?? '', this.airPurifier);
|
524
475
|
this.airPurifier.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
525
476
|
this.airPurifier?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
526
477
|
});
|
527
|
-
// Apple sends Off and High
|
528
478
|
this.airPurifier.subscribeAttribute(FanControlCluster.id, 'fanMode', async (newValue, oldValue) => {
|
529
479
|
this.fan?.log.info(`Fan mode changed from ${this.fanModeLookup[oldValue]} to ${this.fanModeLookup[newValue]}`);
|
530
480
|
if (newValue === FanControl.FanMode.Off) {
|
@@ -551,8 +501,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
551
501
|
if (isValidNumber(newValue, 0, 100))
|
552
502
|
await this.airPurifier?.setAttribute(FanControlCluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
553
503
|
}, this.airPurifier.log);
|
554
|
-
|
555
|
-
this.airConditioner = await this.createMutableDevice([airConditioner, /* fanDevice, temperatureSensor, humiditySensor,*/ bridgedNode], { uniqueStorageKey: 'Air conditioner' }, this.config.debug);
|
504
|
+
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air conditioner' }, this.config.debug);
|
556
505
|
this.airConditioner.log.logName = 'Air conditioner';
|
557
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);
|
558
507
|
this.airConditioner.createDefaultIdentifyClusterServer();
|
@@ -561,18 +510,17 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
561
510
|
this.airConditioner.createDefaultFanControlClusterServer(FanControl.FanMode.Auto);
|
562
511
|
this.airConditioner.createDefaultTemperatureMeasurementClusterServer(20 * 100);
|
563
512
|
this.airConditioner.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100);
|
564
|
-
this.airConditioner.addDeviceType(powerSource);
|
565
513
|
this.airConditioner.createDefaultPowerSourceWiredClusterServer();
|
566
|
-
this.airConditioner.addRequiredClusterServers(
|
514
|
+
this.airConditioner.addRequiredClusterServers();
|
567
515
|
await this.registerDevice(this.airConditioner);
|
568
516
|
this.bridgedDevices.set(this.airConditioner.deviceName ?? '', this.airConditioner);
|
569
517
|
this.airConditioner.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
570
518
|
this.airConditioner?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
571
519
|
});
|
572
520
|
this.airConditioner.addCommandHandler('on', async () => {
|
573
|
-
await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner?.log);
|
574
521
|
this.airConditioner?.log.info('Command on called');
|
575
522
|
await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner?.log);
|
523
|
+
await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner?.log);
|
576
524
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 20 * 100, this.airConditioner?.log);
|
577
525
|
await this.airConditioner?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
|
578
526
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner?.log);
|
@@ -580,22 +528,20 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
580
528
|
await this.airConditioner?.setAttribute(FanControlCluster.id, 'percentSetting', 50, this.airConditioner?.log);
|
581
529
|
});
|
582
530
|
this.airConditioner.addCommandHandler('off', async () => {
|
531
|
+
this.airConditioner?.log.info('Command off called');
|
583
532
|
await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', false, this.airConditioner?.log);
|
584
533
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', null, this.airConditioner?.log);
|
585
534
|
await this.airConditioner?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
|
586
535
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
|
587
536
|
await this.airConditioner?.setAttribute(FanControlCluster.id, 'speedSetting', null, this.airConditioner?.log);
|
588
537
|
await this.airConditioner?.setAttribute(FanControlCluster.id, 'percentSetting', null, this.airConditioner?.log);
|
589
|
-
this.airConditioner?.log.info('Command off called');
|
590
538
|
});
|
591
|
-
|
592
|
-
this.pump = await this.createMutableDevice([pumpDevice, bridgedNode], { uniqueStorageKey: 'Pump' }, this.config.debug);
|
539
|
+
this.pump = new MatterbridgeEndpoint([pumpDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Pump' }, this.config.debug);
|
593
540
|
this.pump.log.logName = 'Pump';
|
594
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);
|
595
542
|
this.pump.createDefaultIdentifyClusterServer();
|
596
543
|
this.pump.createDefaultOnOffClusterServer(true);
|
597
544
|
this.pump.createDefaultPumpConfigurationAndControlClusterServer();
|
598
|
-
this.pump.addDeviceType(powerSource);
|
599
545
|
this.pump.createDefaultPowerSourceWiredClusterServer();
|
600
546
|
await this.registerDevice(this.pump);
|
601
547
|
this.bridgedDevices.set(this.pump.deviceName ?? '', this.pump);
|
@@ -603,31 +549,28 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
603
549
|
this.pump?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
604
550
|
});
|
605
551
|
this.pump.addCommandHandler('on', async () => {
|
606
|
-
await this.pump?.setAttribute(OnOffCluster.id, 'onOff', true, this.pump?.log);
|
607
552
|
this.pump?.log.info('Command on called');
|
553
|
+
await this.pump?.setAttribute(OnOffCluster.id, 'onOff', true, this.pump?.log);
|
608
554
|
});
|
609
555
|
this.pump.addCommandHandler('off', async () => {
|
610
|
-
await this.pump?.setAttribute(OnOffCluster.id, 'onOff', false, this.pump?.log);
|
611
556
|
this.pump?.log.info('Command off called');
|
557
|
+
await this.pump?.setAttribute(OnOffCluster.id, 'onOff', false, this.pump?.log);
|
612
558
|
});
|
613
|
-
|
614
|
-
this.valve = await this.createMutableDevice([waterValve, bridgedNode], { uniqueStorageKey: 'Water valve' }, this.config.debug);
|
559
|
+
this.valve = new MatterbridgeEndpoint([waterValve, bridgedNode, powerSource], { uniqueStorageKey: 'Water valve' }, this.config.debug);
|
615
560
|
this.valve.log.logName = 'Water valve';
|
616
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);
|
617
562
|
this.valve.createDefaultIdentifyClusterServer();
|
618
563
|
this.valve.createDefaultValveConfigurationAndControlClusterServer();
|
619
|
-
this.valve.addDeviceType(powerSource);
|
620
564
|
this.valve.createDefaultPowerSourceWiredClusterServer();
|
621
565
|
await this.registerDevice(this.valve);
|
622
566
|
this.bridgedDevices.set(this.valve.deviceName ?? '', this.valve);
|
623
567
|
this.valve.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
624
568
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
625
569
|
});
|
626
|
-
|
627
|
-
this.fan = await this.createMutableDevice([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug);
|
570
|
+
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug);
|
628
571
|
this.fan.log.logName = 'Fan';
|
629
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);
|
630
|
-
this.fan.
|
573
|
+
this.fan.addRequiredClusterServers();
|
631
574
|
await this.registerDevice(this.fan);
|
632
575
|
this.bridgedDevices.set(this.fan.deviceName ?? '', this.fan);
|
633
576
|
this.fan.subscribeAttribute(FanControlCluster.id, 'fanMode', async (newValue, oldValue) => {
|
@@ -650,7 +593,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
650
593
|
else if (newValue === FanControl.FanMode.Auto) {
|
651
594
|
await this.fan?.setAttribute(FanControlCluster.id, 'percentCurrent', 50, this.fan?.log);
|
652
595
|
}
|
653
|
-
}, this.fan.log
|
596
|
+
}, this.fan.log);
|
654
597
|
this.fan.subscribeAttribute(FanControlCluster.id, 'percentSetting', async (newValue, oldValue) => {
|
655
598
|
this.fan?.log.info(`Percent setting changed from ${oldValue} to ${newValue}`);
|
656
599
|
if (isValidNumber(newValue, 0, 100))
|
@@ -661,45 +604,43 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
661
604
|
if (isValidNumber(newValue, 0, 100))
|
662
605
|
await this.fan?.setAttribute(FanControlCluster.id, 'speedCurrent', newValue, this.fan?.log);
|
663
606
|
}, this.fan.log);
|
664
|
-
|
665
|
-
this.waterLeak = await this.createMutableDevice([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug);
|
607
|
+
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug);
|
666
608
|
this.waterLeak.log.logName = 'Water leak detector';
|
667
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);
|
668
|
-
this.waterLeak.
|
610
|
+
this.waterLeak.addRequiredClusterServers();
|
611
|
+
this.waterLeak.addOptionalClusterServers();
|
669
612
|
await this.registerDevice(this.waterLeak);
|
670
613
|
this.bridgedDevices.set(this.waterLeak.deviceName ?? '', this.waterLeak);
|
671
614
|
await this.waterLeak.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterLeak.log);
|
672
|
-
|
673
|
-
this.waterFreeze = await this.createMutableDevice([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug);
|
615
|
+
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug);
|
674
616
|
this.waterFreeze.log.logName = 'Water freeze detector';
|
675
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);
|
676
|
-
this.waterFreeze.
|
618
|
+
this.waterFreeze.addRequiredClusterServers();
|
619
|
+
this.waterFreeze.addOptionalClusterServers();
|
677
620
|
await this.registerDevice(this.waterFreeze);
|
678
621
|
this.bridgedDevices.set(this.waterFreeze.deviceName ?? '', this.waterFreeze);
|
679
622
|
await this.waterFreeze.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterFreeze.log);
|
680
|
-
|
681
|
-
this.rain = await this.createMutableDevice([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug);
|
623
|
+
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug);
|
682
624
|
this.rain.log.logName = 'Rain sensor';
|
683
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);
|
684
|
-
this.rain.
|
626
|
+
this.rain.createDefaultIdentifyClusterServer();
|
627
|
+
this.rain.createDefaultBooleanStateClusterServer(false);
|
628
|
+
this.rain.createDefaultBooleanStateConfigurationClusterServer();
|
685
629
|
await this.registerDevice(this.rain);
|
686
630
|
this.bridgedDevices.set(this.rain.deviceName ?? '', this.rain);
|
687
|
-
|
688
|
-
/** ********************* Create a smokeCoAlarm device ***********************/
|
689
|
-
this.smoke = await this.createMutableDevice([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug);
|
631
|
+
this.smoke = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug);
|
690
632
|
this.smoke.log.logName = 'Smoke alarm sensor';
|
691
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);
|
692
|
-
this.smoke.
|
634
|
+
this.smoke.createDefaultIdentifyClusterServer();
|
635
|
+
this.smoke.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal);
|
636
|
+
this.smoke.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
693
637
|
await this.registerDevice(this.smoke);
|
694
638
|
this.bridgedDevices.set(this.smoke.deviceName ?? '', this.smoke);
|
695
|
-
|
696
|
-
await this.smoke.setAttribute(SmokeCoAlarmCluster.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
|
697
|
-
await this.smoke.setAttribute(CarbonMonoxideConcentrationMeasurement.Cluster.id, 'measuredValue', 100, this.smoke.log);
|
698
|
-
// Create an airQuality device
|
699
|
-
this.airQuality = await this.createMutableDevice([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug);
|
639
|
+
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug);
|
700
640
|
this.airQuality.log.logName = 'Air quality Sensor';
|
701
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);
|
702
|
-
this.airQuality.
|
642
|
+
this.airQuality.addRequiredClusterServers();
|
643
|
+
this.airQuality.addClusterServers([
|
703
644
|
TemperatureMeasurement.Cluster.id,
|
704
645
|
RelativeHumidityMeasurement.Cluster.id,
|
705
646
|
CarbonMonoxideConcentrationMeasurement.Cluster.id,
|
@@ -732,10 +673,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
732
673
|
async onConfigure() {
|
733
674
|
await super.onConfigure();
|
734
675
|
this.log.info('onConfigure called');
|
735
|
-
// Set switch to off
|
736
676
|
await this.switch?.setAttribute(OnOffCluster.id, 'onOff', false, this.switch.log);
|
737
677
|
this.switch?.log.info('Set switch initial onOff to false');
|
738
|
-
// Toggle switch onOff every minute
|
739
678
|
this.switchInterval = setInterval(async () => {
|
740
679
|
const status = this.switch?.getAttribute(OnOffCluster.id, 'onOff', this.switch.log);
|
741
680
|
if (isValidBoolean(status)) {
|
@@ -743,35 +682,29 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
743
682
|
this.switch?.log.info(`Set switch onOff to ${!status}`);
|
744
683
|
}
|
745
684
|
}, 60 * 1000 + 100);
|
746
|
-
// Set light on/off to off
|
747
685
|
await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightOnOff.log);
|
748
686
|
this.lightOnOff?.log.info('Set light initial onOff to false.');
|
749
|
-
// Set light on/off to off
|
750
687
|
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', false, this.dimmer.log);
|
751
688
|
await this.dimmer?.setAttribute(LevelControlCluster.id, 'currentLevel', 1, this.dimmer.log);
|
752
689
|
this.dimmer?.log.info(`Set dimmer initial onOff to false, currentLevel to 1.`);
|
753
|
-
// Set light to off, level to 0 and hue to 0 and saturation to 50% (pink color)
|
754
690
|
await this.light?.setAttribute(OnOffCluster.id, 'onOff', false, this.light.log);
|
755
|
-
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel',
|
691
|
+
await this.light?.setAttribute(LevelControlCluster.id, 'currentLevel', 200, this.light.log);
|
756
692
|
await this.light?.setAttribute(ColorControlCluster.id, 'currentHue', 0, this.light.log);
|
757
693
|
await this.light?.setAttribute(ColorControlCluster.id, 'currentSaturation', 128, this.light.log);
|
758
694
|
await this.light?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
759
695
|
this.light?.log.info('Set light initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
760
|
-
// Set light XY to true, level to 100% and XY to red
|
761
696
|
await this.lightXY?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightXY.log);
|
762
697
|
await this.lightXY?.setAttribute(LevelControlCluster.id, 'currentLevel', 254, this.lightXY.log);
|
763
698
|
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentX', 0.7006 * 65536, this.lightXY.log);
|
764
699
|
await this.lightXY?.setAttribute(ColorControlCluster.id, 'currentY', 0.2993 * 65536, this.lightXY.log);
|
765
700
|
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.CurrentXAndCurrentY);
|
766
701
|
this.lightXY?.log.info('Set light XY initial onOff to true, currentLevel to 254, X to 0.7006 and Y to 0.2993.');
|
767
|
-
// Set light HS to off, level to 0 and hue to 0 and saturation to 50% (pink color)
|
768
702
|
await this.lightHS?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightHS.log);
|
769
703
|
await this.lightHS?.setAttribute(LevelControlCluster.id, 'currentLevel', 1, this.lightHS.log);
|
770
704
|
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentHue', 0, this.lightHS.log);
|
771
705
|
await this.lightHS?.setAttribute(ColorControlCluster.id, 'currentSaturation', 128, this.lightHS.log);
|
772
706
|
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.CurrentHueAndCurrentSaturation);
|
773
707
|
this.lightHS?.log.info('Set light HS initial onOff to false, currentLevel to 1, hue to 0 and saturation to 50%.');
|
774
|
-
// Set light CT to true, level to 50% and colorTemperatureMireds to 250
|
775
708
|
await this.lightCT?.setAttribute(OnOffCluster.id, 'onOff', true, this.lightCT.log);
|
776
709
|
await this.lightCT?.setAttribute(LevelControlCluster.id, 'currentLevel', 128, this.lightCT.log);
|
777
710
|
await this.lightCT?.setAttribute(ColorControlCluster.id, 'colorTemperatureMireds', 250, this.lightCT.log);
|
@@ -782,7 +715,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
782
715
|
let level = this.light?.getAttribute(LevelControlCluster.id, 'currentLevel', this.light.log);
|
783
716
|
if (isValidBoolean(state) && isValidNumber(level, 0, 254)) {
|
784
717
|
level += 10;
|
785
|
-
if (level >=
|
718
|
+
if (level >= 230) {
|
786
719
|
level = 1;
|
787
720
|
await this.lightOnOff?.setAttribute(OnOffCluster.id, 'onOff', false, this.lightOnOff.log);
|
788
721
|
await this.dimmer?.setAttribute(OnOffCluster.id, 'onOff', false, this.dimmer.log);
|
@@ -814,14 +747,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
814
747
|
this.log.info(`Set lights currentLevel to ${level}`);
|
815
748
|
}
|
816
749
|
}
|
817
|
-
else {
|
818
|
-
this.log.error(`Invalid state ${state} or level ${level}`);
|
819
|
-
}
|
820
750
|
}, 60 * 1000 + 200);
|
821
|
-
// Set outlet to off
|
822
751
|
await this.outlet?.setAttribute(OnOffCluster.id, 'onOff', false, this.outlet.log);
|
823
752
|
this.outlet?.log.info('Set outlet initial onOff to false');
|
824
|
-
// Toggle outlet onOff every minute
|
825
753
|
this.outletInterval = setInterval(async () => {
|
826
754
|
const state = this.outlet?.getAttribute(OnOffCluster.id, 'onOff', this.outlet.log);
|
827
755
|
if (isValidBoolean(state)) {
|
@@ -829,10 +757,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
829
757
|
this.outlet?.log.info(`Set outlet onOff to ${!state}`);
|
830
758
|
}
|
831
759
|
}, 60 * 1000 + 300);
|
832
|
-
// Set cover to target = current position and status to stopped (current position is persisted in the cluster)
|
833
760
|
await this.cover?.setWindowCoveringTargetAsCurrentAndStopped();
|
834
761
|
this.cover?.log.info('Set cover initial targetPositionLiftPercent100ths = currentPositionLiftPercent100ths and operationalStatus to Stopped.');
|
835
|
-
// Increment cover position every minute
|
836
762
|
this.coverInterval = setInterval(async () => {
|
837
763
|
let position = this.cover?.getAttribute(WindowCoveringCluster.id, 'currentPositionLiftPercent100ths', this.cover.log);
|
838
764
|
if (isValidNumber(position, 0, 10000)) {
|
@@ -843,10 +769,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
843
769
|
this.cover?.log.info(`Set cover current and target positionLiftPercent100ths to ${position} and operationalStatus to Stopped`);
|
844
770
|
}
|
845
771
|
}, 60 * 1000 + 400);
|
846
|
-
// Set lock to Locked
|
847
772
|
await this.lock?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Locked, this.lock.log);
|
848
773
|
this.lock?.log.info('Set lock initial lockState to Locked');
|
849
|
-
// Toggle lock every minute
|
850
774
|
this.lockInterval = setInterval(async () => {
|
851
775
|
const status = this.lock?.getAttribute(DoorLockCluster.id, 'lockState', this.lock.log);
|
852
776
|
if (isValidNumber(status, DoorLock.LockState.Locked, DoorLock.LockState.Unlocked)) {
|
@@ -854,18 +778,16 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
854
778
|
this.lock?.log.info(`Set lock lockState to ${status === DoorLock.LockState.Locked ? 'Unlocked' : 'Locked'}`);
|
855
779
|
}
|
856
780
|
}, 60 * 1000 + 500);
|
857
|
-
// Set local to 16°C
|
858
781
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'localTemperature', 16 * 100, this.thermoAuto.log);
|
859
782
|
await this.thermoAuto?.setAttribute(ThermostatCluster.id, 'systemMode', Thermostat.SystemMode.Auto, this.thermoAuto.log);
|
860
783
|
this.thermoAuto?.log.info('Set thermostat initial localTemperature to 16°C and mode Auto');
|
861
784
|
const temperature = this.thermoAuto?.getChildEndpointByName('Temperature');
|
862
|
-
await
|
785
|
+
await temperature?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', 16 * 100, this.thermoAuto?.log);
|
863
786
|
const humidity = this.thermoAuto?.getChildEndpointByName('Humidity');
|
864
|
-
await
|
787
|
+
await humidity?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.thermoAuto?.log);
|
865
788
|
const flow = this.thermoAuto?.getChildEndpointByName('Flow');
|
866
|
-
await
|
789
|
+
await flow?.setAttribute(FlowMeasurementCluster.id, 'measuredValue', 10, this.thermoAuto?.log);
|
867
790
|
this.thermoAuto?.log.info('Set thermostat ext temperature to 16°C, ext humidity to 50% and ext valve flow to 10');
|
868
|
-
// Increment localTemperature every minute
|
869
791
|
this.thermoInterval = setInterval(async () => {
|
870
792
|
let temperature = this.thermoAuto?.getAttribute(ThermostatCluster.id, 'localTemperature', this.thermoAuto.log);
|
871
793
|
if (isValidNumber(temperature, 1600, 2400)) {
|
@@ -877,20 +799,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
877
799
|
const tempOut = this.thermoHeat?.getChildEndpointByName('TemperatureOUT');
|
878
800
|
await tempOut?.setAttribute(TemperatureMeasurementCluster.id, 'measuredValue', temperature - 400, this.thermoHeat?.log);
|
879
801
|
await this.thermoCool?.setAttribute(ThermostatCluster.id, 'localTemperature', temperature, this.thermoCool.log);
|
880
|
-
const temp = this.
|
881
|
-
await
|
882
|
-
const humidity = this.
|
883
|
-
await
|
884
|
-
const flow = this.
|
885
|
-
await
|
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);
|
886
808
|
this.thermoAuto?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
887
809
|
this.thermoHeat?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
888
810
|
this.thermoCool?.log.info(`Set thermostat localTemperature to ${temperature / 100}°C`);
|
889
811
|
}
|
890
812
|
}, 60 * 1000 + 600);
|
891
|
-
// Set airConditioner to on
|
892
813
|
await this.airConditioner?.setAttribute(OnOffCluster.id, 'onOff', true, this.airConditioner.log);
|
893
|
-
|
814
|
+
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 2000, this.airConditioner.log);
|
894
815
|
this.airConditionerInterval = setInterval(async () => {
|
895
816
|
let temperature = this.airConditioner?.getAttribute(ThermostatCluster.id, 'localTemperature', this.airConditioner.log);
|
896
817
|
if (isValidNumber(temperature, 1600, 2400)) {
|
@@ -901,14 +822,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
901
822
|
this.airConditioner?.log.info(`Set airConditioner localTemperature to ${temperature / 100}°C`);
|
902
823
|
}
|
903
824
|
}, 60 * 1000 + 550);
|
904
|
-
// Set fan to auto
|
905
825
|
this.fan?.log.info('Set fan initial fanMode to Auto, percentCurrent and percentSetting to 50 and speedCurrent and speedSetting to 50');
|
906
826
|
await this.fan?.setAttribute(FanControlCluster.id, 'fanMode', FanControl.FanMode.Auto, this.fan.log);
|
907
827
|
await this.fan?.setAttribute(FanControlCluster.id, 'percentCurrent', 50, this.fan.log);
|
908
828
|
await this.fan?.setAttribute(FanControlCluster.id, 'percentSetting', 50, this.fan.log);
|
909
829
|
await this.fan?.setAttribute(FanControlCluster.id, 'speedCurrent', 50, this.fan.log);
|
910
830
|
await this.fan?.setAttribute(FanControlCluster.id, 'speedSetting', 50, this.fan.log);
|
911
|
-
// Increment fan percentCurrent every minute
|
912
831
|
this.fanInterval = setInterval(async () => {
|
913
832
|
const mode = this.fan?.getAttribute(FanControlCluster.id, 'fanMode', this.fan.log);
|
914
833
|
let value = this.fan?.getAttribute(FanControlCluster.id, 'percentCurrent', this.fan.log);
|
@@ -919,9 +838,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
919
838
|
this.fan?.log.info(`Set fan percentCurrent and percentSetting to ${value}`);
|
920
839
|
}
|
921
840
|
}, 60 * 1000 + 700);
|
922
|
-
// Set waterLeak to false
|
923
841
|
await this.waterLeak?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterLeak.log);
|
924
|
-
// Toggle waterLeak every minute
|
925
842
|
this.waterLeakInterval = setInterval(async () => {
|
926
843
|
let value = this.waterLeak?.getAttribute(BooleanStateCluster.id, 'stateValue', this.waterLeak.log);
|
927
844
|
if (isValidBoolean(value)) {
|
@@ -930,9 +847,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
930
847
|
this.waterLeak?.log.info(`Set waterLeak stateValue to ${value}`);
|
931
848
|
}
|
932
849
|
}, 60 * 1000 + 800);
|
933
|
-
// Set waterFreeze to false
|
934
850
|
await this.waterFreeze?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.waterFreeze.log);
|
935
|
-
// Toggle waterFreeze every minute
|
936
851
|
this.waterFreezeInterval = setInterval(async () => {
|
937
852
|
let value = this.waterFreeze?.getAttribute(BooleanStateCluster.id, 'stateValue', this.waterFreeze.log);
|
938
853
|
if (isValidBoolean(value)) {
|
@@ -941,9 +856,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
941
856
|
this.waterFreeze?.log.info(`Set waterFreeze stateValue to ${value}`);
|
942
857
|
}
|
943
858
|
}, 60 * 1000 + 900);
|
944
|
-
// Set rain to false
|
945
859
|
await this.rain?.setAttribute(BooleanStateCluster.id, 'stateValue', false, this.rain.log);
|
946
|
-
// Toggle rain every minute
|
947
860
|
this.rainInterval = setInterval(async () => {
|
948
861
|
let value = this.rain?.getAttribute(BooleanStateCluster.id, 'stateValue', this.rain.log);
|
949
862
|
if (isValidBoolean(value)) {
|
@@ -952,10 +865,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
952
865
|
this.rain?.log.info(`Set rain stateValue to ${value}`);
|
953
866
|
}
|
954
867
|
}, 60 * 1000 + 1000);
|
955
|
-
// Set smoke to Normal
|
956
868
|
await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'smokeState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
|
957
869
|
await this.smoke?.setAttribute(SmokeCoAlarmCluster.id, 'coState', SmokeCoAlarm.AlarmState.Normal, this.smoke.log);
|
958
|
-
// Toggle smoke every minute
|
959
870
|
this.smokeInterval = setInterval(async () => {
|
960
871
|
let value = this.smoke?.getAttribute(SmokeCoAlarmCluster.id, 'smokeState', this.smoke.log);
|
961
872
|
if (isValidNumber(value, SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Critical)) {
|
@@ -965,9 +876,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
965
876
|
this.smoke?.log.info(`Set smoke smokeState and coState to ${value}`);
|
966
877
|
}
|
967
878
|
}, 60 * 1000 + 1100);
|
968
|
-
// Set air quality to Normal
|
969
879
|
this.airQuality?.setAttribute(AirQualityCluster.id, 'airQuality', AirQuality.AirQualityEnum.Good, this.airQuality.log);
|
970
|
-
// Toggle air quality every minute
|
971
880
|
this.airQualityInterval = setInterval(async () => {
|
972
881
|
let value = this.airQuality?.getAttribute(AirQualityCluster.id, 'airQuality', this.airQuality?.log);
|
973
882
|
if (isValidNumber(value, AirQuality.AirQualityEnum.Good, AirQuality.AirQualityEnum.ExtremelyPoor)) {
|
@@ -978,8 +887,6 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
978
887
|
}, 60 * 1000 + 1100);
|
979
888
|
}
|
980
889
|
async onShutdown(reason) {
|
981
|
-
await super.onShutdown(reason);
|
982
|
-
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
983
890
|
clearInterval(this.switchInterval);
|
984
891
|
clearInterval(this.lightInterval);
|
985
892
|
clearInterval(this.outletInterval);
|
@@ -993,8 +900,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
993
900
|
clearInterval(this.smokeInterval);
|
994
901
|
clearInterval(this.airQualityInterval);
|
995
902
|
clearInterval(this.airConditionerInterval);
|
903
|
+
await super.onShutdown(reason);
|
904
|
+
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
996
905
|
if (this.config.unregisterOnShutdown === true)
|
997
906
|
await this.unregisterAllDevices();
|
998
907
|
}
|
999
908
|
}
|
1000
|
-
//# sourceMappingURL=platform.js.map
|