From cec1e09bb060a7ab362ce337c1f192f7590789e8 Mon Sep 17 00:00:00 2001 From: ztimson Date: Tue, 1 Jan 2019 17:10:08 -0500 Subject: [PATCH] Fixed fan buttons --- src/app/battery/battery.component.html | 2 +- src/app/battery/battery.service.ts | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/app/battery/battery.component.html b/src/app/battery/battery.component.html index 050d49b..3861e5c 100644 --- a/src/app/battery/battery.component.html +++ b/src/app/battery/battery.component.html @@ -4,7 +4,7 @@

Powerwall: {{batteryService.total | round}} V

- + Auto On Off diff --git a/src/app/battery/battery.service.ts b/src/app/battery/battery.service.ts index 789b85c..9520b23 100644 --- a/src/app/battery/battery.service.ts +++ b/src/app/battery/battery.service.ts @@ -9,6 +9,7 @@ export class BatteryService { batteries = []; last: Date; + relayMode?: boolean = null; total: number = 0; get icon() { @@ -45,6 +46,9 @@ export class BatteryService { this.firestore.collection('Battery').doc('170614D').onSnapshot(snap => { this.last = new Date(); let data = snap.data(); + + this.relayMode = data.config.relayMode || null; + this.batteries = Object.keys(data.modules).map(key => { let last = data.modules[key].length - 1; return { @@ -56,20 +60,11 @@ export class BatteryService { tempHistory: data.modules[key].map((val, i) => ({name: i, value: val.temp})) } }); - - 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) }); } setRelayMode(mode?:boolean) { - this.firestore.collection('Battery').doc('170724D').update({config: {relayMode: mode}}); + this.firestore.collection('Battery').doc('170614D').update({config: {relayMode: mode}}); } }