Skip to content

Commit

Permalink
clean rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalusan committed Sep 5, 2024
1 parent 1b0955e commit 2e72d58
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 34 deletions.
25 changes: 24 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
}
}
}
}
}
Expand Down
38 changes: 6 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
17 changes: 17 additions & 0 deletions src/platform.ts
Original file line number Diff line number Diff line change
@@ -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';

Check failure on line 4 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Cannot find module './cleanRoomsAccessory.js' or its corresponding type declarations.

Check failure on line 4 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find module './cleanRoomsAccessory.js' or its corresponding type declarations.

Check failure on line 4 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

Cannot find module './cleanRoomsAccessory.js' or its corresponding type declarations.
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';

import { createRequire } from 'module';
Expand Down Expand Up @@ -82,6 +83,22 @@ export class EufyRobovacHomebridgePlatform implements DynamicPlatformPlugin {
},
];

const rooms = this.config.roomSwitches;
rooms.forEach(room => {

Check failure on line 87 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Parameter 'room' implicitly has an 'any' type.

Check failure on line 87 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Parameter 'room' implicitly has an 'any' type.

Check failure on line 87 in src/platform.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

Parameter 'room' implicitly has an 'any' type.
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();
Expand Down

0 comments on commit 2e72d58

Please sign in to comment.