evcc-io / evcc

Sonne tanken ☀️🚘
https://evcc.io
MIT License
3.18k stars 572 forks source link

TWC3 with Model 3 Control Client.Timeout on API request #12600

Closed Shuflel closed 6 months ago

Shuflel commented 6 months ago

Describe the bug

Car does not respond to any API commands evcc sends but is able to retrieve information. Even unlocking or waking up the car does not help. Manually starting/stopping the charging or setting amperage via the tesla app works normally.

I was unable to find any information about the broken pipe error but it also disappears a few minutes after restarting evcc and only the API error remains.

Steps to reproduce

  1. Create tokens from tesla.evcc.io, allow permissions and install virtual key.
  2. Add access and refresh token to config and start evcc.
  3. Start charging in any mode.

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: homeassistant.local
  # port is the listening port for UI and api
  # evcc will listen on all available interfaces
  port: 7070

interval: 30s # control cycle interval. Interval <30s can lead to unexpected behavior, see https://docs.evcc.io/docs/reference/configuration/interval

# database configuration for persisting charge sessions and settings
# database:
#   type: sqlite
#   dsn: <path-to-db-file>

# sponsor token enables optional features (request at https://sponsor.evcc.io)
sponsortoken: XXX
plant: 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: info
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:
  - name: my_pv
    type: template
    template: sungrow-hybrid
    usage: pv

    # Modbus TCP
    modbus: tcpip
    id: 1
    host: 192.168.188.150 # Hostname
    port: 502 # Port

  - name: my_grid
    type: template
    template: sungrow-hybrid
    usage: grid

    # Modbus TCP
    modbus: tcpip
    id: 1
    host: 192.168.188.150 # Hostname
    port: 502 # Port

  - name: my_battery
    type: template
    template: sungrow-hybrid
    usage: battery

    # RS485 via TCP/IP (Modbus RTU)
    modbus: tcpip
    id: 1
    host: 192.168.188.150 # Hostname
    port: 502 # Port

# 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: my_charger
    type: template
    template: twc3
    host: 192.168.188.157 # IP-Adresse oder Hostname

# 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: my_car
    type: template
    template: tesla
    title: Tesla Model 3
    accessToken: XXX
    refreshToken: XXX
    vin: XXX # Erforderlich, wenn mehrere Fahrzeuge des Herstellers vorhanden sind (optional)
    capacity: 60
    control: true

# site describes the EVU connection, PV and home battery
site:
  title: Home # display name for UI
  meters:
    grid: my_grid # grid meter
    pv:
      - my_pv # list of pv inverters/ meters
    battery:
      - my_battery # list of battery meters
  residualPower: 100 # additional household usage margin
  #prioritySoc: 95 # give home battery priority up to this soc (empty to disable) [!! Wurde in Version 0.123.0 entfernt !!]
  #bufferSoc: 95 # continue charging on battery above soc (0 to disable) [!! Wurde in Version 0.123.0 entfernt !!]
  #bufferStartSoc: 0 # start charging on battery above soc (0 to disable) [!! Wurde in Version 0.123.0 entfernt !!]
  maxGridSupplyWhileBatteryCharging: 0 # ignore battery charging if AC consumption is above this value
  #smartCostLimit: 0 # set cost limit for automatic charging in PV mode [!! Wurde in Version 0.123.0 entfernt !!]

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
  - title: Garage # display name for UI
    charger: my_charger # charger
    #meter: my_pv # charge meter
    mode: "pv" # set default charge mode, use "off" to disable by default if charger is publicly available
    vehicle: my_car # set default vehicle (disables vehicle detection)
    #resetOnDisconnect: true # set defaults when vehicle disconnects [!! Wurde in Version 0.123.0 entfernt und ist nun dauerhaft "on" !!]
    #phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
    #minCurrent: 5 # minimum charge current (default 6A)
    #maxCurrent: 16 # maximum charge current (default 16A)

    # remaining settings are experts-only and best left at default values
    priority: 0 # relative priority for concurrent charging in PV mode with multiple loadpoints (higher values have higher priority)
    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: connected
        # 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)
    guardDuration: 5m # switch charger contactor not more often than this (default 5m)

