Fixed some of the math
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
<div class="p-3">
 | 
			
		||||
    <div class="d-flex mb-3">
 | 
			
		||||
        <div class="d-flex flex-grow-1 align-items-center">
 | 
			
		||||
            <h3 class="mb-0 text-white">Powerwall: {{batteryService.total}} V</h3>
 | 
			
		||||
            <h3 class="mb-0 text-white">Powerwall: {{batteryService.total | round}} V</h3>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="d-flex flex-grow-1 align-content-center justify-content-end">
 | 
			
		||||
            <mat-button-toggle-group (change)="batteryService.setRelayMode($event.value)">
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,12 @@ export class BatteryService {
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            this.batteries.map((battery, i, arr) => {
 | 
			
		||||
                if(i % 2 == 1) return battery;
 | 
			
		||||
                console.log(i, battery.charge);
 | 
			
		||||
                battery.charge = battery.charge - arr[i + 1].charge;
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            this.total = this.batteries.reduce((acc, battery) => acc + battery.charge, 0) / 2;
 | 
			
		||||
 | 
			
		||||
            console.log(this.batteries)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user