evcc-io / evcc

Sonne tanken β˜€οΈπŸš˜
https://evcc.io
MIT License
3.31k stars 605 forks source link

Mercedes not showing SoC #9210

Closed dm82m closed 1 year ago

dm82m commented 1 year ago

Describe the bug

Login works incl. redirect but SoC of car cannot be retrieved and gives a token expired and refresh token is not set

Steps to reproduce

  1. Use the current config
  2. Start evcc
  3. Login car b-klasse

Configuration details

network:
  # schema is the HTTP schema
  # setting to `https` does not enable https, it only changes the way URLs are generated
  schema: http
  # host is the hostname or IP address
  # if the host name contains a `.local` suffix, the name will be announced on MDNS
  # docker: MDNS announcements don't work. host must be set to the docker host's name.
  host: 192.168.178.4
  # port is the listening port for UI and api
  # evcc will listen on all available interfaces
  port: 7070

interval: 30s # control cycle interval

# sponsor token enables optional features (request at https://cloud.evcc.io)
sponsortoken: XXX

# telemetry enables aggregated statistics
#
# Telemetry allows collecting usage data (grid and green energy, charge power).
# Data is aggregated, no individual charging sessions are tracked. The collected,
# anonymous data can be retrieved using https://api.evcc.io.
#
# See https://github.com/evcc-io/evcc/pull/4343 or details.
#
# For time being, this is only available to sponsors, hence data is associated with
# the sponsor token's identity.
#
# telemetry: true

# log settings
log: debug
levels:
  site: debug
  lp-1: debug
  lp-2: debug
  cache: error
  db: error

# modbus proxy for allowing external programs to reuse the evcc modbus connection
# each entry will start a proxy instance at the given port speaking Modbus TCP and
# relaying to the given modbus downstream device (either TCP or RTU, RS485 or TCP)
modbusproxy:
  #  - port: 5200
  #    uri: solar-edge:502
  #    # rtu: true
  #    # readonly: true

# meter definitions
# name can be freely chosen and is used as reference when assigning meters to site and loadpoints
# for documentation see https://docs.evcc.io/docs/devices/meters
meters:
- type: template
  template: fronius-gen24
  usage: grid
  host: 192.168.178.5
  port: 502
  name: grid1
- type: template
  template: fronius-gen24
  usage: pv
  host: 192.168.178.5
  port: 502
  name: pv1
- type: template
  template: fronius-gen24
  usage: battery
  host: 192.168.178.5
  port: 502
  name: battery1

# 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: charger1
    type: template
    template: easee
    user: XXX
    password: XXX
    charger: XXX

# vehicle definitions
# name can be freely chosen and is used as reference when assigning vehicle to loadpoint
# for documentation see https://docs.evcc.io/docs/devices/vehicles
vehicles:
  - name: car1
    type: mercedes
    title: b-klasse
    capacity: 12 # kWh
    clientId: XXX
    clientSecret: XXX
    vin: XXX
    #onIdentify: # set defaults when vehicle is identified
    #  mode: pv # enable PV-charging when vehicle is identified
    #  minSoC: 0 # immediately charge to 0% regardless of mode unless "off" (disabled)
    #  targetSoC: 100 # limit charge to 90%

# site describes the EVU connection, PV and home battery
site:
  title: Home # display name for UI
  meters:
    grid: grid1 # grid meter
    pv: pv1 # list of pv inverters/ meters
    battery: battery1 # battery meter
  prioritySoC: 50 # give home battery priority up to this soc (empty to disable)
  bufferSoC: 80 # ignore home battery discharge above soc (empty to disable)
  residualPower: 100

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
  - title: Hof # display name for UI
    charger: charger1 # charger
    #meter: pv1 # charge meter
    mode: "off" # set default charge mode, use "off" to disable by default if charger is publicly available
    vehicle: car1 # set default vehicle (disables vehicle detection)
    resetOnDisconnect: true # set defaults when vehicle disconnects
    soc:
      # polling defines usage of the vehicle APIs
      # Modifying the default settings it NOT recommended. It MAY deplete your vehicle's battery
      # or lead to vehicle manufacturer banning you from API use. USE AT YOUR OWN RISK.
      poll:
        # poll mode defines under which condition the vehicle API is called:
        #   charging: update vehicle ONLY when charging (this is the recommended default)
        #   connected: update vehicle when connected (not only charging), interval defines how often
        #   always: always update vehicle regardless of connection state, interval defines how often (only supported for single vehicle)
        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)
    phases: 0 # 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: 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)
    guardDuration: 5m # switch charger contactor not more often than this (default 5m)
    minCurrent: 6 # minimum charge current (default 6A)
    maxCurrent: 16 # maximum charge current (default 16A)

