Modbus: fix 5a7e9fa point decoding
This commit is contained in:
parent
5a7e9fa56d
commit
4ec931d8ed
3 changed files with 6 additions and 7 deletions
|
|
@ -3,7 +3,6 @@ package meter
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
|
|
@ -94,14 +93,14 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
device: device,
|
||||
}
|
||||
|
||||
if err := modbus.ParseOperation(device, strings.ToLower(cc.Power), &m.opPower); err != nil {
|
||||
if err := modbus.ParseOperation(device, cc.Power, &m.opPower); err != nil {
|
||||
return nil, fmt.Errorf("invalid measurement for power: %s", cc.Power)
|
||||
}
|
||||
|
||||
// decorate energy reading
|
||||
var totalEnergy func() (float64, error)
|
||||
if cc.Energy != "" {
|
||||
if err := modbus.ParseOperation(device, strings.ToLower(cc.Energy), &m.opEnergy); err != nil {
|
||||
if err := modbus.ParseOperation(device, cc.Energy, &m.opEnergy); err != nil {
|
||||
return nil, fmt.Errorf("invalid measurement for energy: %s", cc.Energy)
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +118,7 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
for _, cc := range cc.Currents {
|
||||
var opCurrent modbus.Operation
|
||||
|
||||
if err := modbus.ParseOperation(device, strings.ToLower(cc), &opCurrent); err != nil {
|
||||
if err := modbus.ParseOperation(device, cc, &opCurrent); err != nil {
|
||||
return nil, fmt.Errorf("invalid measurement for current: %s", cc)
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +135,7 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
// decorate soc reading
|
||||
var soc func() (float64, error)
|
||||
if cc.SoC != "" {
|
||||
if err := modbus.ParseOperation(device, strings.ToLower(cc.SoC), &m.opSoC); err != nil {
|
||||
if err := modbus.ParseOperation(device, cc.SoC, &m.opSoC); err != nil {
|
||||
return nil, fmt.Errorf("invalid measurement for soc: %s", cc.SoC)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func NewModbusFromConfig(other map[string]interface{}) (IntProvider, error) {
|
|||
|
||||
// model + value configured
|
||||
if cc.Value != "" {
|
||||
if err := modbus.ParseOperation(device, strings.ToLower(cc.Value), &op); err != nil {
|
||||
if err := modbus.ParseOperation(device, cc.Value, &op); err != nil {
|
||||
return nil, fmt.Errorf("invalid value %s", cc.Value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ type Operation struct {
|
|||
// ParseOperation parses an MBMD measurement or SunsSpec point definition into a modbus operation
|
||||
func ParseOperation(dev meters.Device, measurement string, op *Operation) (err error) {
|
||||
// if measurement cannot be parsed it could be SunSpec model/block/point
|
||||
if op.MBMD.IEC61850, err = meters.MeasurementString(measurement); err != nil {
|
||||
if op.MBMD.IEC61850, err = meters.MeasurementString(strings.ToLower(measurement)); err != nil {
|
||||
op.SunSpec.Model, op.SunSpec.Block, op.SunSpec.Point, err = ParsePoint(measurement)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue