LG ESS: validate firmware version for battery control (#19902)
This commit is contained in:
parent
7ff82549a8
commit
ddd44b72ab
4 changed files with 86 additions and 1 deletions
|
|
@ -82,7 +82,9 @@ func NewLgEss(uri, usage, registration, password string, cache time.Duration, ca
|
|||
var setBatteryMode func(api.BatteryMode) error
|
||||
if usage == "battery" {
|
||||
batterySoc = m.batterySoc
|
||||
setBatteryMode = m.batteryMode(battery)
|
||||
if version, err := conn.GetFirmwareVersion(); err == nil && version >= 7433 {
|
||||
setBatteryMode = m.batteryMode(battery)
|
||||
}
|
||||
}
|
||||
|
||||
return decorateLgEss(m, totalEnergy, batterySoc, setBatteryMode, capacity), nil
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -152,6 +153,29 @@ func (m *Com) essInfo() (EssData, error) {
|
|||
return res, err
|
||||
}
|
||||
|
||||
func (m *Com) GetSystemInfo() (SystemInfoResponse, error) {
|
||||
f := func(payload any) (*http.Request, error) {
|
||||
uri := fmt.Sprintf("%s/v1/user/setting/systeminfo", m.uri)
|
||||
return request.New(http.MethodPost, uri, request.MarshalJSON(payload), request.JSONEncoding)
|
||||
}
|
||||
var res SystemInfoResponse
|
||||
err := m.request(f, nil, &res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (m *Com) GetFirmwareVersion() (int, error) {
|
||||
systemInfo, err := m.GetSystemInfo()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// extract the patch number behind a dot that is always followed by at least 4 digits
|
||||
if match := regexp.MustCompile(`.(\d{4})`).FindStringSubmatch(systemInfo.Version.PMSVersion); len(match) > 1 {
|
||||
return strconv.Atoi(match[1])
|
||||
}
|
||||
|
||||
return 0, errors.New("firmware version not found")
|
||||
}
|
||||
|
||||
// BatteryMode sets the battery mode
|
||||
func (m *Com) BatteryMode(mode string, soc int, autocharge bool) error {
|
||||
var res struct{}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,59 @@ type MeterResponse8 struct {
|
|||
}
|
||||
}
|
||||
|
||||
type SystemInfoResponse struct {
|
||||
Battery BatteryInfo `json:"batt"`
|
||||
PMS PMS `json:"pms"`
|
||||
Version Version `json:"version"`
|
||||
}
|
||||
|
||||
type BatteryInfo struct {
|
||||
Capacity int `json:"capacity,string"`
|
||||
HBCAPackDates string `json:"hbc_a_pack_dates"`
|
||||
HBCASerials string `json:"hbc_a_serials"`
|
||||
HBCBPackDates string `json:"hbc_b_pack_dates"`
|
||||
HBCBSerials string `json:"hbc_b_serials"`
|
||||
HBCChgCap1 int `json:"hbc_chg_cap_1,string"`
|
||||
HBCChgCap2 int `json:"hbc_chg_cap_2,string"`
|
||||
HBCChgEnergy1 int `json:"hbc_chg_energy_1,string"`
|
||||
HBCChgEnergy2 int `json:"hbc_chg_energy_2,string"`
|
||||
HBCCycleCount1 int `json:"hbc_cycle_count_1,string"`
|
||||
HBCCycleCount2 int `json:"hbc_cycle_count_2,string"`
|
||||
HBCDeepDischgCnt1 int `json:"hbc_deep_dischg_cnt_1,string"`
|
||||
HBCDeepDischgCnt2 int `json:"hbc_deep_dischg_cnt_2,string"`
|
||||
HBCDischgCap1 int `json:"hbc_dischg_cap_1,string"`
|
||||
HBCDischgCap2 int `json:"hbc_dischg_cap_2,string"`
|
||||
HBCDischgEnergy1 int `json:"hbc_dischg_energy_1,string"`
|
||||
HBCDischgEnergy2 int `json:"hbc_dischg_energy_2,string"`
|
||||
HBCDischgRate1 int `json:"hbc_dischg_rate_1,string"`
|
||||
HBCDischgRate2 int `json:"hbc_dischg_rate_2,string"`
|
||||
HBCOVerChgCnt1 int `json:"hbc_over_chg_cnt_1,string"`
|
||||
HBCOVerChgCnt2 int `json:"hbc_over_chg_cnt_2,string"`
|
||||
HBCRemainingCap1 int `json:"hbc_remaining_cap_1,string"`
|
||||
HBCRemainingCap2 int `json:"hbc_remaining_cap_2,string"`
|
||||
InstallDate string `json:"install_date"`
|
||||
NameplateEnergy1 int `json:"nameplate_energy_1,string"`
|
||||
NameplateEnergy2 int `json:"nameplate_energy_2,string"`
|
||||
BatteryType string `json:"type"`
|
||||
}
|
||||
|
||||
type PMS struct {
|
||||
ACInputPower int `json:"ac_input_power,string"`
|
||||
ACOutputPower int `json:"ac_output_power,string"`
|
||||
InstallDate string `json:"install_date"`
|
||||
Model string `json:"model"`
|
||||
SerialNo string `json:"serialno"`
|
||||
}
|
||||
|
||||
type Version struct {
|
||||
BMSUnit1Version string `json:"bms_unit1_version"`
|
||||
BMSUnit2Version string `json:"bms_unit2_version"`
|
||||
BMSVersion string `json:"bms_version"`
|
||||
PCSVersion string `json:"pcs_version"`
|
||||
PMSBuildDate string `json:"pms_build_date"`
|
||||
PMSVersion string `json:"pms_version"`
|
||||
}
|
||||
|
||||
func (m MeterResponse8) GetGridPower() float64 {
|
||||
if m.Direction.IsGridSelling > 0 {
|
||||
return -m.Statistics.GridPower
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ products:
|
|||
description:
|
||||
generic: ESS Home 8/10
|
||||
capabilities: ["battery-control"]
|
||||
requirements:
|
||||
description:
|
||||
en: >
|
||||
To use the battery control, a firmware version greater than or equal to 10.05.7433 / R2155 is required
|
||||
de: >
|
||||
Um die Batteriesteuerung zu nutzen, wird eine Firmwareversionen größer gleich 10.05.7433 / R2155 benötigt
|
||||
params:
|
||||
- name: usage
|
||||
choice: ["grid", "pv", "battery"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue