Skip to content

Commit

Permalink
fix(configure): fixing map reference
Browse files Browse the repository at this point in the history
  • Loading branch information
atbore-phx committed Mar 11, 2024
1 parent 6edbab0 commit ab14ccc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Binary file modified home-assistant/addons/sbam/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified home-assistant/addons/sbam/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions pkg/fronius/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ var mdsc = map[uint16]int16{
ChaGriSet: 1, // Grid enabled
}

func copyMap(src map[uint16]int16) map[uint16]int16 {
dst := make(map[uint16]int16)
for k, v := range src {
dst[k] = v
}
return dst
}

func WriteFroniusModbusRegisters(modbusStorageCfg map[uint16]int16) error {

for r, v := range modbusStorageCfg {
Expand Down Expand Up @@ -68,7 +76,7 @@ func Setdefaults(modbus_ip string, port ...string) error {
p = port[0]
}
u.Log.Info("Setting Fronius Storage Defaults start...")
regList := mdsc
regList := copyMap(mdsc)
err = Connectmodbus(modbus_ip, regList, p)
if err != nil {
u.Log.Errorf("Something goes wrong %s", err)
Expand All @@ -85,7 +93,7 @@ func ForceCharge(modbus_ip string, power_prc int16, port ...string) error {
}
u.Log.Infof("Setting Fronius Storage Force Charge at %d%%", power_prc)
if power_prc > 0 {
regList := mdsc
regList := copyMap(mdsc)

regList[StorCtl_Mod] = 2 // Limit Decharging
regList[OutWRte] = -100 * power_prc
Expand Down

0 comments on commit ab14ccc

Please sign in to comment.