Skip to content

Commit

Permalink
Merge pull request #5 from brianroch/fb/MoreSensors
Browse files Browse the repository at this point in the history
Adding purchase, selling and ratio sensors
  • Loading branch information
kubaceg authored Mar 1, 2023
2 parents fa50ee8 + b755c57 commit 6c8c565
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
sofar_g3_lsw3_logger_reader
config.yaml
sofar
sofar-arm
sofar-arm
.idea
4 changes: 2 additions & 2 deletions adapters/devices/sofar/lsw.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func readData(connPort ports.CommunicationPort, serialNumber uint) (map[string]i
result[k] = v
}

reply, err = readRegisterRange(rrPVGeneration, connPort, serialNumber)
reply, err = readRegisterRange(rrEnergyTodayTotals, connPort, serialNumber)
if err != nil {
return nil, err
}
Expand All @@ -121,7 +121,7 @@ func readData(connPort ports.CommunicationPort, serialNumber uint) (map[string]i
result[k] = v
}

reply, err = readRegisterRange(rrBatCharge, connPort, serialNumber)
reply, err = readRegisterRange(rrRatio, connPort, serialNumber)
if err != nil {
return nil, err
}
Expand Down
29 changes: 20 additions & 9 deletions adapters/devices/sofar/sofar_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,18 @@ var rrSystemInfo = registerRange{
{0x043A, "Fault27", "U16", "", ""},
},
}
var rrPVGeneration = registerRange{
var rrEnergyTodayTotals = registerRange{
start: 0x680,
end: 0x687,
end: 0x69B,
replyFields: []field{
{0x684, "PV_Generation_Today", "U32", "0.01", "kWh"},
{0x686, "PV_Generation_Total", "U32", "0.1", "kWh"},
},
}

var rrBatCharge = registerRange{
start: 0x680,
end: 0x69B,
replyFields: []field{
{0x688, "Load_Consumption_Today", "U32", "0.1", "kWh"},
{0x68A, "Load_Consumption_Total", "U32", "0.1", "kWh"},
{0x68C, "Energy_Purchase_Today", "U32", "0.1", "kWh"},
{0x68E, "Energy_Purchase_Total", "U32", "0.1", "kWh"},
{0x690, "Energy_Selling_Today", "U32", "0.1", "kWh"},
{0x692, "Energy_Selling_Total", "U32", "0.1", "kWh"},
{0x694, "Bat_Charge_Today", "U32", "0.01", "kWh"},
{0x696, "Bat_Charge_Total", "U32", "0.1", "kWh"},
{0x698, "Bat_Discharge_Today", "U32", "0.01", "kWh"},
Expand Down Expand Up @@ -191,3 +190,15 @@ var rrBatOutput = registerRange{
{0x0611, "ChargeCycle_Bat2", "U16", "1", ""},
},
}

var rrRatio = registerRange{
start: 0x1030,
end: 0x103D,
replyFields: []field{
{0x1039, "PV_Generation_Ratio", "U16", "0.001", ""},
{0x103A, "Energy_Purchase_Ratio", "U16", "0.001", ""},
{0x103B, "Energy_Selling_Ratio", "U16", "0.001", ""},
{0x103C, "Bat_Charge_Ratio", "U16", "0.001", ""},
{0x103D, "Bat_Discharge_Ratio", "U16", "0.001", ""},
},
}

0 comments on commit 6c8c565

Please sign in to comment.