matterbridge-roborock-vacuum-plugin
Version:
Matterbridge Roborock Vacuum Plugin
68 lines • 3.41 kB
JavaScript
import { RvcOperationalState } from 'matterbridge/matter/clusters';
import { getDefaultOperationalStates } from '../behaviors/roborock.vacuum/core/runModeConfig.js';
import { DockStationStatusCode } from '../model/DockStationStatus.js';
import { VacuumErrorCode } from '../roborockCommunication/enums/index.js';
/**
* Get supported operational states for the vacuum.
* @returns Array of operational state configurations
*/
export function getOperationalStates() {
return getDefaultOperationalStates();
}
/**
* Map vacuum error code to Matter operational state.
* @param errorCode - Vacuum error code from device
* @returns Error operational state or undefined if no error
*/
export function getOperationalErrorState(errorCode) {
switch (errorCode) {
case VacuumErrorCode.None:
return undefined;
default:
return RvcOperationalState.OperationalState.Error;
}
}
/**
* Create an error state structure.
* @param errorStateId - Matter error state identifier
* @param errorStateLabel - Human-readable error label
* @param errorStateDetails - Detailed error description
* @returns Error state structure
*/
function createErrorState(errorStateId, errorStateLabel, errorStateDetails) {
return { errorStateId, errorStateLabel, errorStateDetails };
}
/**
* Create error state structure from docking station status.
* Maps various docking station component errors to Matter error states.
* @param status - Docking station status containing component states
* @returns Error state structure or undefined if no error
*/
export function getErrorFromDSS(status) {
if (!status) {
return createErrorState(RvcOperationalState.ErrorState.NoError, 'No Docking Station Status', 'Docking station status is not available.');
}
const hasError = status.hasError();
if (hasError) {
if (status.cleanFluidStatus === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.MopCleaningPadMissing, 'Clean Fluid Error', 'The clean fluid is not available or has an issue.');
}
if (status.waterBoxFilterStatus === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.WaterTankEmpty, 'Water Box Filter Error', 'The water box filter is not available or has an issue.');
}
if (status.dustBagStatus === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.DustBinMissing, 'Dust Bag Error', 'The dust bag is not available or has an issue.');
}
if (status.dirtyWaterBoxStatus === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.WaterTankEmpty, 'Dirty Water Box Error', 'The dirty water box is not available or has an issue.');
}
if (status.clearWaterBoxStatus === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.WaterTankEmpty, 'Clear Water Box Error', 'The clear water box is not available or has an issue.');
}
if (status.isUpdownWaterReady === DockStationStatusCode.Error) {
return createErrorState(RvcOperationalState.ErrorState.WaterTankMissing, 'Updown Water Ready Error', 'The updown water tank is not ready or has an issue.');
}
}
return undefined;
}
//# sourceMappingURL=getOperationalStates.js.map