Ocpp: fix measurands (#15244)
This commit is contained in:
parent
7cf71855c1
commit
42edde9aa3
4 changed files with 12 additions and 15 deletions
|
|
@ -91,12 +91,12 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
|
|||
}
|
||||
|
||||
var currentsG func() (float64, float64, float64, error)
|
||||
if c.hasMeasurement(types.MeasurandCurrentImport + ".L3") {
|
||||
if c.hasMeasurement(types.MeasurandCurrentImport) {
|
||||
currentsG = c.currents
|
||||
}
|
||||
|
||||
var voltagesG func() (float64, float64, float64, error)
|
||||
if c.hasMeasurement(types.MeasurandVoltage + ".L3") {
|
||||
if c.hasMeasurement(types.MeasurandVoltage) {
|
||||
voltagesG = c.voltages
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,8 +203,6 @@ func (conn *Connector) GetMaxCurrent() (float64, error) {
|
|||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
var _ api.Meter = (*Connector)(nil)
|
||||
|
||||
func (conn *Connector) CurrentPower() (float64, error) {
|
||||
if !conn.cp.Connected() {
|
||||
return 0, api.ErrTimeout
|
||||
|
|
@ -230,8 +228,6 @@ func (conn *Connector) CurrentPower() (float64, error) {
|
|||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
var _ api.MeterEnergy = (*Connector)(nil)
|
||||
|
||||
func (conn *Connector) TotalEnergy() (float64, error) {
|
||||
if !conn.cp.Connected() {
|
||||
return 0, api.ErrTimeout
|
||||
|
|
@ -267,8 +263,7 @@ func (conn *Connector) Soc() (float64, error) {
|
|||
}
|
||||
|
||||
if m, ok := conn.measurements[types.MeasurandSoC]; ok {
|
||||
f, err := strconv.ParseFloat(m.Value, 64)
|
||||
return scale(f, m.Unit) / 1e3, err
|
||||
return strconv.ParseFloat(m.Value, 64)
|
||||
}
|
||||
|
||||
return 0, api.ErrNotAvailable
|
||||
|
|
@ -286,11 +281,9 @@ func scale(f float64, scale types.UnitOfMeasure) float64 {
|
|||
}
|
||||
|
||||
func getPhaseKey(key types.Measurand, phase int) types.Measurand {
|
||||
return key + types.Measurand("@L"+strconv.Itoa(phase))
|
||||
return key + types.Measurand(".L"+strconv.Itoa(phase))
|
||||
}
|
||||
|
||||
var _ api.PhaseCurrents = (*Connector)(nil)
|
||||
|
||||
func (conn *Connector) Currents() (float64, float64, float64, error) {
|
||||
if !conn.cp.Connected() {
|
||||
return 0, 0, 0, api.ErrTimeout
|
||||
|
|
@ -343,9 +336,13 @@ func (conn *Connector) Voltages() (float64, float64, float64, error) {
|
|||
voltages := make([]float64, 0, 3)
|
||||
|
||||
for phase := 1; phase <= 3; phase++ {
|
||||
m, ok := conn.measurements[getPhaseKey(types.MeasurandVoltage, phase)]
|
||||
m, ok := conn.measurements[getPhaseKey(types.MeasurandVoltage, phase)+"-N"]
|
||||
if !ok {
|
||||
return 0, 0, 0, api.ErrNotAvailable
|
||||
// fallback for wrong voltage phase labeling
|
||||
m, ok = conn.measurements[getPhaseKey(types.MeasurandVoltage, phase)]
|
||||
if !ok {
|
||||
return 0, 0, 0, api.ErrNotAvailable
|
||||
}
|
||||
}
|
||||
|
||||
f, err := strconv.ParseFloat(m.Value, 64)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func (conn *Connector) StatusNotification(request *core.StatusNotificationReques
|
|||
|
||||
func getSampleKey(s types.SampledValue) types.Measurand {
|
||||
if s.Phase != "" {
|
||||
return s.Measurand + types.Measurand("@"+string(s.Phase))
|
||||
return s.Measurand + types.Measurand("."+string(s.Phase))
|
||||
}
|
||||
|
||||
return s.Measurand
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ params:
|
|||
render: |
|
||||
{{ include "ocpp" . }}
|
||||
{{- if ne .meter "false" }}
|
||||
metervalues: Current.Import.L1,Current.Import.L2,Current.Import.L3,Energy.Active.Import.Register,Power.Active.Import,Voltage.L1,Voltage.L2,Voltage.L3
|
||||
metervalues: Current.Import,Energy.Active.Import.Register,Power.Active.Import,Voltage
|
||||
meterinterval: {{ .meterinterval }}
|
||||
{{- end }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue