Skip to content

Commit

Permalink
handle undefined roomSwitches
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalusan committed Oct 28, 2024
1 parent 5adc221 commit 5d96c33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@george.talusan/homebridge-eufy-robovac",
"displayName": "Homebridge Plugin for Eufy Robovac",
"type": "module",
"version": "0.0.8",
"version": "0.0.9",
"description": "Homebridge Plugin for Eufy Robovac",
"author": "George Talusan <[email protected]>",
"license": "ISC",
Expand Down
28 changes: 15 additions & 13 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,22 @@ export class EufyRobovacHomebridgePlatform implements DynamicPlatformPlugin {
];

const roomSwitches = this.config.roomSwitches;
roomSwitches.forEach((roomSwitch: RoomSwitch) => {
accessories.push({
displayName: () => {
return `${roomSwitch.name}`;
},
uuid: () => {
return this.api.hap.uuid.generate(`${this.config.name}-${this.config.ip}-${roomSwitch.name}-${roomSwitch.rooms}`);
},
make: (accessory: PlatformAccessory) => {
accessory.context.rooms = roomSwitch.rooms.split(',').map(Number);
new CleanRoomsPlatformAccessory(this, accessory);
},
if (roomSwitches) {
roomSwitches.forEach((roomSwitch: RoomSwitch) => {
accessories.push({
displayName: () => {
return `${roomSwitch.name}`;
},
uuid: () => {
return this.api.hap.uuid.generate(`${this.config.name}-${this.config.ip}-${roomSwitch.name}-${roomSwitch.rooms}`);
},
make: (accessory: PlatformAccessory) => {
accessory.context.rooms = roomSwitch.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) {
Expand Down

0 comments on commit 5d96c33

Please sign in to comment.