Skip to content

Commit

Permalink
Eve room
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Mar 13, 2024
1 parent 22deb30 commit 25f4f1c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/matterBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ export class Matterbridge {
this.log.debug(`***Commissioning changed on fabric ${fabricIndex} for ${plg}${name}${nf}`, debugStringify(info));
if (info.length === 0) {
this.log.warn(`***Commissioning removed from fabric ${fabricIndex} for ${plg}${name}${nf}. Resetting the commissioning server ...`);
commissioningServer.factoryReset();
commissioningServer.factoryReset(); // TODO delete from storage also "matterbridge-eve-weather.EndpointStructure"
}
},
});
Expand Down
25 changes: 21 additions & 4 deletions src/matterbridgeDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,19 @@ export const airQualitySensor = DeviceTypeDefinition({

export interface SerializedMatterbridgeDevice {
pluginName: string;
serialNumber: string;
deviceName: string;
uniqueId: string;
deviceType: AtLeastOne<DeviceTypeDefinition>;
name: string;
endpointName: string;
clusterServersId: ClusterId[];
}

export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device, MatterbridgeDeviceCommands>(Device) {
public static bridgeMode = '';
private serialNumber: string | undefined = undefined;
serialNumber: string | undefined = undefined;
deviceName: string | undefined = undefined;
uniqueId: string | undefined = undefined;

constructor(definition: DeviceTypeDefinition, options: EndpointOptions = {}) {
super(definition, options);
Expand All @@ -152,7 +157,15 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
}

serialize(pluginName: string) {
const serialized: SerializedMatterbridgeDevice = { pluginName, deviceType: this.getDeviceTypes(), name: this.name, clusterServersId: [] };
const serialized: SerializedMatterbridgeDevice = {
pluginName,
serialNumber: this.serialNumber!,
deviceName: this.deviceName!,
uniqueId: this.uniqueId!,
deviceType: this.getDeviceTypes(),
endpointName: this.name,
clusterServersId: [],
};
this.getAllClusterServers().forEach((clusterServer) => {
serialized.clusterServersId.push(clusterServer.id);
});
Expand All @@ -166,7 +179,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
* @param log - The AnsiLogger object.
*/
createRoomEveHistoryClusterServer(history: MatterHistory, log: AnsiLogger) {
history.setMatterHystoryType('room');
history.setMatterHystoryType('room', this.serialNumber);
this.addClusterServer(
ClusterServer(
EveHistoryCluster,
Expand Down Expand Up @@ -641,7 +654,9 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
hardwareVersion = 1,
hardwareVersionString = 'v.1.0.0',
) {
this.deviceName = deviceName;
this.serialNumber = serialNumber;
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
if (MatterbridgeDevice.bridgeMode === 'bridge') {
this.createDefaultBridgedDeviceBasicInformationClusterServer(
deviceName,
Expand Down Expand Up @@ -712,7 +727,9 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
hardwareVersion = 1,
hardwareVersionString = 'v.1.0.0',
) {
this.deviceName = deviceName;
this.serialNumber = serialNumber;
this.uniqueId = this.createUniqueId(deviceName, serialNumber, vendorName, productName);
this.addClusterServer(
ClusterServer(
BridgedDeviceBasicInformationCluster,
Expand Down

0 comments on commit 25f4f1c

Please sign in to comment.