Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPP: Energy meter value not parsed/identified by EVCC #19351

Closed
2 tasks done
tafx opened this issue Mar 2, 2025 · 19 comments · Fixed by #19590
Closed
2 tasks done

OCPP: Energy meter value not parsed/identified by EVCC #19351

tafx opened this issue Mar 2, 2025 · 19 comments · Fixed by #19590
Assignees
Labels
devices Specific device support

Comments

@tafx
Copy link

tafx commented Mar 2, 2025

Describe the bug

EVCC does not recognize the value of energy meter from wallbox connected by OCPP, although the value "Energy.Active.Import.Register" is present in the message received from wallbox.
The wallbox is some cheap china product Sino Energy PEVC2107.
In the log is the message: "[lp-2 ] ERROR 2025/03/02 20:35:55 charge total import: not available ".

Different OCPP charger config parameters were tested (e.g. metervalues), cf. config file without success.
2 chargers of the same type are used and configured with the same issue.

Steps to reproduce

  1. Start EVCC with config below and wallbox conncected.
  2. Look at log.
  3. Alternatively plug EV, initialize charging and see that charged energy is not reported during the session.

evcc-20250302-201859-trace.log

Configuration details

network:
  schema: http
  host: evcc.local
  port: 7070
interval: 10s # control cycle interval. Interval <30s can lead to unexpected behavior, see https://docs.evcc.io/docs/reference/configuration/interval
# log settings
log: debug
levels:
  site: debug
  lp-1: debug
  lp-2: debug
  cache: error
  db: error

meters:
  - type: custom
    name: grid1
    power:
      source: mqtt
      topic: evcc/tometers/grid
      timeout: 30s
      scale: 1

  - name: pv1
    type: template
    template: deye-hybrid-3p
    usage: pv
    # RS485 via TCP/IP (Modbus RTU)
    modbus: tcpip
    id: 1
    host: xxx # Hostname
    port: xxx # Port

  - name: battery1
    type: template
    template: deye-hybrid-3p
    usage: battery
    # RS485 via TCP/IP (Modbus RTU)
    modbus: tcpip
    id: 1
    host: xxx # Hostname
    port: xxx # Port

  - type: custom
    name: Bojler
    power:
      source: mqtt
      topic: evcc/tometers/bojler_power
      timeout: 30s
      scale: 1
    energy:
      source: mqtt
      topic: evcc/tometers/bojler_energy
      timeout: 30s
      scale: 1

  - type: custom
    name: TC
    power:
      source: mqtt
      topic: evcc/tometers/tc_power
      timeout: 30s
      scale: 1
    energy:
      source: mqtt
      topic: evcc/tometers/tc_energy
      timeout: 30s
      scale: 1

  - type: custom
    name: ElKotel
    power:
      source: mqtt
      topic: evcc/tometers/elkotel_power
      timeout: 30s
      scale: 1
    energy:
      source: mqtt
      topic: evcc/tometers/elkotel_energy
      timeout: 30s
      scale: 1

  - type: custom
    name: Dum
    power:
      source: mqtt
      topic: evcc/tometers/dum_power
      timeout: 30s
      scale: 1

