Skip to content

Commit

Permalink
Better rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
robertraaijmakers committed Feb 15, 2025
1 parent f733240 commit 0a483d5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/AlfenApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class AlfenApi {
const voltage = capabilitiesData.find((x) => x.capabilityId === `measure_voltage.${phase}`)?.value;
const current = capabilitiesData.find((x) => x.capabilityId === `measure_current.${phase}`)?.value;
if (voltage && current && !isNaN(Number(voltage)) && !isNaN(Number(current))) {
capabilitiesData.push({ capabilityId: `measure_power.${phase}`, value: Math.round(Number(voltage) * Number(current)) });
capabilitiesData.push({ capabilityId: `measure_power.${phase}`, value: Math.round(Number(voltage) * Number(current) * 10) / 10 });
} else {
capabilitiesData.push({ capabilityId: `measure_power.${phase}`, value: 0 });
}
Expand Down

0 comments on commit 0a483d5

Please sign in to comment.