# tariffs are the fixed or variable tariffs
tariffs:
  currency: EUR # three letter ISO-4217 currency code (default EUR)
  grid:
    # either static grid price (or price zones)
    type: fixed
    price: 0.49 # EUR/kWh

    # or variable tariffs
    # type: tibber
    # token: "476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4" # access token
    # homeid: "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c" # optional if multiple homes associated to account

    # type: awattar
    # region: de # optional, choose at for Austria
    # charges: # optional, additional charges per kWh
    # tax: # optional, additional tax (0.1 for 10%)

    # type: octopusenergy
    # tariff: AGILE-FLEX-22-11-25 # Tariff code
    # region: A # optional

    # type: elering # Nordpool
    # region: ee # or lt, lv, fi
    # charges: # optional, additional charges per kWh
    # tax: # optional, additional tax (0.1 for 10%)

    # type: energinet # Energinet using the price in DKK
    # region: dk1 # or dk2
    # charges: # optional, additional charges per kWh
    # tax: # optional, additional tax (0.1 for 10%)

    # type: entsoe # Entso-E european market data
    # domain: BZN|DE-LU # https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html#_areas
    # securitytoken: # api token
    # charges: # optional, additional charges per kWh
    # tax: # optional, additional tax (0.1 for 10%)
  feedin:
    # rate for feeding excess (pv) energy to the grid
    type: fixed
    price: 0.08 # EUR/kWh

    # type: octopusenergy
    # tariff: AGILE-FLEX-22-11-25 # Tariff code
    # region: A # optional
  co2:
    # co2 tariff provides co2 intensity forecast and is for co2-optimized target charging if no variable grid tariff is specified
    # type: grünstromindex # GrünStromIndex (Germany only)
    # zip: <zip>

    # type: electricitymaps # https://app.electricitymaps.com/map
    # uri: <uri>
    # token: <token>
    # zone: DE

    # type: ngeso # National Grid Electricity System Operator data (United Kingdom only) https://carbonintensity.org.uk/
    # provides national data if both region and postcode are omitted - do not supply both at the same time!
    # region: 1 # optional, coarser than using a postcode - see https://api.carbonintensity.org.uk/ for full list
    # postcode: SW1A1AA # optional

# 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: Laden gestartet
      msg: Laden im "${mode}" Modus gestartet
    stop: # charge stop event
      title: Laden beendet
      msg: ${chargedEnergy:%.1fk}kWh in ${chargeDuration} geladen.
    connect: # vehicle connect event
      title: Fahrzeug verbunden
      msg: "Fahrzeug verbunden mit ${pvPower:%.1fk}kW PV"
    disconnect: # vehicle connected event
      title: Fahrzeug getrennt
      msg: Fahrzeug nach ${connectedDuration} getrennt
    soc: # vehicle soc update event
      title: Neuer Ladestand
      msg: Fahrzeug geladen bis ${vehicleSoc:%.0f}%
    guest: # vehicle could not be identified
      title: Unbekanntes Fahrzeug
      msg: Unbekanntes Fahrzeug, Gast verbunden?
  services:
    - type: pushover
      app: XXX
      recipients:
        - XXX
  # - 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 2024/03/02 14:31:16 evcc 0.124.6