# charger definitions
# name can be freely chosen and is used as reference when assigning charger to vehicle
# for documentation see https://docs.evcc.io/docs/devices/chargers
chargers:
  - name: Wallbox1
    type: template
    template: ocpp
    stationid: 111
    #getconfiguration: false
    #timeout: 1m
    #nostop: true
    #autostart: true
    #connector: 1 # Connector number for charging stations with multiple connectors. Counting starts at 1 for the first connector. (optional)
    #remotestart: # Only enable this option if there is no way to initiate transactions from the charger side! This is only the case if e.g. no RFID reader is available and charging processes would have to be released individually via app. Normally, the charger should always be configured at the device so that either an RFID card is used for activation or the charger is set to "Autostart", "Free Charging" or similar. First check the documentation and configuration possibilities of the charger, ask the manufacturer if necessary! (optional)
    #idtag: evcc # This option is only required in exceptional cases if the charger requires a specific token for accepting external transactions. (optional)
    #connecttimeout: 1m # optional
    meterinterval: 10s # optional
    metervalues: Energy.Active.Import.Register,Power.Active.Import,Current.Import,Voltage # optional

  - name: Wallbox2
    type: template
    template: ocpp
    stationid: 222
    # getconfiguration: false
    #timeout: 1m
    #nostop: true
    #autostart: true
    #connector: 1 # Connector number for charging stations with multiple connectors. Counting starts at 1 for the first connector. (optional)
    #remotestart: # Only enable this option if there is no way to initiate transactions from the charger side! This is only the case if e.g. no RFID reader is available and charging processes would have to be released individually via app. Normally, the charger should always be configured at the device so that either an RFID card is used for activation or the charger is set to "Autostart", "Free Charging" or similar. First check the documentation and configuration possibilities of the charger, ask the manufacturer if necessary! (optional)
    #idtag: evcc # This option is only required in exceptional cases if the charger requires a specific token for accepting external transactions. (optional)
    #connecttimeout: 1m # optional
    #meterinterval: 10s # optional
    #metervalues: Energy.Active.Import.Register # optional

  - name: LK-Bojler
    type: custom
    features:
      - integrateddevice
      - heating
    icon: waterheater
    status: # charger status A..F
      source: mqtt
      topic: homeassistant/input_text/bojler_status/state
    enabled: # charger enabled state (true/false or 0/1)
      source: mqtt
      topic: homeassistant/input_text/bojler_enabled/state
    enable:
      source: mqtt
      topic: evcc/toha/bojler_enable

    maxcurrent: # set charger max current (A)
      source: mqtt
      topic: evcc/toha/bojler_maxcurrent
    soc:
      source: mqtt
      topic: evcc/tometers/bojler_dole
      timeout: 30s
      scale: 1

  - name: TC
    type: custom
    features:
      - integrateddevice
      - heating
    icon: heatpump
    status: # charger status A..F
      source: mqtt
      topic: homeassistant/input_text/tc_status/state
    enabled: # charger enabled state (true/false or 0/1)
      source: mqtt
      topic: homeassistant/input_text/tc_enabled/state
    enable:
      source: mqtt
      topic: evcc/toha/tc_enable
    maxcurrent: # set charger max current (A)
      source: mqtt
      topic: evcc/toha/tc_maxcurrent
    soc:
      source: mqtt
      topic: evcc/tometers/tc_aku_dole
      timeout: 30s
      scale: 1

  - name: LK-ElKotel
    type: custom
    features:
      - integrateddevice
      - heating
    icon: heater
    status: # charger status A..F
      source: mqtt
      topic: homeassistant/input_text/elkotel_status/state
    enabled: # charger enabled state (true/false or 0/1)
      source: mqtt
      topic: homeassistant/input_text/elkotel_enabled/state
    enable:
      source: mqtt
      topic: evcc/toha/elkotel_enable
    maxcurrent: # set charger max current (A)
      source: mqtt
      topic: evcc/toha/elkotel_maxcurrent
    soc:
      source: mqtt
      topic: evcc/tometers/tc_aku_dole
      timeout: 30s
      scale: 1

vehicles:

