OpenEMS: add energy (#23248)
This commit is contained in:
parent
16e3c34989
commit
3d1296224d
2 changed files with 38 additions and 9 deletions
|
|
@ -40,26 +40,52 @@ params:
|
|||
advanced: true
|
||||
render: |
|
||||
type: custom
|
||||
{{- if eq .usage "grid" }}
|
||||
power:
|
||||
source: http
|
||||
{{- if eq .usage "grid" }}
|
||||
uri: http://{{ .host }}/rest/channel/_sum/GridActivePower
|
||||
{{- end }}
|
||||
{{- if eq .usage "pv" }}
|
||||
uri: http://{{ .host }}/rest/channel/_sum/ProductionActivePower
|
||||
{{- end }}
|
||||
{{- if eq .usage "battery" }}
|
||||
uri: http://{{ .host }}/rest/channel/_sum/EssDischargePower
|
||||
{{- end }}
|
||||
auth:
|
||||
type: basic
|
||||
user: x
|
||||
password: {{ .password }}
|
||||
jq: (.value // 0)
|
||||
energy:
|
||||
source: http
|
||||
uri: http://{{ .host }}/rest/channel/_sum/GridBuyActiveEnergy
|
||||
auth:
|
||||
type: basic
|
||||
user: x
|
||||
password: {{ .password }}
|
||||
jq: (.value / 1000 // 0) # convert Wh to kWh
|
||||
{{- end }}
|
||||
{{- if eq .usage "pv" }}
|
||||
power:
|
||||
source: http
|
||||
uri: http://{{ .host }}/rest/channel/_sum/ProductionActivePower
|
||||
auth:
|
||||
type: basic
|
||||
user: x
|
||||
password: {{ .password }}
|
||||
jq: (.value // 0)
|
||||
energy:
|
||||
source: http
|
||||
uri: http://{{ .host }}/rest/channel/_sum/ProductionActiveEnergy
|
||||
auth:
|
||||
type: basic
|
||||
user: x
|
||||
password: {{ .password }}
|
||||
jq: (.value / 1000 // 0) # convert Wh to kWh
|
||||
maxacpower: {{ .maxacpower }} # W
|
||||
{{- end }}
|
||||
{{- if eq .usage "battery" }}
|
||||
power:
|
||||
source: http
|
||||
uri: http://{{ .host }}/rest/channel/_sum/EssDischargePower
|
||||
auth:
|
||||
type: basic
|
||||
user: x
|
||||
password: {{ .password }}
|
||||
jq: (.value // 0)
|
||||
soc:
|
||||
source: http
|
||||
uri: http://{{ .host }}/rest/channel/_sum/EssSoc
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { ServerResponse } from "http";
|
|||
|
||||
let state = {
|
||||
site: {
|
||||
grid: { power: 0 },
|
||||
grid: { power: 0, energy: 0 },
|
||||
pv: { power: 0, energy: 0 },
|
||||
battery: { power: 0, soc: 0 },
|
||||
},
|
||||
|
|
@ -49,10 +49,13 @@ const openemsMiddleware = (
|
|||
) => {
|
||||
const endpoints = {
|
||||
"/rest/channel/_sum/GridActivePower": { value: state.site.grid.power },
|
||||
"/rest/channel/_sum/GridBuyActiveEnergy": { value: state.site.grid.energy },
|
||||
"/rest/channel/_sum/ProductionActivePower": { value: state.site.pv.power },
|
||||
"/rest/channel/_sum/ProductionActiveEnergy": { value: state.site.pv.energy },
|
||||
"/rest/channel/_sum/EssDischargePower": { value: state.site.battery.power },
|
||||
"/rest/channel/_sum/EssSoc": { value: state.site.battery.soc },
|
||||
};
|
||||
|
||||
const endpoint = endpoints[req.originalUrl as keyof typeof endpoints];
|
||||
if (req.method === "GET" && endpoint) {
|
||||
console.log("[simulator] GET", req.originalUrl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue