Skip to content

Commit

Permalink
SonnenBatterie: add battery control (APIv2) (#11990)
Browse files Browse the repository at this point in the history
  • Loading branch information
rivengh authored Feb 1, 2024
1 parent cc2a060 commit 1283612
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions templates/definition/meter/sonnenbatterie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ products:
- brand: Sonnen
description:
generic: sonnenBatterie
capabilities: ["battery-control"]
requirements:
description:
de: |
Für die aktive Batteriesteuerung muss das "JSON Write API" über das Webinterface der sonnenBatterie aktiviert werden (unter Software-Integration).
en: |
For active battery control, the "JSON Write API" must be activated via the sonnenBatterie web interface (under Software-Integration).
params:
- name: usage
choice: ["grid", "pv", "battery"]
Expand All @@ -13,6 +20,13 @@ params:
default: 8080
- name: capacity
advanced: true
- name: token
advanced: true
required: false
help:
de: API Token (benötigt für aktive Batteriesteuerung)
en: API Token (required for active battery control)
usages: ["battery"]
render: |
type: custom
power:
Expand All @@ -31,6 +45,57 @@ render: |
source: http
uri: http://{{ .host }}:{{ .port }}/api/v1/status
jq: .USOC
{{- if .token }}
batterymode:
source: switch
switch:
- case: 1 # normal
set:
source: http
uri: http://{{ .host }}/api/v2/configurations
insecure: true
method: PUT
headers:
- content-type: application/json
- Auth-Token: {{ .token }}
body: '{"EM_OperatingMode":"2"}' # self consumption
- case: 2 # hold
set:
source: sequence
set:
- source: http
uri: http://{{ .host }}/api/v2/configurations
insecure: true
method: PUT
headers:
- content-type: application/json
- Auth-Token: {{ .token }}
body: '{"EM_OperatingMode":"1"}' # manual
- source: http
uri: http://{{ .host }}/api/v2/setpoint/discharge/0
insecure: true
method: POST
headers:
- content-type: application/json
- Auth-Token: {{ .token }}
- source: http
uri: http://{{ .host }}/api/v2/setpoint/charge/0
insecure: true
method: POST
headers:
- content-type: application/json
- Auth-Token: {{ .token }}
- case: 3 # charge
set:
source: http
uri: http://{{ .host }}/api/v2/configurations
insecure: true
method: PUT
headers:
- content-type: application/json
- Auth-Token: {{ .token }}
body: '{"EM_OperatingMode":"2"}' # self consumption
{{- end }}
{{- if .capacity }}
capacity: {{ .capacity }} # kWh
{{- end }}
Expand Down

0 comments on commit 1283612

Please sign in to comment.