# site describes the EVU connection, PV and home battery
site:
  title: Domov # display name for UI
  meters:
    grid: grid1 # grid meter
    pv:
      - pv1 # list of pv inverters/ meters
    battery:
      - battery1 # list of battery meters

  residualPower: -300 # additional household usage margin
  maxGridSupplyWhileBatteryCharging: 0 # ignore battery charging if AC consumption is above this value

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
  - title: Levý WB (bouda) # display name for UI
    charger: Wallbox2 # charger
    #    meter: charge # charge meter
    mode: "pv" # default charge mode to apply when vehicle is disconnected; use "off" to disable by default if charger is publicly available

    # remaining settings are experts-only and best left at default values
    priority: 2 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    soc:
      poll:
        mode: charging
        # poll interval defines how often the vehicle API may be polled if NOT charging
        interval: 60m
      estimate: true # set false to disable interpolating between api updates (not recommended)
    enable: # pv mode enable behavior
      delay: 1m # threshold must be exceeded for this long
      threshold: 0 # grid power threshold (in Watts, negative=export). If zero, export must exceed minimum charge power to enable
    disable: # pv mode disable behavior
      delay: 3m # threshold must be exceeded for this long
      threshold: 0 # maximum import power (W)
    circuit: main

  - title: Pravý WB (dveře) # display name for UI
    charger: Wallbox1 # charger
    #    meter: charge # charge meter
    mode: "pv" # default charge mode to apply when vehicle is disconnected; use "off" to disable by default if charger is publicly available

    # remaining settings are experts-only and best left at default values
    priority: 4 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    soc:
      poll:
        mode: charging
        # poll interval defines how often the vehicle API may be polled if NOT charging
        interval: 60m
      estimate: true # set false to disable interpolating between api updates (not recommended)
    enable: # pv mode enable behavior
      delay: 1m # threshold must be exceeded for this long
      threshold: 0 # grid power threshold (in Watts, negative=export). If zero, export must exceed minimum charge power to enable
    disable: # pv mode disable behavior
      delay: 3m # threshold must be exceeded for this long
      threshold: 0 # maximum import power (W)
    circuit: main

  - title: Bojler # display name for UI
    charger: LK-Bojler # charger
    mode: "pv" # set default charge mode, use "off" to disable by default if charger is publicly available
    priority: 6 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    #    phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
    enable: # pv mode enable behavior
      delay: 5s # threshold must be exceeded for this long
      threshold: 0 # grid power threshold (in Watts, negative=export). If zero, export must exceed minimum charge power to enable
    disable: # pv mode disable behavior
      delay: 5s # threshold must be exceeded for this long
      threshold: 0 # maximum import power (W)
    guardDuration: 60s # switch charger contactor not more often than this (default 5m)
    #minCurrent: 1 # minimum charge current (default 6A)
    #maxCurrent: 10 # maximum charge current (default 16A)
    meter: Bojler
    circuit: main

  - title: Tepelné čerpadlo # display name for UI
    charger: TC # charger
    mode: "pv" # set default charge mode, use "off" to disable by default if charger is publicly available
    priority: 10 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    #    phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
    enable: # pv mode enable behavior
      delay: 60s # threshold must be exceeded for this long
      threshold: 0 # grid power threshold (in Watts, negative=export). If zero, export must exceed minimum charge power to enable
    disable: # pv mode disable behavior
      delay: 2m # threshold must be exceeded for this long
      threshold: 0 # maximum import power (W)
    guardDuration: 5m # switch charger contactor not more often than this (default 5m)
    #minCurrent: 1 # minimum charge current (default 6A)
    #maxCurrent: 10 # maximum charge current (default 16A)
    meter: TC
    circuit: main

  - title: Elektrokotel # display name for UI
    charger: LK-ElKotel # charger
    mode: "pv" # set default charge mode, use "off" to disable by default if charger is publicly available
    priority: 2 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    #    phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
    enable: # pv mode enable behavior
      delay: 5s # threshold must be exceeded for this long
      threshold: 0 # grid power threshold (in Watts, negative=export). If zero, export must exceed minimum charge power to enable
    disable: # pv mode disable behavior
      delay: 5s # threshold must be exceeded for this long
      threshold: 0 # maximum import power (W)
    guardDuration: 60s # switch charger contactor not more often than this (default 5m)
    #minCurrent: 1 # minimum charge current (default 6A)
    #maxCurrent: 10 # maximum charge current (default 16A)
    meter: ElKotel
    circuit: main

    # tariffs are the fixed or variable tariffs
tariffs:
  currency: CZK # three letter ISO-4217 currency code (default EUR)
  grid:
    # either static grid price (or price zones)
    type: fixed
    price: 7 # EUR/kWh
    zones:
      - days: Mon-Fri
        hours: 2-5
        price: 7 # EUR/kWh
      - days: Sat,Sun
        price: 7 # EUR/kWh

  feedin:
    # rate for feeding excess (pv) energy to the grid
    type: fixed
    price: 1.8 # EUR/kWh
  co2:
# mqtt message broker
mqtt:
  broker: localhost:1883
  topic: # root topic for publishing, set empty to disable
  user: xxx
  password: xxx

Log details

Log attached as a file.

What type of operating system or environment does evcc run on?

HomeAssistant Add-on

External automation

  • I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.

Nightly build

  • I have verified that the issue is reproducible with the latest nightly build

Version

0.200.5

@premultiply premultiply self-assigned this Mar 2, 2025
@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 2, 2025

The charging station rejects the measurand activation

[ocpp  ] TRACE 2025/03/02 20:14:23 send 222: [2,"496852054","ChangeConfiguration",{"key":"MeterValuesSampledData","value":"Energy.Active.Import.Register"}]
[ocpp  ] TRACE 2025/03/02 20:14:24 recv 222: [3,"496852054",{"status":"Rejected"}]

