Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ import {
calculateMonthlyAutarchy,
} from './model'
import { historicSummary, resetHistoricSummary } from '@/assets/js/model'
import { itemNames } from './model'

let columnValues: { [key: string]: number } = {}
const consumerCategories = ['charging', 'house', 'batIn', 'devices']
const nonPvCategories = ['evuIn', 'pv', 'batIn', 'evuOut']
const nonPvCategories = ['evuIn', 'pv', 'batOut', 'evuOut']
let gridCounters: string[] = []

// methods:
// Process a new message with monthly graph data. A single message contains all data
export function processMonthGraphMessages(topic: string, message: string) {
const inputTable: RawDayGraphDataItem[] = JSON.parse(message).entries
const energyValues: RawDayGraphDataItem = JSON.parse(message).totals
//const inputTable: RawDayGraphDataItem[] = JSON.parse(message).entries
//const energyValues: RawDayGraphDataItem = JSON.parse(message).totals
const {
entries: inputTable,
names: itemNames2,
totals: energyValues,
} = JSON.parse(message)
itemNames.value = new Map(Object.entries(itemNames2))
resetHistoricSummary()
gridCounters = []
consumerCategories.forEach((cat) => {
Expand All @@ -33,15 +40,23 @@ export function processMonthGraphMessages(topic: string, message: string) {
// reloadMonthGraph(topic, message)
}
export function processYearGraphMessages(topic: string, message: string) {
const inputTable: RawDayGraphDataItem[] = JSON.parse(message).entries
const energyValues: RawDayGraphDataItem = JSON.parse(message).totals
//const inputTable: RawDayGraphDataItem[] = JSON.parse(message).entries
//const energyValues: RawDayGraphDataItem = JSON.parse(message).totals
const {
entries: inputTable,
names: itemNames2,
totals: energyValues,
} = JSON.parse(message)
itemNames.value = new Map(Object.entries(itemNames2))
resetHistoricSummary()
gridCounters = []
consumerCategories.forEach((cat) => {
historicSummary.items[cat].energyPv = 0
historicSummary.items[cat].energyBat = 0
})
setGraphData(transformDatatable(inputTable))
if (inputTable.length > 0) {
setGraphData(transformDatatable(inputTable))
}
updateEnergyValues(energyValues, gridCounters)
}
// transform the incoming format into the format used by the graph
Expand Down Expand Up @@ -158,13 +173,17 @@ function transformRow(inputRow: RawDayGraphDataItem): GraphDataItem {
0,
)
// House
outputRow.house =
outputRow.pv +
outputRow.evuIn +
outputRow.batOut -
outputRow.evuOut -
outputRow.batIn -
outputRow.charging
if (inputRow.hc && inputRow.hc.all) {
outputRow.house = inputRow.hc.all.energy_imported // (seems this is now centrally computed) - currentItem.devices
} else {
outputRow.house =
outputRow.pv +
outputRow.evuIn +
outputRow.batOut -
outputRow.evuOut -
outputRow.batIn -
outputRow.charging
}
// Self usage
outputRow.selfUsage = outputRow.pv - outputRow.evuOut
// Autarchy
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/modules/web_themes/colors/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<link rel="apple-touch-icon" sizes="57x57" href="/openWB/web/img/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/openWB/web/img/favicons/apple-touch-icon-60x60.png">
<title>openWB</title>
<script type="module" crossorigin src="/openWB/web/themes/colors/assets/index-64509b9e.js"></script>
<script type="module" crossorigin src="/openWB/web/themes/colors/assets/index-cfda3130.js"></script>
<link rel="modulepreload" crossorigin href="/openWB/web/themes/colors/assets/vendor-978a58bb.js">
<link rel="stylesheet" href="/openWB/web/themes/colors/assets/index-a2141c90.css">
</head>
Expand Down