[main  ] INFO 2024/03/02 14:31:16 using config file: /config/evcc.yaml
[main  ] INFO 2024/03/02 14:31:16 starting ui and api at :7070
[lp-1  ] WARN 2024/03/02 14:31:17 poll mode '{connected 1h0m0s}' may deplete your battery or lead to API misuse. USE AT YOUR OWN RISK.
[site  ] INFO 2024/03/02 14:31:17 site config:
[site  ] INFO 2024/03/02 14:31:17   meters:      grid ✓ pv ✓ battery ✓
[site  ] INFO 2024/03/02 14:31:17     grid:      power ✓ energy ✓ currents ✗
[site  ] INFO 2024/03/02 14:31:17     pv 1:      power ✓ energy ✓ currents ✗
[site  ] INFO 2024/03/02 14:31:17     battery 1: power ✓ energy ✓ currents ✗ soc ✓ capacity ✗
[site  ] INFO 2024/03/02 14:31:17   vehicles:
[site  ] INFO 2024/03/02 14:31:17     vehicle 1: range ✓ finish ✓ status ✓ climate ✗ wakeup ✓
[lp-1  ] INFO 2024/03/02 14:31:17 loadpoint 1:
[lp-1  ] INFO 2024/03/02 14:31:17   mode:        pv
[lp-1  ] INFO 2024/03/02 14:31:17   charger:     power ✓ energy ✗ currents ✓ phases ✗ wakeup ✗
[lp-1  ] INFO 2024/03/02 14:31:17   meters:      charge ✓
[lp-1  ] INFO 2024/03/02 14:31:17     charge:    power ✓ energy ✗ currents ✓
[site  ] DEBUG 2024/03/02 14:31:17 set buffer soc: 95
[site  ] DEBUG 2024/03/02 14:31:17 set buffer start soc: 99
[site  ] DEBUG 2024/03/02 14:31:17 set priority soc: 95
[site  ] DEBUG 2024/03/02 14:31:17 set battery discharge control: true
[lp-1  ] DEBUG 2024/03/02 14:31:17 phase timer inactive
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv timer inactive
[lp-1  ] INFO 2024/03/02 14:31:17 vehicle updated: unknown -> Tesla Model 3
[site  ] DEBUG 2024/03/02 14:31:17 ----
[lp-1  ] DEBUG 2024/03/02 14:31:17 charge power: 0W
[site  ] DEBUG 2024/03/02 14:31:17 pv power: 9945W
[site  ] DEBUG 2024/03/02 14:31:17 battery soc: 100%
[site  ] DEBUG 2024/03/02 14:31:17 battery power: 0W
[site  ] DEBUG 2024/03/02 14:31:17 grid meter: -9674W
[site  ] DEBUG 2024/03/02 14:31:17 site power: -9574W
[lp-1  ] DEBUG 2024/03/02 14:31:17 vehicle odometer: 35168km
[lp-1  ] DEBUG 2024/03/02 14:31:17 charge voltages: [3.8 0 0.5]V
[lp-1  ] DEBUG 2024/03/02 14:31:17 charge currents: [0 0.4 0]A
[lp-1  ] DEBUG 2024/03/02 14:31:17 charger status: B
[lp-1  ] INFO 2024/03/02 14:31:17 car connected
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv timer elapse
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv timer inactive
[lp-1  ] DEBUG 2024/03/02 14:31:17 vehicle status: B
[lp-1  ] DEBUG 2024/03/02 14:31:17 vehicle soc: 79%
[lp-1  ] DEBUG 2024/03/02 14:31:17 vehicle soc limit: 100%
[lp-1  ] DEBUG 2024/03/02 14:31:17 vehicle range: 337km
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv charge current: 13.9A = 0A + 13.9A (-9574W @ 3p)
[lp-1  ] DEBUG 2024/03/02 14:31:17 site power -9574W <= 0W enable threshold
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv enable in 0s
[lp-1  ] DEBUG 2024/03/02 14:31:17 pv enable timer elapsed
[lp-1  ] ERROR 2024/03/02 14:31:27 max charge current 5A: Post "https://tesla.evcc.io/api/1/vehicles/XXX/command/set_charging_amps": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
[site  ] ERROR 2024/03/02 14:31:27 battery mode: write tcp 192.168.188.172:41410->192.168.188.150:502: write: broken pipe
[site  ] DEBUG 2024/03/02 14:31:47 ----
[lp-1  ] DEBUG 2024/03/02 14:31:47 charge power: 0W
[site  ] DEBUG 2024/03/02 14:31:47 pv power: 9493W
[site  ] DEBUG 2024/03/02 14:31:47 battery soc: 100%
[site  ] DEBUG 2024/03/02 14:31:47 battery power: 0W
[site  ] DEBUG 2024/03/02 14:31:47 grid meter: -9215W
[site  ] DEBUG 2024/03/02 14:31:47 site power: -9115W
[lp-1  ] DEBUG 2024/03/02 14:31:47 vehicle odometer: 35168km
[lp-1  ] DEBUG 2024/03/02 14:31:47 charge voltages: [3.8 0 0.5]V
[lp-1  ] DEBUG 2024/03/02 14:31:47 charge currents: [0 0.4 0]A
[lp-1  ] DEBUG 2024/03/02 14:31:47 charger status: B
[lp-1  ] DEBUG 2024/03/02 14:31:47 next soc poll remaining time: 59m30s
[lp-1  ] DEBUG 2024/03/02 14:31:47 pv charge current: 13.2A = 0A + 13.2A (-9115W @ 3p)
[lp-1  ] DEBUG 2024/03/02 14:31:47 site power -9115W <= 0W enable threshold
[lp-1  ] DEBUG 2024/03/02 14:31:47 pv enable in 0s
[lp-1  ] DEBUG 2024/03/02 14:31:47 pv enable timer elapsed
[lp-1  ] ERROR 2024/03/02 14:31:57 max charge current 5A: Post "https://tesla.evcc.io/api/1/vehicles/XXX/command/set_charging_amps": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
[site  ] ERROR 2024/03/02 14:31:57 battery mode: write tcp 192.168.188.172:54740->192.168.188.150:502: write: broken pipe
[site  ] DEBUG 2024/03/02 14:32:17 ----
[lp-1  ] DEBUG 2024/03/02 14:32:17 charge power: 0W
[site  ] DEBUG 2024/03/02 14:32:17 pv power: 9295W
[site  ] DEBUG 2024/03/02 14:32:17 battery soc: 100%
[site  ] DEBUG 2024/03/02 14:32:17 battery power: 0W
[site  ] DEBUG 2024/03/02 14:32:17 grid meter: -9022W
[site  ] DEBUG 2024/03/02 14:32:17 site power: -8922W
[lp-1  ] DEBUG 2024/03/02 14:32:17 charge voltages: [3.8 0 0.5]V
[lp-1  ] DEBUG 2024/03/02 14:32:17 charge currents: [0 0.4 0]A
[lp-1  ] DEBUG 2024/03/02 14:32:17 charger status: B
[lp-1  ] DEBUG 2024/03/02 14:32:17 next soc poll remaining time: 59m0s
[lp-1  ] DEBUG 2024/03/02 14:32:17 pv charge current: 12.9A = 0A + 12.9A (-8922W @ 3p)
[lp-1  ] DEBUG 2024/03/02 14:32:17 site power -8922W <= 0W enable threshold
[lp-1  ] DEBUG 2024/03/02 14:32:17 pv enable in 0s
[lp-1  ] DEBUG 2024/03/02 14:32:17 pv enable timer elapsed
[lp-1  ] ERROR 2024/03/02 14:32:27 max charge current 5A: Post "https://tesla.evcc.io/api/1/vehicles/XXX/command/set_charging_amps": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
[site  ] ERROR 2024/03/02 14:32:27 battery mode: write tcp 192.168.188.172:42520->192.168.188.150:502: write: broken pipe