but still sends the data (and has it in the initial configuration message).

In case of Current.Import, it accepts the configuration.

@tafx
Copy link
Author

tafx commented Mar 3, 2025

Thanks for looking at it. Should I try to change config somehow? It was my guess that the wallbox has nonstandard responses. Is there any workaround?

@andig
Copy link
Member

andig commented Mar 3, 2025

You can set metervalues imho and evcc will trust those as „working“. Might also help to open a vendor ticket to get this fixed.

@andig andig added the devices Specific device support label Mar 3, 2025
@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 3, 2025

Was thinking this as well, but at least in the provided config, they are configured
metervalues: Energy.Active.Import.Register,Power.Active.Import,Current.Import,Voltage # optional

@tafx has the full log file been created with exactly this config?

@tafx
Copy link
Author

tafx commented Mar 3, 2025

Yes for the case of wallbox with id 111. The second wallbox (id 222) has minimal config. Results seem to me to be the same.
I already tried to set metervalues but without any effect. To be honest I dont know what each of config parameters mean as I found no reference to them.

@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 3, 2025

Oh, could you please temporarily remove the second charger and create new logs? It is not easy to get an overview when having to find out for each message to which charger it belongs.

@tafx
Copy link
Author

tafx commented Mar 4, 2025

Here is the new log with just one charger.

evcc-20250304-110350-trace.txt

@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 4, 2025

Think I found the issue:
The charger reports a phase with Energy.Active.Import.Register (which seems to be nonsense)
{"value":"824952","context":"Trigger","format":"Raw","measurand":"Energy.Active.Import.Register","phase":"L1","location":"Body","unit":"Wh"}

Evcc appends the phase to the key when storing the measurement

return s.Measurand + types.Measurand("."+string(s.Phase))

This leads to the situation that the measurement cannot be found later when looking for types.MeasurandEnergyActiveImportRegister

if m, ok := conn.measurements[types.MeasurandEnergyActiveImportRegister]; ok {

@andig
Copy link
Member

andig commented Mar 4, 2025

Seems vendor will need to fix this.

@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 4, 2025

While Ocpp specs are very vague about this

The phase field is not applicable to all Measurands.

it is quite obvious that it does not make real sense in case of this specific measurand.

@mfuchs1984
Copy link
Contributor

Still, seems to be easy to solve in evcc. Just fall back to phase measurements as it is done here

func (conn *Connector) CurrentPower() (float64, error) {

@tafx
Copy link
Author

tafx commented Mar 4, 2025

Thanks to both.
Understood. The problem is "phase":"L1" in the part specifiying total energy charged. So I try to find if there is any possibility to restrict content of the ocpp response. Probably there is no option.
I will try ask the vendor but they did not responded in the past regarding modbus register description so the only way will be to replace the wallboxes or add external meters.

@mfuchs1984
Copy link
Contributor

mfuchs1984 commented Mar 4, 2025

Created the pull request #19405, I think it might make this charger work while not hurting anyone else. Same is already implemented for Power.Active.Import.

@andig andig closed this as completed Mar 4, 2025
@mfuchs1984
Copy link
Contributor

@tafx you can try again with the next nightly build.

@tafx
Copy link
Author

tafx commented Mar 4, 2025

I am using the HA addon so I cant use nightly build right?

@mfuchs1984
Copy link
Contributor

I think it is possible, see https://docs.evcc.io/en/docs/installation/home-assistant#installation

But for quick testing, it might be simpler to just run the nightly on your normal computer with the same config as in home assistant (maybe without vehicle configuration).

Anyhow, you have to wait for the next nightly build.

The other option is to wait for the next release.

@tafx
Copy link
Author

tafx commented Mar 4, 2025

Thanks. I will report back at latest after next release.

@tafx
Copy link
Author

tafx commented Mar 8, 2025

Here is report after update 0.200.8: EVCC have the values from both wallboxes, but with wrong unit. In the part of the message the unit is correct {"value":"826199","context":"Trigger","format":"Raw","measurand":"Energy.Active.Import.Register","phase":"L1","location":"Body","unit":"Wh"}.
But EVCC did not account and reads the value as kWh. Could it be solved in EVCC please?

@andig
Copy link
Member

andig commented Mar 8, 2025

Excellent, here we go: #19590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devices Specific device support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants