Skip to content

Commit

Permalink
fix(energy): cumulative validation
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinBol committed Dec 12, 2024
1 parent f7164e0 commit e01bb65
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,21 @@ class App {
}
});
}

if (driver.energy.cumulative === true) {
if (typeof driver.energy.cumulativeImportedCapability !== 'string') {
console.warn(`Warning: drivers.${driver.id} has energy.cumulative set to true, but is missing 'cumulativeImportedCapability'.`);
}
if (typeof driver.energy.cumulativeExportedCapability !== 'string') {
console.warn(`Warning: drivers.${driver.id} has energy.cumulative set to true, but is missing 'cumulativeExportedCapability'.`);
}
if (typeof driver.energy.cumulativeImportedCapability === 'string' && Capability.isInstanceOfId(driver.energy.cumulativeImportedCapability, 'meter_power') === false) {
throw new Error(`drivers.${driver.id} has 'cumulativeImportedCapability': '${driver.energy.cumulativeImportedCapability}' but only instances of 'meter_power' are allowed.`);
}
if (typeof driver.energy.cumulativeExportedCapability === 'string' && Capability.isInstanceOfId(driver.energy.cumulativeExportedCapability, 'meter_power') === false) {
throw new Error(`drivers.${driver.id} has 'cumulativeExportedCapability': '${driver.energy.cumulativeExportedCapability}' but only instances of 'meter_power' are allowed.`);
}
}
}

if (driver.connectivity && driver.connectivity.includes('matter')) {
Expand Down

0 comments on commit e01bb65

Please sign in to comment.