Skip to content

Commit

Permalink
prep v6
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Mar 11, 2023
1 parent 9cd0dff commit 4c2bbec
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 138 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to homebridge-wemo will be documented in this file.

## BETA
## 6.0.0 (2023-03-11)

### Breaking

Expand All @@ -14,7 +14,7 @@ All notable changes to homebridge-wemo will be documented in this file.
### Changed

- Bump `homebridge` recommended version to v1.6.0 or v2.0.0-beta
- Bump `node` recommended versions to v16.19.1 or v18.14.2
- Bump `node` recommended versions to v16.19.1 or v18.15.0

## 5.0.5 (2022-10-16)

Expand Down
45 changes: 20 additions & 25 deletions lib/device/insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,43 +259,38 @@ export default class {

externalConsumptionUpdate(power) {
try {
// Check to see if the cache value is different
if (power === this.cachePower) {
return;
}

// Update the cache value
this.cachePower = power;

// Divide by 1000 to get the power value in W
const powerInWatts = Math.round(power / 1000);

// Calculate a difference from the last reading (only used for logging)
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);
// Check to see if the cache value is different
if (powerInWatts === this.cachePowerInWatts) {
return;
}

// Update the power in watts cache
this.cachePowerInWatts = powerInWatts;

// Update the HomeKit characteristic
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, powerInWatts);
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, this.cachePowerInWatts);

// Add the Eve wattage entry
this.accessory.historyService.addEntry({ power: powerInWatts });
this.accessory.historyService.addEntry({ power: this.cachePowerInWatts });

// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (this.skipTimeDiff || diff < this.wattDiff) {
return;
}
// Calculate a difference from the last reading
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);

// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${powerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (!this.skipTimeDiff && diff >= this.wattDiff) {
// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${this.cachePowerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
}
}
} catch (err) {
// Catch any errors
Expand Down
45 changes: 20 additions & 25 deletions lib/device/simulation/purifier-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,43 +274,38 @@ export default class {

externalConsumptionUpdate(power) {
try {
// Check to see if the cache value is different
if (power === this.cachePower) {
return;
}

// Update the cache value
this.cachePower = power;

// Divide by 1000 to get the power value in W
const powerInWatts = Math.round(power / 1000);

// Calculate a difference from the last reading (only used for logging)
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);
// Check to see if the cache value is different
if (powerInWatts === this.cachePowerInWatts) {
return;
}

// Update the power in watts cache
this.cachePowerInWatts = powerInWatts;

// Update the HomeKit characteristic
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, powerInWatts);
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, this.cachePowerInWatts);

// Add the Eve wattage entry
this.accessory.historyService.addEntry({ power: powerInWatts });
this.accessory.historyService.addEntry({ power: this.cachePowerInWatts });

// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (this.skipTimeDiff || diff < this.wattDiff) {
return;
}
// Calculate a difference from the last reading
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);

// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${powerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (!this.skipTimeDiff && diff >= this.wattDiff) {
// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${this.cachePowerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
}
}
} catch (err) {
// Catch any errors
Expand Down
45 changes: 20 additions & 25 deletions lib/device/simulation/switch-insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,43 +232,38 @@ export default class {

externalConsumptionUpdate(power) {
try {
// Check to see if the cache value is different
if (power === this.cachePower) {
return;
}

// Update the cache value
this.cachePower = power;

// Divide by 1000 to get the power value in W
const powerInWatts = Math.round(power / 1000);

// Calculate a difference from the last reading (only used for logging)
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);
// Check to see if the cache value is different
if (powerInWatts === this.cachePowerInWatts) {
return;
}

// Update the power in watts cache
this.cachePowerInWatts = powerInWatts;

// Update the HomeKit characteristic
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, powerInWatts);
this.service.updateCharacteristic(this.eveChar.CurrentConsumption, this.cachePowerInWatts);

// Add the Eve wattage entry
this.accessory.historyService.addEntry({ power: powerInWatts });
this.accessory.historyService.addEntry({ power: this.cachePowerInWatts });

// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (this.skipTimeDiff || diff < this.wattDiff) {
return;
}
// Calculate a difference from the last reading
const diff = Math.abs(powerInWatts - this.cachePowerInWatts);

// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${powerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
// Don't continue with logging if the user has set a timeout between entries or a min difference between entries
if (!this.skipTimeDiff && diff >= this.wattDiff) {
// Log the change if appropriate
this.accessory.log(`${platformLang.curCons} [${this.cachePowerInWatts}W]`);

// Set the time difference timeout if needed
if (this.timeDiff) {
this.skipTimeDiff = true;
setTimeout(() => {
this.skipTimeDiff = false;
}, this.timeDiff * 1000);
}
}
} catch (err) {
// Catch any errors
Expand Down
103 changes: 44 additions & 59 deletions package-lock.json

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

Loading

0 comments on commit 4c2bbec

Please sign in to comment.