UNPKG

matterbridge-roborock-vacuum-plugin

Version:
75 lines 2.51 kB
import { NotifyMessageTypes } from '../../../../types/index.js'; export class SimpleMessageHandler { duid; logger; deviceNotify; constructor(duid, logger, deviceNotify) { this.duid = duid; this.logger = logger; this.deviceNotify = deviceNotify; } async onError(error) { if (!this.deviceNotify) { this.logger.debug(`[SimpleMessageHandler]: No deviceNotify callback provided`); return Promise.resolve(); } await this.deviceNotify({ type: NotifyMessageTypes.ErrorOccurred, data: { duid: error.duid, vacuumErrorCode: error.vacuumErrorCode, dockErrorCode: error.dockErrorCode, dockStationStatus: error.dockStationStatus, }, }); } async onBatteryUpdate(message) { if (!this.deviceNotify) { this.logger.debug(`[SimpleMessageHandler]: No deviceNotify callback provided`); return Promise.resolve(); } await this.deviceNotify({ type: NotifyMessageTypes.BatteryUpdate, data: message, }); } async onStatusChanged(message) { if (!this.deviceNotify) { this.logger.debug(`[SimpleMessageHandler]: No deviceNotify callback provided`); return Promise.resolve(); } await this.deviceNotify({ type: NotifyMessageTypes.DeviceStatus, data: message, }); } async onCleanModeUpdate(message) { if (!this.deviceNotify) { this.logger.debug(`[SimpleMessageHandler]: No deviceNotify callback provided`); return Promise.resolve(); } await this.deviceNotify({ type: NotifyMessageTypes.CleanModeUpdate, data: { ...message, duid: this.duid, seq_type: message.sequenceType, }, }); } async onServiceAreaUpdate(message) { if (!this.deviceNotify) { this.logger.debug(`[SimpleMessageHandler]: No deviceNotify callback provided`); return Promise.resolve(); } await this.deviceNotify({ type: NotifyMessageTypes.ServiceAreaUpdate, data: message, }); } onAdditionalProps(value) { // Implement additional properties handling logic here return Promise.resolve(); } } //# sourceMappingURL=simpleMessageHandler.js.map