# tariffs are the fixed or variable tariffs
# cheap (tibber/awattar) can be used to define a tariff rate considered cheap enough for charging
tariffs:
  currency: EUR # three letter ISO-4217 currency code (default EUR)
  grid:
    # either static grid price
    type: fixed
    price: 0.294 # EUR/kWh

    # # or variable via tibber
    # type: tibber
    # cheap: 0.2 # EUR/kWh
    # token: "476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4" # access token
    # homeid: "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c" # optional if multiple homes associated to account

    # # or variable via awattar
    # type: awattar
    # cheap: 0.2 # EUR/kWh
    # region: de # optional, choose at for Austria
  feedin:
    # rate for feeding excess (pv) energy to the grid
    type: fixed
    price: 0.08 # EUR/kWh

# mqtt message broker
mqtt:
  # broker: localhost:1883
  # topic: evcc # root topic for publishing, set empty to disable
  # user:
  # password:

# influx database
influx:
  # url: http://localhost:8086
  # database: evcc
  # user:
  # password:

# eebus credentials
eebus:
  # uri: # :4712
  # interfaces: # limit eebus to specific network interfaces
  # - en0
  # certificate: # local signed certificate, required, can be generated via `evcc eebus-cert`
  #   public: # public key
  #   private: # private key

# push messages
messaging:
  events:
    start: # charge start event
      title: Charge started
      msg: Started charging in "${mode}" mode
    stop: # charge stop event
      title: Charge finished
      msg: Finished charging ${chargedEnergy:%.1fk}kWh in ${chargeDuration}.
    connect: # vehicle connect event
      title: Car connected
      msg: "Car connected at ${pvPower:%.1fk}kW PV"
    disconnect: # vehicle connected event
      title: Car disconnected
      msg: Car disconnected after ${connectedDuration}
    soc: # vehicle soc update event
      title: SoC updated
      msg: Battery charged to ${vehicleSoC:%.0f}%
    guest: # vehicle could not be identified
      title: Unknown vehicle
      msg: Unknown vehicle, guest connected?
  services:
  # - type: pushover
  #   app: # app id
  #   recipients:
  #   - # list of recipient ids
  # - type: telegram
  #   token: # bot id
  #   chats:
  #   - # list of chat ids
  # - type: email
  #   uri: smtp://<user>:<password>@<host>:<port>/?fromAddress=<from>&toAddresses=<to>
  # - type: ntfy
  #   uri: https://<host>/<topics>
  #   priority: <priority>
  #   tags: <tags>

Log details

