Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
fix/device-removal-on-power-loss (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresAil authored Jan 6, 2023
1 parent c73d1bd commit 70cd960
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

custom: ['https://www.paypal.com/donate/?hosted_button_id=5GM8SZ2YNVK5Q']
custom: ['https://revolut.me/nicolanuyi']
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"private": false,
"displayName": "TPLink Tapo",
"name": "homebridge-tp-link-tapo",
"version": "3.2.1",
"version": "3.2.2",
"description": "A platform to implement the tp-link tapo device and Adaptive Lighting for light bulbs",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git://github.com/RaresAil/homebridge-tp-link-tapo.git"
},
"funding": {
"url": "https://www.paypal.com/donate/?hosted_button_id=5GM8SZ2YNVK5Q",
"type": "paypal"
"url": "https://revolut.me/nicolanuyi",
"type": "individual"
},
"bugs": {
"url": "https://github.com/RaresAil/homebridge-tp-link-tapo/issues"
Expand Down Expand Up @@ -43,22 +43,22 @@
"smart"
],
"dependencies": {
"async-lock": "^1.3.2",
"axios": "^0.27.2"
"async-lock": "^1.4.0",
"axios": "^1.2.2"
},
"resolutions": {
"minimist": "^1.2.6"
"minimatch": "^3.0.5"
},
"devDependencies": {
"@types/async-lock": "^1.1.5",
"@types/node": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"homebridge": "^1.5.0",
"nodemon": "^2.0.19",
"@types/async-lock": "^1.3.0",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint": "^8.31.0",
"homebridge": "^1.6.0",
"nodemon": "^2.0.20",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
}
}
14 changes: 11 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,18 @@ export default class Platform implements DynamicPlatformPlugin {
}

private checkOldDevices() {
const addressesByUUID: Record<string, string> = (
(this.config?.addresses as string[]) || []
).reduce(
(acc, ip) => ({
...acc,
[this.api.hap.uuid.generate(ip)]: ip
}),
{}
);

this.accessories.map((accessory) => {
const exists = this.registeredDevices.find(
(device) => device.UUID === accessory.UUID
);
const exists = addressesByUUID[accessory.UUID.toString()];

if (!exists) {
this.log.info('Remove cached accessory:', accessory.displayName);
Expand Down
Loading

0 comments on commit 70cd960

Please sign in to comment.