diff --git a/config.schema.json b/config.schema.json index 41959d8..2ebdb66 100644 --- a/config.schema.json +++ b/config.schema.json @@ -17,7 +17,7 @@ "description": "IP Address of your Eufy Robovac", "type": "string", "required": true, - "default": "10.0.1.69" + "placeholder": "10.0.1.69" }, "deviceId": { "title": "Tuya Device ID", @@ -30,6 +30,29 @@ "description": "Tuya/Eufy Device/Local Key (see: https://github.com/markbajaj/eufy-device-id-python)", "type": "string", "required": true + }, + "roomSwitches": { + "description": "Per-Room Switches", + "type": "array", + "items": { + "title": "Switch", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "placeholder": "Arbitrary name for this switch", + "required": true + }, + "rooms": { + "title": "Rooms", + "type": "string", + "placeholder": "A room number or comma-separated list of room numbers", + "pattern": "^[0-9]+(,[0-9]+)*$", + "required": true + } + } + } } } } diff --git a/package-lock.json b/package-lock.json index eb12e28..8168f1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@george.talusan/homebridge-eufy-robovac", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@george.talusan/homebridge-eufy-robovac", - "version": "0.0.4", + "version": "0.0.5", "license": "ISC", "dependencies": { - "@george.talusan/eufy-robovac-js": "^0.0.6" + "@george.talusan/eufy-robovac-js": "^0.0.9" }, "devDependencies": { "@eslint/js": "^9.9.0", @@ -140,13 +140,12 @@ } }, "node_modules/@george.talusan/eufy-robovac-js": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/@george.talusan/eufy-robovac-js/-/eufy-robovac-js-0.0.6.tgz", - "integrity": "sha512-w2pTainGUxJjtoJw84SOpAUkKBhXfMVlJqXRSB6THHPxozc1rm3aZ/g3b0wdfO13Gh+v33J9cXQqtT5J7HYEfw==", + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@george.talusan/eufy-robovac-js/-/eufy-robovac-js-0.0.9.tgz", + "integrity": "sha512-E2Y/9G8ErIWxHIGVmAiN3iKcCVLiiV7CwFV00wIPHt+f4B0T6l5zESirVYLJxteV2nhPAdme9HXCzzzel/eJvg==", "license": "ISC", "dependencies": { "debug": "^4.3.5", - "net-ping": "^1.2.4", "tuyapi": "github:codetheweb/tuyapi" } }, @@ -2541,12 +2540,6 @@ "dev": true, "license": "MIT" }, - "node_modules/nan": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", - "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==", - "license": "MIT" - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -2554,15 +2547,6 @@ "dev": true, "license": "MIT" }, - "node_modules/net-ping": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/net-ping/-/net-ping-1.2.4.tgz", - "integrity": "sha512-9IbIgPonxYj5HMkgCYXFqHF/pz462qsxA7RVLA6sI604eQyaecxVKl3yrDGHajjKZpUL1r2VBMwd0KVMnPO5Rw==", - "license": "MIT", - "dependencies": { - "raw-socket": "*" - } - }, "node_modules/node-persist": { "version": "0.0.12", "resolved": "https://registry.npmjs.org/node-persist/-/node-persist-0.0.12.tgz", @@ -2967,16 +2951,6 @@ ], "license": "MIT" }, - "node_modules/raw-socket": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/raw-socket/-/raw-socket-1.8.1.tgz", - "integrity": "sha512-AjadKwsmroOZkAy/t9xm3wkHWN/WOJZMSryHAqABwE8A2j5DmqJevgdYR1das5xOWyoL11UFPRu7TYEDFs9vdw==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "nan": "2.19.*" - } - }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", diff --git a/package.json b/package.json index 19795eb..a0188ea 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,6 @@ "typescript-eslint": "^8.0.1" }, "dependencies": { - "@george.talusan/eufy-robovac-js": "^0.0.6" + "@george.talusan/eufy-robovac-js": "^0.0.9" } } diff --git a/src/platform.ts b/src/platform.ts index 5e1ecc1..1b5fe0d 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -1,6 +1,7 @@ import type { API, Characteristic, DynamicPlatformPlugin, Logging, PlatformAccessory, PlatformConfig, Service } from 'homebridge'; import { DefaultPlatformAccessory } from './defaultAccessory.js'; +import { CleanRoomsPlatformAccessory } from './cleanRoomsAccessory.js'; import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'; import { createRequire } from 'module'; @@ -82,6 +83,22 @@ export class EufyRobovacHomebridgePlatform implements DynamicPlatformPlugin { }, ]; + const rooms = this.config.roomSwitches; + rooms.forEach(room => { + accessories.push({ + displayName: () => { + return `${room.name}`; + }, + uuid: () => { + return this.api.hap.uuid.generate(`${this.config.name}-${this.config.ip}-${room.name}-${room.rooms}`); + }, + make: (accessory: PlatformAccessory) => { + accessory.context.rooms = room.rooms.split(',').map(Number); + new CleanRoomsPlatformAccessory(this, accessory); + }, + }); + }); + // loop over the discovered devices and register each one if it has not already been registered for (const a of accessories) { const uuid = a.uuid();