Skip to content

Commit

Permalink
1.4.5-beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoduj committed Apr 22, 2021
1 parent cdfc5f4 commit 6cb57b6
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 88 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ You can also use the [PACKAGES](https://github.com/oznu/docker-homebridge#option

All notable changes to this project will be documented in this file.

## 1.4.5-beta.5

- [FIX] Custom areas and spots as separate device #63

## 1.4.5-beta.4

- [FIX] Custom areas and spots as separate device #63
Expand Down
172 changes: 85 additions & 87 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,48 @@ myDeebotEcovacsPlatform.prototype = {
}

if (isForThisDeebot) {
let HKSwitchSpotAreaService = myDeebotEcovacsAccessory.getServiceByUUIDAndSubType(
//get Accessory
let accessory = myDeebotEcovacsAccessory;

if (this.publishAreaSwitchesAsSeparateDevices) {
let uuid2 = UUIDGen.generate(deebotName + 'SpotArea ' + i);
let myDeebotEcovacsAccessory2 = this.foundAccessories.find((x) => x.UUID == uuid2);

if (!myDeebotEcovacsAccessory2) {
this.log('INFO - Creating SpotArea' + i + ' Accessory for ' + deebotName);

myDeebotEcovacsAccessory2 = new Accessory(deebotName + 'SpotArea ' + i, uuid2);

this.api.registerPlatformAccessories(
'homebridge-deebotecovacs',
'DeebotEcovacs',
[myDeebotEcovacsAccessory2]
);
this.foundAccessories.push(myDeebotEcovacsAccessory2);
}
myDeebotEcovacsAccessory2.name = deebotName + 'SpotArea ' + i;
myDeebotEcovacsAccessory2.manufacturer = vacBot.vacuum.company;
myDeebotEcovacsAccessory2.serialNumber = vacBot.vacuum.did;
myDeebotEcovacsAccessory2.model = vacBot.deviceModel;
myDeebotEcovacsAccessory2.vacBot = vacBot;

myDeebotEcovacsAccessory2
.getService(Service.AccessoryInformation)
.setCharacteristic(
Characteristic.Manufacturer,
myDeebotEcovacsAccessory2.manufacturer
)
.setCharacteristic(Characteristic.Model, myDeebotEcovacsAccessory2.model)
.setCharacteristic(
Characteristic.SerialNumber,
myDeebotEcovacsAccessory2.serialNumber
);

this._confirmedAccessories.push(myDeebotEcovacsAccessory2);
accessory = myDeebotEcovacsAccessory2;
}

let HKSwitchSpotAreaService = accessory.getServiceByUUIDAndSubType(
'SpotArea ' + i + ' ' + deebotName,
'SwitchSpotAreaService' + i + deebotName
);
Expand All @@ -448,47 +489,8 @@ myDeebotEcovacsPlatform.prototype = {
'SwitchSpotAreaService' + i + deebotName
);
HKSwitchSpotAreaService.subtype = 'SwitchSpotAreaService' + i + deebotName;
if (this.publishAreaSwitchesAsSeparateDevices) {
let uuid2 = UUIDGen.generate(deebotName + 'SpotArea ' + i);
let myDeebotEcovacsAccessory2 = this.foundAccessories.find(
(x) => x.UUID == uuid2
);

if (!myDeebotEcovacsAccessory2) {
this.log('INFO - Creating SpotArea' + i + ' Accessory for ' + deebotName);

myDeebotEcovacsAccessory2 = new Accessory(deebotName + 'SpotArea ' + i, uuid2);

this.api.registerPlatformAccessories(
'homebridge-deebotecovacs',
'DeebotEcovacs',
[myDeebotEcovacsAccessory2]
);
this.foundAccessories.push(myDeebotEcovacsAccessory2);
}
myDeebotEcovacsAccessory2.name = deebotName + 'SpotArea ' + i;
myDeebotEcovacsAccessory2.manufacturer = vacBot.vacuum.company;
myDeebotEcovacsAccessory2.serialNumber = vacBot.vacuum.did;
myDeebotEcovacsAccessory2.model = vacBot.deviceModel;
myDeebotEcovacsAccessory2.vacBot = vacBot;

myDeebotEcovacsAccessory2
.getService(Service.AccessoryInformation)
.setCharacteristic(
Characteristic.Manufacturer,
myDeebotEcovacsAccessory2.manufacturer
)
.setCharacteristic(Characteristic.Model, myDeebotEcovacsAccessory2.model)
.setCharacteristic(
Characteristic.SerialNumber,
myDeebotEcovacsAccessory2.serialNumber
);

myDeebotEcovacsAccessory2.addService(HKSwitchSpotAreaService);
this._confirmedAccessories.push(myDeebotEcovacsAccessory2);
} else {
myDeebotEcovacsAccessory.addService(HKSwitchSpotAreaService);
}
accessory.addService(HKSwitchSpotAreaService);
}

this.bindSwitchOrderCharacteristic(
Expand Down Expand Up @@ -528,7 +530,47 @@ myDeebotEcovacsPlatform.prototype = {
}

if (isForThisDeebot) {
let HKSwitchCustomAreaService = myDeebotEcovacsAccessory.getServiceByUUIDAndSubType(
//get Accessory
let accessory = myDeebotEcovacsAccessory;

if (this.publishAreaSwitchesAsSeparateDevices) {
let uuid2 = UUIDGen.generate(deebotName + 'CustomArea ' + i);
let myDeebotEcovacsAccessory2 = this.foundAccessories.find((x) => x.UUID == uuid2);

if (!myDeebotEcovacsAccessory2) {
this.log('INFO - Creating CustomArea ' + i + ' Accessory for ' + deebotName);

myDeebotEcovacsAccessory2 = new Accessory(deebotName + 'CustomArea ' + i, uuid2);

this.api.registerPlatformAccessories(
'homebridge-deebotecovacs',
'DeebotEcovacs',
[myDeebotEcovacsAccessory2]
);
this.foundAccessories.push(myDeebotEcovacsAccessory2);
}
myDeebotEcovacsAccessory2.name = deebotName + 'CustomArea ' + i;
myDeebotEcovacsAccessory2.manufacturer = vacBot.vacuum.company;
myDeebotEcovacsAccessory2.serialNumber = vacBot.vacuum.did;
myDeebotEcovacsAccessory2.model = vacBot.deviceModel;
myDeebotEcovacsAccessory2.vacBot = vacBot;

myDeebotEcovacsAccessory2
.getService(Service.AccessoryInformation)
.setCharacteristic(
Characteristic.Manufacturer,
myDeebotEcovacsAccessory2.manufacturer
)
.setCharacteristic(Characteristic.Model, myDeebotEcovacsAccessory2.model)
.setCharacteristic(
Characteristic.SerialNumber,
myDeebotEcovacsAccessory2.serialNumber
);
this._confirmedAccessories.push(myDeebotEcovacsAccessory2);
accessory = myDeebotEcovacsAccessory2;
}

let HKSwitchCustomAreaService = accessory.getServiceByUUIDAndSubType(
'CustomArea ' + i + ' ' + deebotName,
'SwitchCustomAreaService' + i + deebotName
);
Expand All @@ -542,51 +584,7 @@ myDeebotEcovacsPlatform.prototype = {
'SwitchCustomAreaService' + i + deebotName
);
HKSwitchCustomAreaService.subtype = 'SwitchCustomAreaService' + i + deebotName;

if (this.publishAreaSwitchesAsSeparateDevices) {
let uuid2 = UUIDGen.generate(deebotName + 'CustomArea ' + i);
let myDeebotEcovacsAccessory2 = this.foundAccessories.find(
(x) => x.UUID == uuid2
);

if (!myDeebotEcovacsAccessory2) {
this.log('INFO - Creating CustomArea ' + i + ' Accessory for ' + deebotName);

myDeebotEcovacsAccessory2 = new Accessory(
deebotName + 'CustomArea ' + i,
uuid2
);

this.api.registerPlatformAccessories(
'homebridge-deebotecovacs',
'DeebotEcovacs',
[myDeebotEcovacsAccessory2]
);
this.foundAccessories.push(myDeebotEcovacsAccessory2);
}
myDeebotEcovacsAccessory2.name = deebotName + 'CustomArea ' + i;
myDeebotEcovacsAccessory2.manufacturer = vacBot.vacuum.company;
myDeebotEcovacsAccessory2.serialNumber = vacBot.vacuum.did;
myDeebotEcovacsAccessory2.model = vacBot.deviceModel;
myDeebotEcovacsAccessory2.vacBot = vacBot;

myDeebotEcovacsAccessory2
.getService(Service.AccessoryInformation)
.setCharacteristic(
Characteristic.Manufacturer,
myDeebotEcovacsAccessory2.manufacturer
)
.setCharacteristic(Characteristic.Model, myDeebotEcovacsAccessory2.model)
.setCharacteristic(
Characteristic.SerialNumber,
myDeebotEcovacsAccessory2.serialNumber
);

myDeebotEcovacsAccessory2.addService(HKSwitchCustomAreaService);
this._confirmedAccessories.push(myDeebotEcovacsAccessory2);
} else {
myDeebotEcovacsAccessory.addService(HKSwitchCustomAreaService);
}
accessory.addService(HKSwitchCustomAreaService);
}

this.bindSwitchOrderCharacteristic(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-deebotecovacs",
"version": "1.4.5-beta.4",
"version": "1.4.5-beta.5",
"author": "Nicolas Dujardin",
"description": "Publish your deebot ecovacs as an homekit accessory",
"main": "index.js",
Expand Down

0 comments on commit 6cb57b6

Please sign in to comment.