Using config file: /config/evcc.yaml
starting evcc: 'EVCC_DATABASE_DSN=/data/evcc.db evcc --config /config/evcc.yaml'
[main  ] INFO 2023/08/01 20:32:06 evcc 0.118.11
[main  ] INFO 2023/08/01 20:32:06 using config file: /config/evcc.yaml
[main  ] INFO 2023/08/01 20:32:06 starting ui and api at :7070
[site  ] INFO 2023/08/01 20:32:17 site config:
[site  ] INFO 2023/08/01 20:32:17   meters:      grid βœ“ pv βœ“ battery βœ“
[site  ] INFO 2023/08/01 20:32:17     grid:      power βœ“ energy βœ“ currents βœ“
[site  ] INFO 2023/08/01 20:32:17     pv 1:      power βœ“ energy βœ“ currents βœ—
[site  ] INFO 2023/08/01 20:32:17     battery 1: power βœ“ energy βœ— currents βœ— soc βœ“ capacity βœ—
[site  ] INFO 2023/08/01 20:32:17   vehicles:
[site  ] INFO 2023/08/01 20:32:17     vehicle 1: range βœ“ finish βœ— status βœ— climate βœ— wakeup βœ—
[lp-1  ] INFO 2023/08/01 20:32:17 loadpoint 1:
[lp-1  ] INFO 2023/08/01 20:32:17   mode:        off
[lp-1  ] INFO 2023/08/01 20:32:17   charger:     power βœ“ energy βœ“ currents βœ“ phases βœ“ wakeup βœ—
[lp-1  ] INFO 2023/08/01 20:32:17   meters:      charge βœ“
[lp-1  ] INFO 2023/08/01 20:32:17     charge:    power βœ“ energy βœ“ currents βœ“
[lp-1  ] DEBUG 2023/08/01 20:32:17 phase timer inactive
[lp-1  ] DEBUG 2023/08/01 20:32:17 pv timer inactive
[lp-1  ] DEBUG 2023/08/01 20:32:17 guard timer inactive
[lp-1  ] INFO 2023/08/01 20:32:17 vehicle updated: unknown -> b-klasse
[main  ] INFO 2023/08/01 20:32:17 ensure the oauth client redirect/callback is configured for b-klasse: http://192.168.178.4:7070/oauth/vehicles/1/callback
[site  ] DEBUG 2023/08/01 20:32:17 ----
[lp-1  ] DEBUG 2023/08/01 20:32:17 charge power: 0W
[site  ] DEBUG 2023/08/01 20:32:17 pv power: 113W
[site  ] DEBUG 2023/08/01 20:32:17 battery soc: 97%
[site  ] DEBUG 2023/08/01 20:32:17 battery power: 308W
[site  ] DEBUG 2023/08/01 20:32:17 grid power: -12W
[site  ] DEBUG 2023/08/01 20:32:17 grid currents: [-0.601 2.11 -0.562]A
[site  ] DEBUG 2023/08/01 20:32:17 site power: 396W
[lp-1  ] DEBUG 2023/08/01 20:32:17 charge currents: [0.009 0.01 0.013]A
[lp-1  ] DEBUG 2023/08/01 20:32:17 charge total import: 508.743kWh
[lp-1  ] DEBUG 2023/08/01 20:32:17 charger status: B
[lp-1  ] INFO 2023/08/01 20:32:17 car connected
[lp-1  ] DEBUG 2023/08/01 20:32:17 pv timer elapse
[lp-1  ] DEBUG 2023/08/01 20:32:17 pv timer inactive
[lp-1  ] DEBUG 2023/08/01 20:32:17 charger: guard elapse
[lp-1  ] DEBUG 2023/08/01 20:32:17 guard timer inactive
[lp-1  ] DEBUG 2023/08/01 20:32:17 charge total import: 508.743kWh
[lp-1  ] DEBUG 2023/08/01 20:32:17 charger vehicle id: 9EE933F9
[lp-1  ] ERROR 2023/08/01 20:32:17 vehicle soc: Get "https://api.mercedes-benz.com/vehicledata/v2/vehicles/XXX/containers/electricvehicle": oauth2: token expired and refresh token is not set
[mercedes] DEBUG 2023/08/01 20:32:27 callback request received
[site  ] DEBUG 2023/08/01 20:32:47 ----
[lp-1  ] DEBUG 2023/08/01 20:32:47 charge power: 0W
[site  ] DEBUG 2023/08/01 20:32:47 pv power: 111W
[site  ] DEBUG 2023/08/01 20:32:47 battery soc: 97%
[site  ] DEBUG 2023/08/01 20:32:47 battery power: 297W
[site  ] DEBUG 2023/08/01 20:32:47 grid power: 14W
[site  ] DEBUG 2023/08/01 20:32:47 grid currents: [-0.594 2.15 -0.551]A
[site  ] DEBUG 2023/08/01 20:32:47 site power: 411W
[lp-1  ] DEBUG 2023/08/01 20:32:47 charge currents: [0.009 0.01 0.013]A
[lp-1  ] DEBUG 2023/08/01 20:32:47 charge total import: 508.743kWh
[lp-1  ] DEBUG 2023/08/01 20:32:47 charger status: B

What type of operating system are you running?

HomeAssistant Add-on

Version

0.118.11

andig commented 1 year ago

The log tells me that the initial login is performed. From that moment on it should work. If not please use the ui login.

dm82m commented 1 year ago

UI Login works but SoC is still not shown:

dm82m commented 1 year ago

IMG_5136

dm82m commented 1 year ago

@andig can you please reopen

andig commented 1 year ago

We need a vehicle trace log.

dm82m commented 1 year ago

How to create one? I put

log: debug
levels:
  car1: trace

Restarted evcc but result is the same.

andig commented 1 year ago
mercedes: trace
dm82m commented 1 year ago

Nothing with Mercedes debug or trace apart of that after I use the login of β€žb-klasseβ€œ in evcc menu:

[mercedes] DEBUG 2023/08/02 06:39:35 callback request received
[mercedes] TRACE 2023/08/02 06:39:36 sending login update...
dm82m commented 1 year ago

@andig it works now. replugging the charger cable solved it. :D