What type of operating system are you running?

HomeAssistant Add-on

Version

0.124.6

andig commented 6 months ago

@Shuflel ist das ein temporäres oder andauernes Problem? Wenn es auftritt- funktioniert parallel ein

evcc vehicle --log trace,db:error -i 5

Falls nein- könntest Du bitte testweise Zugangsdaten an info@evcc.io schicken? Ggf. ist das ein Überlastungsproblem mit unserem Proxyserver.

Shuflel commented 6 months ago

@Shuflel ist das ein temporäres oder andauernes Problem? Wenn es auftritt- funktioniert parallel ein

evcc vehicle --log trace,db:error -i 5

Falls nein- könntest Du bitte testweise Zugangsdaten an info@evcc.io schicken? Ggf. ist das ein Überlastungsproblem mit unserem Proxyserver.

Es ist ein andauerndes Problem. Ich bin zwar mit docker attach in den evcc Docker reingekommen, aber habe nicht wirklich Ahnung, wie ich den Befehl dort ausführen soll. Meinst du mit Zugangsdaten die beiden Tesla Tokens?

andig commented 6 months ago

Meinst du mit Zugangsdaten die beiden Tesla Tokens?

Ja bitte

Ich bin zwar mit docker attach in den evcc Docker reingekommen, aber habe nicht wirklich Ahnung, wie ich den Befehl dort ausführen soll.

Du kannst das auch auf jedem anderen Rechner machen (oder ich schau's mir an...)

Shuflel commented 6 months ago

Meinst du mit Zugangsdaten die beiden Tesla Tokens?

Ja bitte

Ich bin zwar mit docker attach in den evcc Docker reingekommen, aber habe nicht wirklich Ahnung, wie ich den Befehl dort ausführen soll.

Du kannst das auch auf jedem anderen Rechner machen (oder ich schau's mir an...)

Klar... blöd von mir. Ich habe dir mal die Tokens und den Output des Befehls an die Mail Adresse geschickt.

andig commented 6 months ago

@Shuflel in Deinem Fall antwortet tatsächlich das Tesla API nichts. Wir können daran erstmal nichts ändern- Issue ist unter https://github.com/teslamotors/vehicle-command/issues/200 erstellt.

Shuflel commented 5 months ago

@andig Du kannst das Issue bei Tesla schließen...

Der Virtual Key war zwar auf dem Fahrzeug installiert und wurde auch unter den Schlüsseln aufgelistet, aber hat dem Wagen oder der API wohl trotzdem nicht gefallen.

  1. Virtual Key gelöscht
  2. Tesla mit den beiden Knöpfen am Lenkrad neu gestartet
  3. Tokens neu erstellt und Virtual Key nochmal installiert

Jetzt gehen die Proxy Befehle vernünftig durch. Danke für deine Hilfe :)

andig commented 5 months ago

Ich lasse das mal auf- das wäre ja trotzdem ein Bug bei Tesla...