UNPKG

homebridge-roborock-vacuum-update

Version:

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

50 lines 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DockService = void 0; const rxjs_1 = require("rxjs"); const plugin_service_class_1 = require("./plugin_service_class"); const ensure_name_1 = require("./utils/ensure_name"); class DockService extends plugin_service_class_1.PluginServiceClass { constructor(coreContext, accessory) { super(coreContext); this.accessory = accessory; if (this.config.dock) { const name = `${this.config.name} Dock`; this.service = this.accessory.getServiceById(this.hap.Service.OccupancySensor, "dock") || this.accessory.addService(this.hap.Service.OccupancySensor, name, "dock"); (0, ensure_name_1.ensureName)(this.hap, this.service, name); this.service .getCharacteristic(this.hap.Characteristic.OccupancyDetected) .onGet(() => this.getDocked()); } } async init() { if (!this.service) return; this.deviceManager.stateChanged$ .pipe((0, rxjs_1.filter)(({ key }) => key === "state" || key === "charge_status"), (0, rxjs_1.map)(({ value, key }) => { if (key === "state") { return this.deviceManager.isDocked; } return this.deviceManager.isCharging; }), (0, rxjs_1.distinct)(), (0, rxjs_1.tap)((isDocked) => { this.service .getCharacteristic(this.hap.Characteristic.OccupancyDetected) .updateValue(isDocked); })) .subscribe((isDocked) => { const msg = isDocked ? "Robot was docked" : "Robot not anymore in dock"; this.log.info(`Dock status changed: ${msg}`); }); } get services() { return this.service ? [this.service] : []; } async getDocked() { const isDocked = this.deviceManager.isDocked || this.deviceManager.isCharging; this.log.debug(`getDocked: ${isDocked}`); return isDocked; } } exports.DockService = DockService; //# sourceMappingURL=dock_service.js.map