matterbridge 3.0.6-dev-20250611-6f49811 → 3.0.6-dev-20250611-48af719
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/evse.js +22 -18
- package/dist/laundryWasher.js +18 -11
- package/dist/matterbridgeBehaviors.js +180 -308
- package/dist/matterbridgeEndpoint.js +4 -4
- package/dist/matterbridgeEndpointHelpers.js +31 -1
- package/dist/matterbridgePlatform.js +2 -2
- package/dist/roboticVacuumCleaner.js +30 -25
- package/dist/waterHeater.js +18 -14
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/evse.js
CHANGED
|
@@ -15,7 +15,7 @@ export class Evse extends MatterbridgeEndpoint {
|
|
|
15
15
|
.createDefaultPowerTopologyClusterServer()
|
|
16
16
|
.createDefaultElectricalPowerMeasurementClusterServer()
|
|
17
17
|
.createDefaultElectricalEnergyMeasurementClusterServer()
|
|
18
|
-
.
|
|
18
|
+
.createDefaultDeviceEnergyManagementClusterServer(DeviceEnergyManagement.EsaType.Evse, false, DeviceEnergyManagement.EsaState.Online, absMinPower, absMaxPower)
|
|
19
19
|
.createDefaultEnergyEvseClusterServer(state, supplyState, faultState)
|
|
20
20
|
.createDefaultEnergyEvseModeClusterServer(currentMode, supportedModes)
|
|
21
21
|
.addRequiredClusterServers();
|
|
@@ -49,39 +49,43 @@ export class Evse extends MatterbridgeEndpoint {
|
|
|
49
49
|
}
|
|
50
50
|
export class MatterbridgeEnergyEvseServer extends EnergyEvseServer {
|
|
51
51
|
disable() {
|
|
52
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
53
|
-
device.
|
|
54
|
-
device.
|
|
52
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
53
|
+
device.log.info(`Disable charging (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
54
|
+
device.commandHandler.executeHandler('disable', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
55
|
+
device.log.debug(`MatterbridgeEnergyEvseServer disable called`);
|
|
55
56
|
this.state.supplyState = EnergyEvse.SupplyState.Disabled;
|
|
56
57
|
if (this.state.state === EnergyEvse.State.PluggedInCharging) {
|
|
57
58
|
this.state.state = EnergyEvse.State.PluggedInDemand;
|
|
58
59
|
}
|
|
59
60
|
this.state.chargingEnabledUntil = 0;
|
|
60
61
|
}
|
|
61
|
-
enableCharging(
|
|
62
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
63
|
-
device.
|
|
64
|
-
device.
|
|
62
|
+
enableCharging(request) {
|
|
63
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
64
|
+
device.log.info(`EnableCharging (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
65
|
+
device.commandHandler.executeHandler('enableCharging', { request, attributes: this.state, endpoint: this.endpoint });
|
|
66
|
+
device.log.debug(`MatterbridgeEnergyEvseServer enableCharging called`);
|
|
65
67
|
this.state.supplyState = EnergyEvse.SupplyState.ChargingEnabled;
|
|
66
68
|
if (this.state.state === EnergyEvse.State.PluggedInDemand) {
|
|
67
69
|
this.state.state = EnergyEvse.State.PluggedInCharging;
|
|
68
70
|
}
|
|
69
|
-
this.state.chargingEnabledUntil = chargingEnabledUntil;
|
|
70
|
-
this.state.minimumChargeCurrent = minimumChargeCurrent;
|
|
71
|
-
this.state.maximumChargeCurrent = maximumChargeCurrent;
|
|
71
|
+
this.state.chargingEnabledUntil = request.chargingEnabledUntil;
|
|
72
|
+
this.state.minimumChargeCurrent = request.minimumChargeCurrent;
|
|
73
|
+
this.state.maximumChargeCurrent = request.maximumChargeCurrent;
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
export class MatterbridgeEnergyEvseModeServer extends EnergyEvseModeServer {
|
|
75
|
-
changeToMode(
|
|
76
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
77
|
-
|
|
77
|
+
changeToMode(request) {
|
|
78
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
79
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
80
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
81
|
+
const supported = this.state.supportedModes.find((mode) => mode.mode === request.newMode);
|
|
78
82
|
if (!supported) {
|
|
79
|
-
device.log.error(`MatterbridgeEnergyEvseModeServer changeToMode called with unsupported newMode: ${newMode}`);
|
|
83
|
+
device.log.error(`MatterbridgeEnergyEvseModeServer changeToMode called with unsupported newMode: ${request.newMode}`);
|
|
80
84
|
return { status: ModeBase.ModeChangeStatus.UnsupportedMode, statusText: 'Unsupported mode' };
|
|
81
85
|
}
|
|
82
|
-
device.changeToMode
|
|
83
|
-
this.state.currentMode = newMode;
|
|
84
|
-
device.log.
|
|
86
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
87
|
+
this.state.currentMode = request.newMode;
|
|
88
|
+
device.log.debug(`MatterbridgeEnergyEvseModeServer changeToMode called with newMode ${request.newMode} => ${supported.label}`);
|
|
85
89
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
|
86
90
|
}
|
|
87
91
|
}
|
package/dist/laundryWasher.js
CHANGED
|
@@ -64,14 +64,16 @@ export class LaundryWasher extends MatterbridgeEndpoint {
|
|
|
64
64
|
export class MatterbridgeLevelTemperatureControlServer extends TemperatureControlServer.with(TemperatureControl.Feature.TemperatureLevel) {
|
|
65
65
|
initialize() {
|
|
66
66
|
if (this.state.supportedTemperatureLevels.length >= 2) {
|
|
67
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
67
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
68
68
|
device.log.info(`MatterbridgeLevelTemperatureControlServer initialized with selectedTemperatureLevel ${this.state.selectedTemperatureLevel} and supportedTemperatureLevels: ${this.state.supportedTemperatureLevels.join(', ')}`);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
setTemperature(request) {
|
|
72
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
72
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
73
|
+
device.log.info(`SetTemperature (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
74
|
+
device.commandHandler.executeHandler('setTemperature', { request, attributes: this.state, endpoint: this.endpoint });
|
|
73
75
|
if (request.targetTemperatureLevel !== undefined && request.targetTemperatureLevel >= 0 && request.targetTemperatureLevel < this.state.supportedTemperatureLevels.length) {
|
|
74
|
-
device.log.
|
|
76
|
+
device.log.debug(`MatterbridgeLevelTemperatureControlServer: setTemperature called setting selectedTemperatureLevel to ${request.targetTemperatureLevel}: ${this.state.supportedTemperatureLevels[request.targetTemperatureLevel]}`);
|
|
75
77
|
this.state.selectedTemperatureLevel = request.targetTemperatureLevel;
|
|
76
78
|
}
|
|
77
79
|
else {
|
|
@@ -81,13 +83,15 @@ export class MatterbridgeLevelTemperatureControlServer extends TemperatureContro
|
|
|
81
83
|
}
|
|
82
84
|
export class MatterbridgeNumberTemperatureControlServer extends TemperatureControlServer.with(TemperatureControl.Feature.TemperatureNumber, TemperatureControl.Feature.TemperatureStep) {
|
|
83
85
|
initialize() {
|
|
84
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
86
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
85
87
|
device.log.info(`MatterbridgeNumberTemperatureControlServer initialized with temperatureSetpoint ${this.state.temperatureSetpoint} minTemperature ${this.state.minTemperature} maxTemperature ${this.state.maxTemperature} step ${this.state.step}`);
|
|
86
88
|
}
|
|
87
89
|
setTemperature(request) {
|
|
88
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
90
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
91
|
+
device.log.info(`SetTemperature (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
92
|
+
device.commandHandler.executeHandler('setTemperature', { request, attributes: this.state, endpoint: this.endpoint });
|
|
89
93
|
if (request.targetTemperature !== undefined && request.targetTemperature >= this.state.minTemperature && request.targetTemperature <= this.state.maxTemperature) {
|
|
90
|
-
device.log.
|
|
94
|
+
device.log.debug(`MatterbridgeNumberTemperatureControlServer: setTemperature called setting temperatureSetpoint to ${request.targetTemperature}`);
|
|
91
95
|
this.state.temperatureSetpoint = request.targetTemperature;
|
|
92
96
|
}
|
|
93
97
|
else {
|
|
@@ -97,23 +101,26 @@ export class MatterbridgeNumberTemperatureControlServer extends TemperatureContr
|
|
|
97
101
|
}
|
|
98
102
|
export class MatterbridgeLaundryWasherModeServer extends LaundryWasherModeServer {
|
|
99
103
|
initialize() {
|
|
100
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
104
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
101
105
|
device.log.info(`MatterbridgeLaundryWasherModeServer initialized: currentMode is ${this.state.currentMode}`);
|
|
102
106
|
this.reactTo(this.agent.get(MatterbridgeOnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
|
103
107
|
}
|
|
104
108
|
handleOnOffChange(onOff) {
|
|
105
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
109
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
110
|
+
device.log.info(`HandleOnOffChange (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
106
111
|
if (onOff === false) {
|
|
107
112
|
device.log.notice('OnOffServer changed to OFF: setting Dead Front state to Manufacturer Specific');
|
|
108
113
|
this.state.currentMode = 2;
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
changeToMode(request) {
|
|
112
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
117
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
118
|
+
device.log.info(`ChangeToMode (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
119
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
113
120
|
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
|
114
121
|
if (supportedMode) {
|
|
115
|
-
device.
|
|
116
|
-
device.changeToMode
|
|
122
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
123
|
+
device.log.debug(`MatterbridgeLaundryWasherModeServer: changeToMode called with mode ${supportedMode.mode} => ${supportedMode.label}`);
|
|
117
124
|
this.state.currentMode = request.newMode;
|
|
118
125
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
|
119
126
|
}
|
|
@@ -25,423 +25,279 @@ import { SwitchServer } from '@matter/main/behaviors/switch';
|
|
|
25
25
|
import { OperationalStateServer } from '@matter/main/behaviors/operational-state';
|
|
26
26
|
import { ServiceAreaServer } from '@matter/main/behaviors/service-area';
|
|
27
27
|
import { DeviceEnergyManagementModeServer } from '@matter/main/behaviors/device-energy-management-mode';
|
|
28
|
-
export class MatterbridgeServerDevice {
|
|
29
|
-
log;
|
|
30
|
-
commandHandler;
|
|
31
|
-
device;
|
|
32
|
-
endpointId = undefined;
|
|
33
|
-
endpointNumber = undefined;
|
|
34
|
-
constructor(log, commandHandler, device) {
|
|
35
|
-
this.log = log;
|
|
36
|
-
this.commandHandler = commandHandler;
|
|
37
|
-
this.device = device;
|
|
38
|
-
}
|
|
39
|
-
setEndpointId(endpointId) {
|
|
40
|
-
this.endpointId = endpointId;
|
|
41
|
-
}
|
|
42
|
-
setEndpointNumber(endpointNumber) {
|
|
43
|
-
this.endpointNumber = endpointNumber;
|
|
44
|
-
}
|
|
45
|
-
identify({ identifyTime }) {
|
|
46
|
-
this.log.info(`Identifying device for ${identifyTime} seconds`);
|
|
47
|
-
this.commandHandler.executeHandler('identify', { request: { identifyTime }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
48
|
-
}
|
|
49
|
-
triggerEffect({ effectIdentifier, effectVariant }) {
|
|
50
|
-
this.log.info(`Triggering effect ${effectIdentifier} variant ${effectVariant}`);
|
|
51
|
-
this.commandHandler.executeHandler('triggerEffect', { request: { effectIdentifier, effectVariant }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
52
|
-
}
|
|
53
|
-
on() {
|
|
54
|
-
this.log.info(`Switching device on (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
55
|
-
this.commandHandler.executeHandler('on', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
56
|
-
}
|
|
57
|
-
off() {
|
|
58
|
-
this.log.info(`Switching device off (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
59
|
-
this.commandHandler.executeHandler('off', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
60
|
-
}
|
|
61
|
-
toggle() {
|
|
62
|
-
this.log.info(`Toggle device on/off (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
63
|
-
this.commandHandler.executeHandler('toggle', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
64
|
-
}
|
|
65
|
-
moveToLevel({ level, transitionTime, optionsMask, optionsOverride }) {
|
|
66
|
-
this.log.info(`Setting level to ${level} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
67
|
-
this.commandHandler.executeHandler('moveToLevel', { request: { level, transitionTime, optionsMask, optionsOverride }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
68
|
-
}
|
|
69
|
-
moveToLevelWithOnOff({ level, transitionTime, optionsMask, optionsOverride }) {
|
|
70
|
-
this.log.info(`Setting level to ${level} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
71
|
-
this.commandHandler.executeHandler('moveToLevelWithOnOff', { request: { level, transitionTime, optionsMask, optionsOverride }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
72
|
-
}
|
|
73
|
-
moveToHue({ optionsMask, optionsOverride, hue, direction, transitionTime }) {
|
|
74
|
-
this.log.info(`Setting hue to ${hue} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
75
|
-
this.commandHandler.executeHandler('moveToHue', { request: { optionsMask, optionsOverride, hue, direction, transitionTime }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
76
|
-
}
|
|
77
|
-
moveToSaturation({ optionsMask, optionsOverride, saturation, transitionTime }) {
|
|
78
|
-
this.log.info(`Setting saturation to ${saturation} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
79
|
-
this.commandHandler.executeHandler('moveToSaturation', { request: { optionsMask, optionsOverride, saturation, transitionTime }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
80
|
-
}
|
|
81
|
-
moveToHueAndSaturation({ optionsOverride, optionsMask, saturation, hue, transitionTime }) {
|
|
82
|
-
this.log.info(`Setting hue to ${hue} and saturation to ${saturation} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
83
|
-
this.commandHandler.executeHandler('moveToHueAndSaturation', { request: { optionsOverride, optionsMask, saturation, hue, transitionTime }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
84
|
-
}
|
|
85
|
-
moveToColor({ optionsMask, optionsOverride, colorX, colorY, transitionTime }) {
|
|
86
|
-
this.log.info(`Setting color to ${colorX}, ${colorY} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
87
|
-
this.commandHandler.executeHandler('moveToColor', { request: { optionsMask, optionsOverride, colorX, colorY, transitionTime }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
88
|
-
}
|
|
89
|
-
moveToColorTemperature({ optionsOverride, optionsMask, colorTemperatureMireds, transitionTime }) {
|
|
90
|
-
this.log.info(`Setting color temperature to ${colorTemperatureMireds} with transitionTime ${transitionTime} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
91
|
-
this.commandHandler.executeHandler('moveToColorTemperature', {
|
|
92
|
-
request: { optionsOverride, optionsMask, colorTemperatureMireds, transitionTime },
|
|
93
|
-
attributes: {},
|
|
94
|
-
endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId },
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
upOrOpen() {
|
|
98
|
-
this.log.info(`Opening cover (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
99
|
-
this.commandHandler.executeHandler(`upOrOpen`, { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
100
|
-
}
|
|
101
|
-
downOrClose() {
|
|
102
|
-
this.log.info(`Closing cover (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
103
|
-
this.commandHandler.executeHandler(`downOrClose`, { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
104
|
-
}
|
|
105
|
-
stopMotion() {
|
|
106
|
-
this.log.info(`Stopping cover (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
107
|
-
this.commandHandler.executeHandler('stopMotion', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
108
|
-
}
|
|
109
|
-
goToLiftPercentage({ liftPercent100thsValue }) {
|
|
110
|
-
this.log.info(`Setting cover lift percentage to ${liftPercent100thsValue} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
111
|
-
this.commandHandler.executeHandler('goToLiftPercentage', { request: { liftPercent100thsValue }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
112
|
-
}
|
|
113
|
-
goToTiltPercentage({ tiltPercent100thsValue }) {
|
|
114
|
-
this.log.info(`Setting cover tilt percentage to ${tiltPercent100thsValue} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
115
|
-
this.commandHandler.executeHandler('goToTiltPercentage', { request: { tiltPercent100thsValue }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
116
|
-
}
|
|
117
|
-
lockDoor() {
|
|
118
|
-
this.log.info(`Locking door (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
119
|
-
this.commandHandler.executeHandler('lockDoor', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
120
|
-
}
|
|
121
|
-
unlockDoor() {
|
|
122
|
-
this.log.info(`Unlocking door (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
123
|
-
this.commandHandler.executeHandler('unlockDoor', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
124
|
-
}
|
|
125
|
-
step({ direction, wrap, lowestOff }) {
|
|
126
|
-
this.log.info(`Stepping fan with direction ${direction} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
127
|
-
this.commandHandler.executeHandler('step', { request: { direction, wrap, lowestOff }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
128
|
-
}
|
|
129
|
-
setpointRaiseLower({ mode, amount }) {
|
|
130
|
-
this.log.info(`Setting setpoint by ${amount} in mode ${mode} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
131
|
-
this.commandHandler.executeHandler('setpointRaiseLower', { request: { mode, amount }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
132
|
-
}
|
|
133
|
-
open({ openDuration, targetLevel }) {
|
|
134
|
-
this.log.info(`Opening valve to ${targetLevel}% (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
135
|
-
this.commandHandler.executeHandler('open', { request: { openDuration, targetLevel }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
136
|
-
}
|
|
137
|
-
close() {
|
|
138
|
-
this.log.info(`Closing valve (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
139
|
-
this.commandHandler.executeHandler('close', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
140
|
-
}
|
|
141
|
-
changeToMode({ newMode }) {
|
|
142
|
-
this.log.info(`Changing mode to ${newMode} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
143
|
-
this.commandHandler.executeHandler('changeToMode', { request: { newMode }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
144
|
-
}
|
|
145
|
-
selfTestRequest() {
|
|
146
|
-
this.log.info(`Testing SmokeCOAlarm (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
147
|
-
this.commandHandler.executeHandler('selfTestRequest', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
148
|
-
}
|
|
149
|
-
enableDisableAlarm({ alarmsToEnableDisable }) {
|
|
150
|
-
this.log.info(`Enabling/disabling alarm ${alarmsToEnableDisable} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
151
|
-
this.commandHandler.executeHandler('enableDisableAlarm', { request: { alarmsToEnableDisable }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
152
|
-
}
|
|
153
|
-
pause() {
|
|
154
|
-
this.log.info(`Pause (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
155
|
-
this.commandHandler.executeHandler('pause', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
156
|
-
}
|
|
157
|
-
stop() {
|
|
158
|
-
this.log.info(`Stop (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
159
|
-
this.commandHandler.executeHandler('stop', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
160
|
-
}
|
|
161
|
-
start() {
|
|
162
|
-
this.log.info(`Start (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
163
|
-
this.commandHandler.executeHandler('start', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
164
|
-
}
|
|
165
|
-
resume() {
|
|
166
|
-
this.log.info(`Resume (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
167
|
-
this.commandHandler.executeHandler('resume', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
168
|
-
}
|
|
169
|
-
goHome() {
|
|
170
|
-
this.log.info(`GoHome (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
171
|
-
this.commandHandler.executeHandler('goHome', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
172
|
-
}
|
|
173
|
-
selectAreas({ newAreas }) {
|
|
174
|
-
this.log.info(`Selecting areas ${newAreas} (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
175
|
-
this.commandHandler.executeHandler('selectAreas', { request: { newAreas }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
176
|
-
}
|
|
177
|
-
boost({ boostInfo }) {
|
|
178
|
-
this.log.info(`Boost (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
179
|
-
this.commandHandler.executeHandler('boost', { request: { boostInfo }, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
180
|
-
}
|
|
181
|
-
cancelBoost() {
|
|
182
|
-
this.log.info(`Cancel boost (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
183
|
-
this.commandHandler.executeHandler('cancelBoost', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
184
|
-
}
|
|
185
|
-
enableCharging() {
|
|
186
|
-
this.log.info(`EnableCharging (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
187
|
-
this.commandHandler.executeHandler('enableCharging', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
188
|
-
}
|
|
189
|
-
disable() {
|
|
190
|
-
this.log.info(`Disable charging (endpoint ${this.endpointId}.${this.endpointNumber})`);
|
|
191
|
-
this.commandHandler.executeHandler('disable', { request: {}, attributes: {}, endpoint: { number: this.endpointNumber, uniqueStorageKey: this.endpointId } });
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
28
|
export class MatterbridgeServer extends Behavior {
|
|
195
29
|
static id = 'matterbridge';
|
|
196
30
|
initialize() {
|
|
197
|
-
|
|
198
|
-
device?.setEndpointId(this.endpoint.maybeId);
|
|
199
|
-
device?.setEndpointNumber(this.endpoint.maybeNumber);
|
|
31
|
+
this.state.log.debug(`MatterbridgeServer initialized (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
200
32
|
super.initialize();
|
|
201
33
|
}
|
|
202
34
|
}
|
|
203
35
|
(function (MatterbridgeServer) {
|
|
204
36
|
class State {
|
|
205
|
-
|
|
37
|
+
log;
|
|
38
|
+
commandHandler;
|
|
206
39
|
}
|
|
207
40
|
MatterbridgeServer.State = State;
|
|
208
41
|
})(MatterbridgeServer || (MatterbridgeServer = {}));
|
|
209
42
|
export class MatterbridgeIdentifyServer extends IdentifyServer {
|
|
210
|
-
identify(
|
|
211
|
-
const device = this.
|
|
212
|
-
device.
|
|
43
|
+
identify(request) {
|
|
44
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
45
|
+
device.log.info(`Identifying device for ${request.identifyTime} seconds (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
46
|
+
device.commandHandler.executeHandler('identify', { request, attributes: this.state, endpoint: this.endpoint });
|
|
213
47
|
device.log.debug(`MatterbridgeIdentifyServer: identify called`);
|
|
214
|
-
super.identify(
|
|
48
|
+
super.identify(request);
|
|
215
49
|
}
|
|
216
|
-
triggerEffect(
|
|
217
|
-
const device = this.
|
|
218
|
-
device.
|
|
50
|
+
triggerEffect(request) {
|
|
51
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
52
|
+
device.log.info(`Triggering effect ${request.effectIdentifier} variant ${request.effectVariant} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
53
|
+
device.commandHandler.executeHandler('triggerEffect', { request, attributes: this.state, endpoint: this.endpoint });
|
|
219
54
|
device.log.debug(`MatterbridgeIdentifyServer: triggerEffect called`);
|
|
220
|
-
super.triggerEffect(
|
|
55
|
+
super.triggerEffect(request);
|
|
221
56
|
}
|
|
222
57
|
}
|
|
223
58
|
export class MatterbridgeOnOffServer extends OnOffServer {
|
|
224
59
|
on() {
|
|
225
|
-
const device = this.
|
|
226
|
-
device.on();
|
|
60
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
61
|
+
device.log.info(`Switching device on (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
62
|
+
device.commandHandler.executeHandler('on', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
227
63
|
device.log.debug(`MatterbridgeOnOffServer: on called`);
|
|
228
64
|
super.on();
|
|
229
65
|
}
|
|
230
66
|
off() {
|
|
231
|
-
const device = this.
|
|
232
|
-
device.off();
|
|
67
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
68
|
+
device.log.info(`Switching device off (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
69
|
+
device.commandHandler.executeHandler('off', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
233
70
|
device.log.debug(`MatterbridgeOnOffServer: off called`);
|
|
234
71
|
super.off();
|
|
235
72
|
}
|
|
236
73
|
toggle() {
|
|
237
|
-
const device = this.
|
|
238
|
-
device.
|
|
74
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
75
|
+
device.log.info(`Toggle device on/off (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
76
|
+
device.commandHandler.executeHandler('toggle', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
239
77
|
device.log.debug(`MatterbridgeOnOffServer: toggle called`);
|
|
240
78
|
super.toggle();
|
|
241
79
|
}
|
|
242
80
|
}
|
|
243
81
|
export class MatterbridgeLevelControlServer extends LevelControlServer {
|
|
244
|
-
moveToLevel(
|
|
245
|
-
const device = this.
|
|
246
|
-
device.
|
|
82
|
+
moveToLevel(request) {
|
|
83
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
84
|
+
device.log.info(`Setting level to ${request.level} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
85
|
+
device.commandHandler.executeHandler('moveToLevel', { request, attributes: this.state, endpoint: this.endpoint });
|
|
247
86
|
device.log.debug(`MatterbridgeLevelControlServer: moveToLevel called`);
|
|
248
|
-
super.moveToLevel(
|
|
87
|
+
super.moveToLevel(request);
|
|
249
88
|
}
|
|
250
|
-
moveToLevelWithOnOff(
|
|
251
|
-
const device = this.
|
|
252
|
-
device.
|
|
89
|
+
moveToLevelWithOnOff(request) {
|
|
90
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
91
|
+
device.log.info(`Setting level to ${request.level} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
92
|
+
device.commandHandler.executeHandler('moveToLevelWithOnOff', { request, attributes: this.state, endpoint: this.endpoint });
|
|
253
93
|
device.log.debug(`MatterbridgeLevelControlServer: moveToLevelWithOnOff called`);
|
|
254
|
-
super.moveToLevelWithOnOff(
|
|
94
|
+
super.moveToLevelWithOnOff(request);
|
|
255
95
|
}
|
|
256
96
|
}
|
|
257
97
|
export class MatterbridgeColorControlServer extends ColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature) {
|
|
258
|
-
moveToHue(
|
|
259
|
-
const device = this.
|
|
260
|
-
device.
|
|
98
|
+
moveToHue(request) {
|
|
99
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
100
|
+
device.log.info(`Setting hue to ${request.hue} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
101
|
+
device.commandHandler.executeHandler('moveToHue', { request, attributes: this.state, endpoint: this.endpoint });
|
|
261
102
|
device.log.debug(`MatterbridgeColorControlServer: moveToHue called`);
|
|
262
|
-
super.moveToHue(
|
|
103
|
+
super.moveToHue(request);
|
|
263
104
|
}
|
|
264
|
-
moveToSaturation(
|
|
265
|
-
const device = this.
|
|
266
|
-
device.
|
|
105
|
+
moveToSaturation(request) {
|
|
106
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
107
|
+
device.log.info(`Setting saturation to ${request.saturation} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
108
|
+
device.commandHandler.executeHandler('moveToSaturation', { request, attributes: this.state, endpoint: this.endpoint });
|
|
267
109
|
device.log.debug(`MatterbridgeColorControlServer: moveToSaturation called`);
|
|
268
|
-
super.moveToSaturation(
|
|
110
|
+
super.moveToSaturation(request);
|
|
269
111
|
}
|
|
270
|
-
moveToHueAndSaturation(
|
|
271
|
-
const device = this.
|
|
272
|
-
device.
|
|
112
|
+
moveToHueAndSaturation(request) {
|
|
113
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
114
|
+
device.log.info(`Setting hue to ${request.hue} and saturation to ${request.saturation} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
115
|
+
device.commandHandler.executeHandler('moveToHueAndSaturation', { request, attributes: this.state, endpoint: this.endpoint });
|
|
273
116
|
device.log.debug(`MatterbridgeColorControlServer: moveToHueAndSaturation called`);
|
|
274
|
-
super.moveToHueAndSaturation(
|
|
117
|
+
super.moveToHueAndSaturation(request);
|
|
275
118
|
}
|
|
276
|
-
moveToColor(
|
|
277
|
-
const device = this.
|
|
278
|
-
device.
|
|
119
|
+
moveToColor(request) {
|
|
120
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
121
|
+
device.log.info(`Setting color to ${request.colorX}, ${request.colorY} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
122
|
+
device.commandHandler.executeHandler('moveToColor', { request, attributes: this.state, endpoint: this.endpoint });
|
|
279
123
|
device.log.debug(`MatterbridgeColorControlServer: moveToColor called`);
|
|
280
|
-
super.moveToColor(
|
|
124
|
+
super.moveToColor(request);
|
|
281
125
|
}
|
|
282
|
-
moveToColorTemperature(
|
|
283
|
-
const device = this.
|
|
284
|
-
device.
|
|
126
|
+
moveToColorTemperature(request) {
|
|
127
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
128
|
+
device.log.info(`Setting color temperature to ${request.colorTemperatureMireds} with transitionTime ${request.transitionTime} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
129
|
+
device.commandHandler.executeHandler('moveToColorTemperature', { request, attributes: this.state, endpoint: this.endpoint });
|
|
285
130
|
device.log.debug(`MatterbridgeColorControlServer: moveToColorTemperature called`);
|
|
286
|
-
super.moveToColorTemperature(
|
|
131
|
+
super.moveToColorTemperature(request);
|
|
287
132
|
}
|
|
288
133
|
}
|
|
289
134
|
export class MatterbridgeLiftWindowCoveringServer extends WindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift) {
|
|
290
135
|
upOrOpen() {
|
|
291
|
-
const device = this.
|
|
292
|
-
device.
|
|
136
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
137
|
+
device.log.info(`Opening cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
138
|
+
device.commandHandler.executeHandler(`upOrOpen`, { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
293
139
|
device.log.debug(`MatterbridgeWindowCoveringServer: upOrOpen called`);
|
|
294
140
|
super.upOrOpen();
|
|
295
141
|
}
|
|
296
142
|
downOrClose() {
|
|
297
|
-
const device = this.
|
|
298
|
-
device.
|
|
143
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
144
|
+
device.log.info(`Closing cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
145
|
+
device.commandHandler.executeHandler(`downOrClose`, { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
299
146
|
device.log.debug(`MatterbridgeWindowCoveringServer: downOrClose called`);
|
|
300
147
|
super.downOrClose();
|
|
301
148
|
}
|
|
302
149
|
stopMotion() {
|
|
303
|
-
const device = this.
|
|
304
|
-
device.
|
|
150
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
151
|
+
device.log.info(`Stopping cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
152
|
+
device.commandHandler.executeHandler('stopMotion', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
305
153
|
device.log.debug(`MatterbridgeWindowCoveringServer: stopMotion called`);
|
|
306
154
|
super.stopMotion();
|
|
307
155
|
}
|
|
308
|
-
goToLiftPercentage(
|
|
309
|
-
const device = this.
|
|
310
|
-
device.
|
|
311
|
-
device.
|
|
312
|
-
|
|
156
|
+
goToLiftPercentage(request) {
|
|
157
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
158
|
+
device.log.info(`Setting cover lift percentage to ${request.liftPercent100thsValue} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
159
|
+
device.commandHandler.executeHandler('goToLiftPercentage', { request, attributes: this.state, endpoint: this.endpoint });
|
|
160
|
+
device.log.debug(`MatterbridgeWindowCoveringServer: goToLiftPercentage with ${request.liftPercent100thsValue}`);
|
|
161
|
+
super.goToLiftPercentage(request);
|
|
313
162
|
}
|
|
314
163
|
async handleMovement(type, reversed, direction, targetPercent100ths) {
|
|
315
164
|
}
|
|
316
165
|
}
|
|
317
166
|
export class MatterbridgeLiftTiltWindowCoveringServer extends WindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt) {
|
|
318
167
|
upOrOpen() {
|
|
319
|
-
const device = this.
|
|
320
|
-
device.
|
|
168
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
169
|
+
device.log.info(`Opening cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
170
|
+
device.commandHandler.executeHandler(`upOrOpen`, { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
321
171
|
device.log.debug(`MatterbridgeLiftTiltWindowCoveringServer: upOrOpen called`);
|
|
322
172
|
super.upOrOpen();
|
|
323
173
|
}
|
|
324
174
|
downOrClose() {
|
|
325
|
-
const device = this.
|
|
326
|
-
device.
|
|
175
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
176
|
+
device.log.info(`Closing cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
177
|
+
device.commandHandler.executeHandler(`downOrClose`, { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
327
178
|
device.log.debug(`MatterbridgeLiftTiltWindowCoveringServer: downOrClose called`);
|
|
328
179
|
super.downOrClose();
|
|
329
180
|
}
|
|
330
181
|
stopMotion() {
|
|
331
|
-
const device = this.
|
|
332
|
-
device.
|
|
182
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
183
|
+
device.log.info(`Stopping cover (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
184
|
+
device.commandHandler.executeHandler('stopMotion', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
333
185
|
device.log.debug(`MatterbridgeLiftTiltWindowCoveringServer: stopMotion called`);
|
|
334
186
|
super.stopMotion();
|
|
335
187
|
}
|
|
336
|
-
goToLiftPercentage(
|
|
337
|
-
const device = this.
|
|
338
|
-
device.
|
|
339
|
-
device.
|
|
340
|
-
|
|
188
|
+
goToLiftPercentage(request) {
|
|
189
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
190
|
+
device.log.info(`Setting cover lift percentage to ${request.liftPercent100thsValue} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
191
|
+
device.commandHandler.executeHandler('goToLiftPercentage', { request, attributes: this.state, endpoint: this.endpoint });
|
|
192
|
+
device.log.debug(`MatterbridgeLiftTiltWindowCoveringServer: goToLiftPercentage with ${request.liftPercent100thsValue}`);
|
|
193
|
+
super.goToLiftPercentage(request);
|
|
341
194
|
}
|
|
342
|
-
goToTiltPercentage(
|
|
343
|
-
const device = this.
|
|
344
|
-
device.
|
|
345
|
-
device.
|
|
346
|
-
|
|
195
|
+
goToTiltPercentage(request) {
|
|
196
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
197
|
+
device.log.info(`Setting cover tilt percentage to ${request.tiltPercent100thsValue} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
198
|
+
device.commandHandler.executeHandler('goToTiltPercentage', { request, attributes: this.state, endpoint: this.endpoint });
|
|
199
|
+
device.log.debug(`MatterbridgeLiftTiltWindowCoveringServer: goToTiltPercentage with ${request.tiltPercent100thsValue}`);
|
|
200
|
+
super.goToTiltPercentage(request);
|
|
347
201
|
}
|
|
348
202
|
async handleMovement(type, reversed, direction, targetPercent100ths) {
|
|
349
203
|
}
|
|
350
204
|
}
|
|
351
205
|
export class MatterbridgeDoorLockServer extends DoorLockServer {
|
|
352
206
|
lockDoor() {
|
|
353
|
-
const device = this.
|
|
354
|
-
device.
|
|
207
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
208
|
+
device.log.info(`Locking door (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
209
|
+
device.commandHandler.executeHandler('lockDoor', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
355
210
|
device.log.debug(`MatterbridgeDoorLockServer: lockDoor called`);
|
|
356
211
|
super.lockDoor();
|
|
357
212
|
}
|
|
358
213
|
unlockDoor() {
|
|
359
|
-
const device = this.
|
|
360
|
-
device.
|
|
214
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
215
|
+
device.log.info(`Unlocking door (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
216
|
+
device.commandHandler.executeHandler('unlockDoor', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
361
217
|
device.log.debug(`MatterbridgeDoorLockServer: unlockDoor called`);
|
|
362
218
|
super.unlockDoor();
|
|
363
219
|
}
|
|
364
220
|
}
|
|
365
|
-
export class MatterbridgeModeSelectServer extends ModeSelectServer {
|
|
366
|
-
changeToMode({ newMode }) {
|
|
367
|
-
const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
|
|
368
|
-
device.changeToMode({ newMode });
|
|
369
|
-
device.log.debug(`MatterbridgeModeSelectServer: changeToMode called with mode: ${newMode}`);
|
|
370
|
-
super.changeToMode({ newMode });
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
221
|
export class MatterbridgeFanControlServer extends FanControlServer.with(FanControl.Feature.MultiSpeed, FanControl.Feature.Auto, FanControl.Feature.Step) {
|
|
374
|
-
step(
|
|
375
|
-
const device = this.
|
|
376
|
-
device.
|
|
222
|
+
step(request) {
|
|
223
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
224
|
+
device.log.info(`Stepping fan with direction ${request.direction} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
225
|
+
device.commandHandler.executeHandler('step', { request, attributes: this.state, endpoint: this.endpoint });
|
|
377
226
|
const lookupStepDirection = ['Increase', 'Decrease'];
|
|
378
|
-
device.log.debug(`MatterbridgeFanControlServer: step called with direction: ${lookupStepDirection[direction]} wrap: ${wrap} lowestOff: ${lowestOff}`);
|
|
227
|
+
device.log.debug(`MatterbridgeFanControlServer: step called with direction: ${lookupStepDirection[request.direction]} wrap: ${request.wrap} lowestOff: ${request.lowestOff}`);
|
|
379
228
|
device.log.debug(`- current percentCurrent: ${this.state.percentCurrent}`);
|
|
380
|
-
if (direction === FanControl.StepDirection.Increase) {
|
|
381
|
-
if (wrap && this.state.percentCurrent === 100) {
|
|
382
|
-
this.state.percentCurrent = lowestOff ? 0 : 10;
|
|
229
|
+
if (request.direction === FanControl.StepDirection.Increase) {
|
|
230
|
+
if (request.wrap && this.state.percentCurrent === 100) {
|
|
231
|
+
this.state.percentCurrent = request.lowestOff ? 0 : 10;
|
|
383
232
|
}
|
|
384
233
|
else
|
|
385
234
|
this.state.percentCurrent = Math.min(this.state.percentCurrent + 10, 100);
|
|
386
235
|
}
|
|
387
|
-
else if (direction === FanControl.StepDirection.Decrease) {
|
|
388
|
-
if (wrap && this.state.percentCurrent === (lowestOff ? 0 : 10)) {
|
|
236
|
+
else if (request.direction === FanControl.StepDirection.Decrease) {
|
|
237
|
+
if (request.wrap && this.state.percentCurrent === (request.lowestOff ? 0 : 10)) {
|
|
389
238
|
this.state.percentCurrent = 100;
|
|
390
239
|
}
|
|
391
240
|
else
|
|
392
|
-
this.state.percentCurrent = Math.max(this.state.percentCurrent - 10, lowestOff ? 0 : 10);
|
|
241
|
+
this.state.percentCurrent = Math.max(this.state.percentCurrent - 10, request.lowestOff ? 0 : 10);
|
|
393
242
|
}
|
|
394
243
|
device.log.debug('Set percentCurrent to:', this.state.percentCurrent);
|
|
395
244
|
}
|
|
396
245
|
}
|
|
397
246
|
export class MatterbridgeThermostatServer extends ThermostatServer.with(Thermostat.Feature.Cooling, Thermostat.Feature.Heating, Thermostat.Feature.AutoMode) {
|
|
398
|
-
setpointRaiseLower(
|
|
399
|
-
const device = this.
|
|
400
|
-
device.
|
|
247
|
+
setpointRaiseLower(request) {
|
|
248
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
249
|
+
device.log.info(`Setting setpoint by ${request.amount} in mode ${request.mode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
250
|
+
device.commandHandler.executeHandler('setpointRaiseLower', { request, attributes: this.state, endpoint: this.endpoint });
|
|
401
251
|
const lookupSetpointAdjustMode = ['Heat', 'Cool', 'Both'];
|
|
402
|
-
device.log.debug(`MatterbridgeThermostatServer: setpointRaiseLower called with mode: ${lookupSetpointAdjustMode[mode]} amount: ${amount / 10}`);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (
|
|
406
|
-
|
|
252
|
+
device.log.debug(`MatterbridgeThermostatServer: setpointRaiseLower called with mode: ${lookupSetpointAdjustMode[request.mode]} amount: ${request.amount / 10}`);
|
|
253
|
+
if (this.state.occupiedHeatingSetpoint !== undefined)
|
|
254
|
+
device.log.debug(`- current occupiedHeatingSetpoint: ${this.state.occupiedHeatingSetpoint / 100}`);
|
|
255
|
+
if (this.state.occupiedCoolingSetpoint !== undefined)
|
|
256
|
+
device.log.debug(`- current occupiedCoolingSetpoint: ${this.state.occupiedCoolingSetpoint / 100}`);
|
|
257
|
+
if ((request.mode === Thermostat.SetpointRaiseLowerMode.Heat || request.mode === Thermostat.SetpointRaiseLowerMode.Both) && this.state.occupiedHeatingSetpoint !== undefined) {
|
|
258
|
+
const setpoint = this.state.occupiedHeatingSetpoint / 100 + request.amount / 10;
|
|
407
259
|
this.state.occupiedHeatingSetpoint = setpoint * 100;
|
|
408
260
|
device.log.debug(`Set occupiedHeatingSetpoint to ${setpoint}`);
|
|
409
261
|
}
|
|
410
|
-
if ((mode === Thermostat.SetpointRaiseLowerMode.Cool || mode === Thermostat.SetpointRaiseLowerMode.Both) && this.state.occupiedCoolingSetpoint !== undefined) {
|
|
411
|
-
const setpoint = this.state.occupiedCoolingSetpoint / 100 + amount / 10;
|
|
262
|
+
if ((request.mode === Thermostat.SetpointRaiseLowerMode.Cool || request.mode === Thermostat.SetpointRaiseLowerMode.Both) && this.state.occupiedCoolingSetpoint !== undefined) {
|
|
263
|
+
const setpoint = this.state.occupiedCoolingSetpoint / 100 + request.amount / 10;
|
|
412
264
|
this.state.occupiedCoolingSetpoint = setpoint * 100;
|
|
413
265
|
device.log.debug(`Set occupiedCoolingSetpoint to ${setpoint}`);
|
|
414
266
|
}
|
|
415
267
|
}
|
|
416
268
|
}
|
|
417
269
|
export class MatterbridgeValveConfigurationAndControlServer extends ValveConfigurationAndControlServer.with(ValveConfigurationAndControl.Feature.Level) {
|
|
418
|
-
open(
|
|
419
|
-
const device = this.
|
|
420
|
-
device.log.
|
|
421
|
-
device.open
|
|
422
|
-
|
|
423
|
-
this.state.
|
|
270
|
+
open(request) {
|
|
271
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
272
|
+
device.log.info(`Opening valve to ${request.targetLevel}% (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
273
|
+
device.commandHandler.executeHandler('open', { request, attributes: this.state, endpoint: this.endpoint });
|
|
274
|
+
device.log.debug(`MatterbridgeValveConfigurationAndControlServer: open called with openDuration: ${request.openDuration} targetLevel: ${request.targetLevel}`);
|
|
275
|
+
this.state.targetLevel = request.targetLevel ?? 100;
|
|
276
|
+
this.state.currentLevel = request.targetLevel ?? 100;
|
|
424
277
|
}
|
|
425
278
|
close() {
|
|
426
|
-
const device = this.
|
|
279
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
280
|
+
device.log.info(`Closing valve (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
281
|
+
device.commandHandler.executeHandler('close', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
427
282
|
device.log.debug(`MatterbridgeValveConfigurationAndControlServer: close called`);
|
|
428
|
-
device.close();
|
|
429
283
|
this.state.targetLevel = 0;
|
|
430
284
|
this.state.currentLevel = 0;
|
|
431
285
|
}
|
|
432
286
|
}
|
|
433
287
|
export class MatterbridgeSmokeCoAlarmServer extends SmokeCoAlarmServer.with(SmokeCoAlarm.Feature.SmokeAlarm, SmokeCoAlarm.Feature.CoAlarm) {
|
|
434
288
|
selfTestRequest() {
|
|
435
|
-
const device = this.
|
|
289
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
290
|
+
device.log.info(`Testing SmokeCOAlarm (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
291
|
+
device.commandHandler.executeHandler('selfTestRequest', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
436
292
|
device.log.debug(`MatterbridgeSmokeCoAlarmServer: selfTestRequest called`);
|
|
437
|
-
device.selfTestRequest();
|
|
438
293
|
}
|
|
439
294
|
}
|
|
440
295
|
export class MatterbridgeBooleanStateConfigurationServer extends BooleanStateConfigurationServer.with(BooleanStateConfiguration.Feature.Visual, BooleanStateConfiguration.Feature.Audible, BooleanStateConfiguration.Feature.SensitivityLevel) {
|
|
441
|
-
enableDisableAlarm(
|
|
442
|
-
const device = this.
|
|
296
|
+
enableDisableAlarm(request) {
|
|
297
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
298
|
+
device.log.info(`Enabling/disabling alarm ${request.alarmsToEnableDisable} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
299
|
+
device.commandHandler.executeHandler('enableDisableAlarm', { request, attributes: this.state, endpoint: this.endpoint });
|
|
443
300
|
device.log.debug(`MatterbridgeBooleanStateConfigurationServer: enableDisableAlarm called`);
|
|
444
|
-
device.enableDisableAlarm({ alarmsToEnableDisable });
|
|
445
301
|
}
|
|
446
302
|
}
|
|
447
303
|
export class MatterbridgeSwitchServer extends SwitchServer {
|
|
@@ -450,15 +306,17 @@ export class MatterbridgeSwitchServer extends SwitchServer {
|
|
|
450
306
|
}
|
|
451
307
|
export class MatterbridgeOperationalStateServer extends OperationalStateServer {
|
|
452
308
|
initialize() {
|
|
453
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
309
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
454
310
|
device.log.debug('MatterbridgeOperationalStateServer initialized: setting operational state to Stopped');
|
|
455
311
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
|
456
312
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
|
313
|
+
super.initialize();
|
|
457
314
|
}
|
|
458
315
|
pause() {
|
|
459
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
316
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
317
|
+
device.log.info(`Pause (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
318
|
+
device.commandHandler.executeHandler('pause', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
460
319
|
device.log.debug('MatterbridgeOperationalStateServer: pause called setting operational state to Paused');
|
|
461
|
-
device.pause();
|
|
462
320
|
this.state.operationalState = OperationalState.OperationalStateEnum.Paused;
|
|
463
321
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
|
464
322
|
return {
|
|
@@ -466,9 +324,10 @@ export class MatterbridgeOperationalStateServer extends OperationalStateServer {
|
|
|
466
324
|
};
|
|
467
325
|
}
|
|
468
326
|
stop() {
|
|
469
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
327
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
328
|
+
device.log.info(`Stop (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
329
|
+
device.commandHandler.executeHandler('stop', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
470
330
|
device.log.debug('MatterbridgeOperationalStateServer: stop called setting operational state to Stopped');
|
|
471
|
-
device.stop();
|
|
472
331
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
|
473
332
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
|
474
333
|
return {
|
|
@@ -476,9 +335,10 @@ export class MatterbridgeOperationalStateServer extends OperationalStateServer {
|
|
|
476
335
|
};
|
|
477
336
|
}
|
|
478
337
|
start() {
|
|
479
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
338
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
339
|
+
device.log.info(`Start (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
340
|
+
device.commandHandler.executeHandler('start', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
480
341
|
device.log.debug('MatterbridgeOperationalStateServer: start called setting operational state to Running');
|
|
481
|
-
device.start();
|
|
482
342
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
|
483
343
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
|
484
344
|
return {
|
|
@@ -486,9 +346,10 @@ export class MatterbridgeOperationalStateServer extends OperationalStateServer {
|
|
|
486
346
|
};
|
|
487
347
|
}
|
|
488
348
|
resume() {
|
|
489
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
349
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
350
|
+
device.log.info(`Resume (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
351
|
+
device.commandHandler.executeHandler('resume', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
490
352
|
device.log.debug('MatterbridgeOperationalStateServer: resume called setting operational state to Running');
|
|
491
|
-
device.resume();
|
|
492
353
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
|
493
354
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
|
494
355
|
return {
|
|
@@ -497,32 +358,43 @@ export class MatterbridgeOperationalStateServer extends OperationalStateServer {
|
|
|
497
358
|
}
|
|
498
359
|
}
|
|
499
360
|
export class MatterbridgeServiceAreaServer extends ServiceAreaServer {
|
|
500
|
-
selectAreas(
|
|
501
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
502
|
-
for (const area of newAreas) {
|
|
361
|
+
selectAreas(request) {
|
|
362
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
363
|
+
for (const area of request.newAreas) {
|
|
503
364
|
const supportedArea = this.state.supportedAreas.find((supportedArea) => supportedArea.areaId === area);
|
|
504
365
|
if (!supportedArea) {
|
|
505
366
|
device.log.error(`MatterbridgeServiceAreaServer selectAreas called with unsupported area: ${area}`);
|
|
506
367
|
return { status: ServiceArea.SelectAreasStatus.UnsupportedArea, statusText: 'Unsupported areas' };
|
|
507
368
|
}
|
|
508
369
|
}
|
|
509
|
-
device.
|
|
510
|
-
this.state.
|
|
511
|
-
|
|
512
|
-
|
|
370
|
+
device.log.info(`Selecting areas ${request.newAreas} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
371
|
+
device.commandHandler.executeHandler('selectAreas', { request, attributes: this.state, endpoint: this.endpoint });
|
|
372
|
+
this.state.selectedAreas = request.newAreas;
|
|
373
|
+
device.log.debug(`MatterbridgeServiceAreaServer selectAreas called with: ${request.newAreas.map((area) => area.toString()).join(', ')}`);
|
|
374
|
+
return super.selectAreas(request);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
export class MatterbridgeModeSelectServer extends ModeSelectServer {
|
|
378
|
+
changeToMode(request) {
|
|
379
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
380
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
381
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
382
|
+
device.log.debug(`MatterbridgeModeSelectServer: changeToMode called with mode: ${request.newMode}`);
|
|
383
|
+
super.changeToMode(request);
|
|
513
384
|
}
|
|
514
385
|
}
|
|
515
386
|
export class MatterbridgeDeviceEnergyManagementModeServer extends DeviceEnergyManagementModeServer {
|
|
516
|
-
changeToMode(
|
|
517
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
518
|
-
const supported = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
|
387
|
+
changeToMode(request) {
|
|
388
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
389
|
+
const supported = this.state.supportedModes.find((mode) => mode.mode === request.newMode);
|
|
519
390
|
if (!supported) {
|
|
520
|
-
device.log.error(`MatterbridgeDeviceEnergyManagementModeServer changeToMode called with unsupported newMode: ${newMode}`);
|
|
391
|
+
device.log.error(`MatterbridgeDeviceEnergyManagementModeServer changeToMode called with unsupported newMode: ${request.newMode}`);
|
|
521
392
|
return { status: ModeBase.ModeChangeStatus.UnsupportedMode, statusText: 'Unsupported mode' };
|
|
522
393
|
}
|
|
523
|
-
device.
|
|
524
|
-
this.state.
|
|
525
|
-
|
|
526
|
-
|
|
394
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
395
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
396
|
+
this.state.currentMode = request.newMode;
|
|
397
|
+
device.log.debug(`MatterbridgeDeviceEnergyManagementModeServer changeToMode called with newMode ${request.newMode} => ${supported.label}`);
|
|
398
|
+
return super.changeToMode(request);
|
|
527
399
|
}
|
|
528
400
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnsiLogger, CYAN, YELLOW, db, debugStringify, hk, or, zb } from './logger/export.js';
|
|
2
2
|
import { bridgedNode } from './matterbridgeDeviceTypes.js';
|
|
3
3
|
import { isValidNumber, isValidObject, isValidString } from './utils/export.js';
|
|
4
|
-
import { MatterbridgeServer,
|
|
4
|
+
import { MatterbridgeServer, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
5
5
|
import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultOperationalStateClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, invokeBehaviorCommand, triggerEvent, } from './matterbridgeEndpointHelpers.js';
|
|
6
6
|
import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, UINT16_MAX, UINT32_MAX, VendorId } from '@matter/main';
|
|
7
7
|
import { getClusterNameById, MeasurementType } from '@matter/main/types';
|
|
@@ -143,7 +143,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
143
143
|
this.deviceTypes.set(firstDefinition.code, firstDefinition);
|
|
144
144
|
this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
|
|
145
145
|
this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
|
|
146
|
-
this.behaviors.require(MatterbridgeServer, {
|
|
146
|
+
this.behaviors.require(MatterbridgeServer, { log: this.log, commandHandler: this.commandHandler });
|
|
147
147
|
}
|
|
148
148
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
149
149
|
return new MatterbridgeEndpoint(definition, options, debug);
|
|
@@ -1043,7 +1043,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1043
1043
|
});
|
|
1044
1044
|
return this;
|
|
1045
1045
|
}
|
|
1046
|
-
|
|
1046
|
+
createDefaultDeviceEnergyManagementClusterServer(esaType = DeviceEnergyManagement.EsaType.Other, esaCanGenerate = false, esaState = DeviceEnergyManagement.EsaState.Online, absMinPower = 0, absMaxPower = 0) {
|
|
1047
1047
|
this.behaviors.require(DeviceEnergyManagementServer.with(DeviceEnergyManagement.Feature.PowerForecastReporting), {
|
|
1048
1048
|
forecast: null,
|
|
1049
1049
|
esaType,
|
|
@@ -1054,7 +1054,7 @@ export class MatterbridgeEndpoint extends Endpoint {
|
|
|
1054
1054
|
});
|
|
1055
1055
|
return this;
|
|
1056
1056
|
}
|
|
1057
|
-
|
|
1057
|
+
createDefaultDeviceEnergyManagementModeClusterServer(currentMode, supportedModes) {
|
|
1058
1058
|
this.behaviors.require(MatterbridgeDeviceEnergyManagementModeServer, {
|
|
1059
1059
|
supportedModes: supportedModes ?? [
|
|
1060
1060
|
{ label: 'No Energy Management (Forecast reporting only)', mode: 1, modeTags: [{ value: DeviceEnergyManagementMode.ModeTag.NoOptimization }] },
|
|
@@ -42,6 +42,8 @@ import { Pm10ConcentrationMeasurement } from '@matter/main/clusters/pm10-concent
|
|
|
42
42
|
import { RadonConcentrationMeasurement } from '@matter/main/clusters/radon-concentration-measurement';
|
|
43
43
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurement } from '@matter/main/clusters/total-volatile-organic-compounds-concentration-measurement';
|
|
44
44
|
import { OperationalState } from '@matter/main/clusters/operational-state';
|
|
45
|
+
import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
|
|
46
|
+
import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode';
|
|
45
47
|
import { PowerSourceServer } from '@matter/main/behaviors/power-source';
|
|
46
48
|
import { UserLabelServer } from '@matter/main/behaviors/user-label';
|
|
47
49
|
import { FixedLabelServer } from '@matter/main/behaviors/fixed-label';
|
|
@@ -71,10 +73,11 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-
|
|
|
71
73
|
import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
|
|
72
74
|
import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
|
|
73
75
|
import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
|
|
76
|
+
import { DeviceEnergyManagementServer } from '@matter/node/behaviors/device-energy-management';
|
|
74
77
|
import { createHash } from 'node:crypto';
|
|
75
78
|
import { BLUE, CYAN, db, debugStringify, er, hk, or, YELLOW, zb } from 'node-ansi-logger';
|
|
76
79
|
import { deepCopy, deepEqual, isValidArray } from './utils/export.js';
|
|
77
|
-
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, } from './matterbridgeBehaviors.js';
|
|
80
|
+
import { MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeOperationalStateServer, MatterbridgeDeviceEnergyManagementModeServer, } from './matterbridgeBehaviors.js';
|
|
78
81
|
export function capitalizeFirstLetter(name) {
|
|
79
82
|
if (!name)
|
|
80
83
|
return name;
|
|
@@ -204,6 +207,10 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
|
|
|
204
207
|
return RadonConcentrationMeasurementServer.with('NumericMeasurement');
|
|
205
208
|
if (clusterId === TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id)
|
|
206
209
|
return TotalVolatileOrganicCompoundsConcentrationMeasurementServer.with('NumericMeasurement');
|
|
210
|
+
if (clusterId === DeviceEnergyManagement.Cluster.id)
|
|
211
|
+
return DeviceEnergyManagementServer.with('PowerForecastReporting');
|
|
212
|
+
if (clusterId === DeviceEnergyManagementMode.Cluster.id)
|
|
213
|
+
return MatterbridgeDeviceEnergyManagementModeServer;
|
|
207
214
|
return MatterbridgeIdentifyServer;
|
|
208
215
|
}
|
|
209
216
|
export function getBehaviourTypeFromClusterClientId(_clusterId) {
|
|
@@ -240,6 +247,25 @@ export async function invokeBehaviorCommand(endpoint, cluster, command, params)
|
|
|
240
247
|
});
|
|
241
248
|
return true;
|
|
242
249
|
}
|
|
250
|
+
export async function invokeSubscribeHandler(endpoint, cluster, attribute, newValue, oldValue) {
|
|
251
|
+
const event = attribute + '$Changed';
|
|
252
|
+
const clusterName = getBehavior(endpoint, cluster)?.id;
|
|
253
|
+
if (!clusterName) {
|
|
254
|
+
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (endpoint.construction.status !== Lifecycle.Status.Active) {
|
|
258
|
+
endpoint.log.error(`invokeSubscribeHandler ${hk}${clusterName}.${event}${er} error: Endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er} is in the ${BLUE}${endpoint.construction.status}${er} state`);
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
const events = endpoint.events;
|
|
262
|
+
if (!(clusterName in events) || !(event in events[clusterName])) {
|
|
263
|
+
endpoint.log.error(`invokeSubscribeHandler ${hk}${event}${er} error: cluster ${clusterName} not found on endpoint ${or}${endpoint.id}${er}:${or}${endpoint.number}${er}`);
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
await endpoint.act((agent) => agent[clusterName].events[event].emit(newValue, oldValue, { ...agent.context, offline: false }));
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
243
269
|
export function addRequiredClusterServers(endpoint) {
|
|
244
270
|
const requiredServerList = [];
|
|
245
271
|
endpoint.log.debug(`addRequiredClusterServers for ${CYAN}${endpoint.maybeId}${db}`);
|
|
@@ -343,6 +369,10 @@ export function addClusterServers(endpoint, serverList) {
|
|
|
343
369
|
endpoint.createDefaultRadonConcentrationMeasurementClusterServer();
|
|
344
370
|
if (serverList.includes(TotalVolatileOrganicCompoundsConcentrationMeasurement.Cluster.id))
|
|
345
371
|
endpoint.createDefaultTvocMeasurementClusterServer();
|
|
372
|
+
if (serverList.includes(DeviceEnergyManagement.Cluster.id))
|
|
373
|
+
endpoint.createDefaultDeviceEnergyManagementClusterServer();
|
|
374
|
+
if (serverList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
375
|
+
endpoint.createDefaultDeviceEnergyManagementModeClusterServer();
|
|
346
376
|
}
|
|
347
377
|
export async function addFixedLabel(endpoint, label, value) {
|
|
348
378
|
if (!endpoint.hasClusterServer(FixedLabel.Cluster.id)) {
|
|
@@ -137,8 +137,8 @@ export class MatterbridgePlatform {
|
|
|
137
137
|
this.selectEntity.clear();
|
|
138
138
|
await this.saveSelects();
|
|
139
139
|
}
|
|
140
|
-
async clearDeviceSelect(
|
|
141
|
-
this.selectDevice.delete(
|
|
140
|
+
async clearDeviceSelect(serial) {
|
|
141
|
+
this.selectDevice.delete(serial);
|
|
142
142
|
await this.saveSelects();
|
|
143
143
|
}
|
|
144
144
|
setSelectDevice(serial, name, configUrl, icon, entities) {
|
|
@@ -94,49 +94,52 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
export class MatterbridgeRvcRunModeServer extends RvcRunModeServer {
|
|
97
|
-
changeToMode(
|
|
98
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
99
|
-
|
|
97
|
+
changeToMode(request) {
|
|
98
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
99
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
100
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
101
|
+
const supported = this.state.supportedModes.find((mode) => mode.mode === request.newMode);
|
|
100
102
|
if (!supported) {
|
|
101
|
-
device.log.error(`MatterbridgeRvcRunModeServer changeToMode called with unsupported newMode: ${newMode}`);
|
|
103
|
+
device.log.error(`MatterbridgeRvcRunModeServer changeToMode called with unsupported newMode: ${request.newMode}`);
|
|
102
104
|
return { status: ModeBase.ModeChangeStatus.UnsupportedMode, statusText: 'Unsupported mode' };
|
|
103
105
|
}
|
|
104
|
-
|
|
105
|
-
this.state.currentMode = newMode;
|
|
106
|
+
this.state.currentMode = request.newMode;
|
|
106
107
|
if (supported.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Cleaning)) {
|
|
107
|
-
device.log.
|
|
108
|
+
device.log.debug('MatterbridgeRvcRunModeServer changeToMode called with newMode Cleaning => Running');
|
|
108
109
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
|
109
110
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Running' };
|
|
110
111
|
}
|
|
111
112
|
else if (supported.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Idle)) {
|
|
112
|
-
device.log.
|
|
113
|
+
device.log.debug('MatterbridgeRvcRunModeServer changeToMode called with newMode Idle => Docked');
|
|
113
114
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Docked;
|
|
114
115
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Docked' };
|
|
115
116
|
}
|
|
116
|
-
device.log.
|
|
117
|
+
device.log.debug(`MatterbridgeRvcRunModeServer changeToMode called with newMode ${request.newMode} => ${supported.label}`);
|
|
117
118
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
|
118
119
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
export class MatterbridgeRvcCleanModeServer extends RvcCleanModeServer {
|
|
122
|
-
changeToMode(
|
|
123
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
124
|
-
|
|
123
|
+
changeToMode(request) {
|
|
124
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
125
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
126
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
127
|
+
const supported = this.state.supportedModes.find((mode) => mode.mode === request.newMode);
|
|
125
128
|
if (!supported) {
|
|
126
|
-
device.log.error(`MatterbridgeRvcCleanModeServer changeToMode called with unsupported newMode: ${newMode}`);
|
|
129
|
+
device.log.error(`MatterbridgeRvcCleanModeServer changeToMode called with unsupported newMode: ${request.newMode}`);
|
|
127
130
|
return { status: ModeBase.ModeChangeStatus.UnsupportedMode, statusText: 'Unsupported mode' };
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
device.log.info(`MatterbridgeRvcCleanModeServer changeToMode called with newMode ${newMode} => ${supported.label}`);
|
|
132
|
+
this.state.currentMode = request.newMode;
|
|
133
|
+
device.log.debug(`MatterbridgeRvcCleanModeServer changeToMode called with newMode ${request.newMode} => ${supported.label}`);
|
|
132
134
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateServer {
|
|
136
138
|
pause() {
|
|
137
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
138
|
-
device.log.info(
|
|
139
|
-
device.pause
|
|
139
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
140
|
+
device.log.info(`Pause (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
141
|
+
device.commandHandler.executeHandler('pause', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
142
|
+
device.log.debug('MatterbridgeRvcOperationalStateServer: pause called setting operational state to Paused and currentMode to Idle');
|
|
140
143
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
|
|
141
144
|
this.state.operationalState = RvcOperationalState.OperationalState.Paused;
|
|
142
145
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
|
@@ -145,9 +148,10 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
|
|
|
145
148
|
};
|
|
146
149
|
}
|
|
147
150
|
resume() {
|
|
148
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
149
|
-
device.log.info(
|
|
150
|
-
device.resume
|
|
151
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
152
|
+
device.log.info(`Resume (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
153
|
+
device.commandHandler.executeHandler('resume', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
154
|
+
device.log.debug('MatterbridgeRvcOperationalStateServer: resume called setting operational state to Running and currentMode to Cleaning');
|
|
151
155
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2;
|
|
152
156
|
this.state.operationalState = RvcOperationalState.OperationalState.Running;
|
|
153
157
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
|
@@ -156,9 +160,10 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
|
|
|
156
160
|
};
|
|
157
161
|
}
|
|
158
162
|
goHome() {
|
|
159
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
160
|
-
device.log.info(
|
|
161
|
-
device.goHome
|
|
163
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
164
|
+
device.log.info(`GoHome (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
165
|
+
device.commandHandler.executeHandler('goHome', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
166
|
+
device.log.debug('MatterbridgeRvcOperationalStateServer: goHome called setting operational state to Docked and currentMode to Idle');
|
|
162
167
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
|
|
163
168
|
this.state.operationalState = RvcOperationalState.OperationalState.Docked;
|
|
164
169
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
package/dist/waterHeater.js
CHANGED
|
@@ -48,30 +48,34 @@ export class WaterHeater extends MatterbridgeEndpoint {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
export class MatterbridgeWaterHeaterManagementServer extends WaterHeaterManagementServer {
|
|
51
|
-
boost(
|
|
52
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
53
|
-
device.
|
|
54
|
-
device.
|
|
51
|
+
boost(request) {
|
|
52
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
53
|
+
device.log.info(`Boost (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
54
|
+
device.commandHandler.executeHandler('boost', { request, attributes: this.state, endpoint: this.endpoint });
|
|
55
|
+
device.log.debug(`MatterbridgeWaterHeaterManagementServer boost called with: ${JSON.stringify(request)}`);
|
|
55
56
|
this.state.boostState = WaterHeaterManagement.BoostState.Active;
|
|
56
57
|
}
|
|
57
58
|
cancelBoost() {
|
|
58
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
59
|
-
device.
|
|
60
|
-
device.
|
|
59
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
60
|
+
device.log.info(`Cancel boost (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
61
|
+
device.commandHandler.executeHandler('cancelBoost', { request: {}, attributes: this.state, endpoint: this.endpoint });
|
|
62
|
+
device.log.debug(`MatterbridgeWaterHeaterManagementServer cancelBoost called`);
|
|
61
63
|
this.state.boostState = WaterHeaterManagement.BoostState.Inactive;
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
export class MatterbridgeWaterHeaterModeServer extends WaterHeaterModeServer {
|
|
65
|
-
changeToMode(
|
|
66
|
-
const device = this.endpoint.stateOf(MatterbridgeServer)
|
|
67
|
-
|
|
67
|
+
changeToMode(request) {
|
|
68
|
+
const device = this.endpoint.stateOf(MatterbridgeServer);
|
|
69
|
+
device.log.info(`Changing mode to ${request.newMode} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
|
|
70
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
71
|
+
const supported = this.state.supportedModes.find((mode) => mode.mode === request.newMode);
|
|
68
72
|
if (!supported) {
|
|
69
|
-
device.log.error(`MatterbridgeWaterHeaterModeServer changeToMode called with unsupported newMode: ${newMode}`);
|
|
73
|
+
device.log.error(`MatterbridgeWaterHeaterModeServer changeToMode called with unsupported newMode: ${request.newMode}`);
|
|
70
74
|
return { status: ModeBase.ModeChangeStatus.UnsupportedMode, statusText: 'Unsupported mode' };
|
|
71
75
|
}
|
|
72
|
-
device.changeToMode
|
|
73
|
-
this.state.currentMode = newMode;
|
|
74
|
-
device.log.
|
|
76
|
+
device.commandHandler.executeHandler('changeToMode', { request, attributes: this.state, endpoint: this.endpoint });
|
|
77
|
+
this.state.currentMode = request.newMode;
|
|
78
|
+
device.log.debug(`MatterbridgeWaterHeaterModeServer changeToMode called with newMode ${request.newMode} => ${supported.label}`);
|
|
75
79
|
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
|
76
80
|
}
|
|
77
81
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge",
|
|
3
|
-
"version": "3.0.6-dev-20250611-
|
|
3
|
+
"version": "3.0.6-dev-20250611-48af719",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge",
|
|
9
|
-
"version": "3.0.6-dev-20250611-
|
|
9
|
+
"version": "3.0.6-dev-20250611-48af719",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@matter/main": "0.14.0",
|
package/package.json
CHANGED