UNPKG

homebridge-roborock-vacuum-update

Version:

Comprehensive Homebridge plugin for Roborock vacuum cleaners with full HomeKit integration including mopping, dock features, and advanced controls.

103 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceManager = void 0; const rxjs_1 = require("rxjs"); /** * DeviceManager wraps the Roborock API and provides a consistent interface * for services to access device state and control. */ class DeviceManager { constructor(hap, log, roborockAPI, duid) { this.log = log; this.roborockAPI = roborockAPI; this.duid = duid; this.internalStateChanged$ = new rxjs_1.Subject(); this.stateChanged$ = this.internalStateChanged$.asObservable(); // HAP is passed but not stored as it's not directly used // All HAP access is through the roborockAPI } /** * Get a device status value */ getStatus(key) { return this.roborockAPI.getVacuumDeviceStatus(this.duid, key); } /** * Get device info */ getInfo(key) { return this.roborockAPI.getVacuumDeviceInfo(this.duid, key); } /** * Get product attribute */ getProductAttribute(key) { return this.roborockAPI.getProductAttribute(this.duid, key); } /** * Check if device is cleaning */ get isCleaning() { const state = this.getStatus("state"); return this.roborockAPI.isCleaning(state); } /** * Check if device is paused */ get isPaused() { const state = this.getStatus("state"); return state === 10; // Paused state } /** * Check if device is charging */ get isCharging() { const chargeStatus = this.getStatus("charge_status"); return chargeStatus === 1 || chargeStatus === 2; } /** * Check if device is docked */ get isDocked() { const state = this.getStatus("state"); return state === 8; // Charging state } /** * Get current state */ get state() { return this.getStatus("state") || 0; } /** * Get battery level */ get battery() { return this.getStatus("battery") || 0; } /** * Emit state change event */ emitStateChange(key, value) { this.internalStateChanged$.next({ key, value }); } /** * Check if device supports a feature */ hasFeature(feature) { return this.roborockAPI.hasFeature(this.duid, feature); } /** * Get room mapping */ getRoomMapping() { return this.roborockAPI.roomIDs || {}; } /** * Get scenes for device */ getScenes() { return this.roborockAPI.getScenesForDevice(this.duid) || []; } } exports.DeviceManager = DeviceManager; //# sourceMappingURL=device_manager.js.map