Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site: publish meter values as map (BC) #15216

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
14 changes: 7 additions & 7 deletions assets/js/components/BatterySettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default {
batterySoc: Number,
bufferStartSoc: Number,
batteryDischargeControl: Boolean,
battery: { type: Array, default: () => [] },
battery: Object,
batteryGridChargeLimit: Number,
smartCostType: String,
tariffGrid: Number,
Expand Down Expand Up @@ -302,7 +302,7 @@ export default {
return options;
},
controllable() {
return this.battery.some(({ controllable }) => controllable);
return Object.values(this.battery || {}).some(({ controllable }) => controllable);
},
gridChargePossible() {
return (
Expand Down Expand Up @@ -356,13 +356,13 @@ export default {
return this.prioritySoc;
},
batteryDetails() {
if (!Array.isArray(this.battery)) {
return;
}
return this.battery
const batteries = Object.values(this.battery || {});
if (batteries.length === 0) return;

return batteries
.filter(({ capacity }) => capacity > 0)
.map(({ soc, capacity }) => {
const multipleBatteries = this.battery.length > 1;
const multipleBatteries = batteries.length > 1;
const energy = this.fmtKWh(
(capacity / 100) * soc * 1e3,
true,
Expand Down
13 changes: 5 additions & 8 deletions assets/js/components/Energyflow/Energyflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ import formatter from "../../mixins/formatter";
import AnimatedNumber from "../AnimatedNumber.vue";
import settings from "../../settings";
import { CO2_TYPE } from "../../units";
import collector from "../../mixins/collector";

export default {
name: "Energyflow",
Expand All @@ -207,17 +206,16 @@ export default {
EnergyflowEntry,
AnimatedNumber,
},
mixins: [formatter, collector],
mixins: [formatter],
props: {
gridConfigured: Boolean,
gridPower: { type: Number, default: 0 },
homePower: { type: Number, default: 0 },
pvConfigured: Boolean,
pv: { type: Array },
pv: { type: Object },
pvPower: { type: Number, default: 0 },
loadpointsCompact: { type: Array, default: () => [] },
batteryConfigured: { type: Boolean },
battery: { type: Array },
batteryPower: { type: Number, default: 0 },
batterySoc: { type: Number, default: 0 },
batteryDischargeControl: { type: Boolean },
Expand Down Expand Up @@ -305,10 +303,9 @@ export default {
return this.detailsOpen ? this.detailsCompleteHeight + "px" : 0;
},
pvTooltip() {
if (!Array.isArray(this.pv) || this.pv.length <= 1) {
return;
}
return this.pv.map(({ power }) => this.fmtKw(power, this.powerInKw));
const pvs = Object.values(this.pv || {});
if (pvs.length <= 1) return;
return pvs.map(({ power }) => this.fmtKw(power, this.powerInKw));
},
batteryFmt() {
return (soc) => this.fmtPercentage(soc, 0);
Expand Down
8 changes: 4 additions & 4 deletions assets/js/components/Site.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ export default {
gridPower: Number,
homePower: Number,
pvPower: Number,
pv: Array,
pv: Object,
batteryPower: Number,
batterySoc: Number,
batteryDischargeControl: Boolean,
batteryGridChargeLimit: Number,
batteryGridChargeActive: Boolean,
batteryMode: String,
battery: Array,
battery: Object,
gridCurrents: Array,
prioritySoc: Number,
bufferSoc: Number,
Expand Down Expand Up @@ -106,10 +106,10 @@ export default {
},
computed: {
batteryConfigured: function () {
return this.battery?.length > 0;
return Object.keys(this.battery || {}).length > 0;
},
pvConfigured: function () {
return this.pv?.length > 0;
return Object.keys(this.pv || {}).length > 0;
},
energyflow: function () {
return this.collectProps(Energyflow);
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/TopNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default {
return {};
},
},
battery: Array,
battery: Object,
fatal: Object,
},
data() {
Expand All @@ -152,7 +152,7 @@ export default {
},
computed: {
batteryConfigured: function () {
return this.battery?.length;
return Object.keys(this.battery || {}).length > 0;
},
logoutCount() {
return this.providerLogins.filter((login) => !login.loggedIn).length;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
return store.state.version;
},
batteryModalAvailabe: function () {
return store.state.battery?.length;
return Object.keys(store.state.battery || {}).length > 0;
},
globalSettingsProps: function () {
return this.collectProps(GlobalSettingsModal, store.state);
Expand Down
Loading