evcc-io / evcc

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

panic: runtime error: invalid memory address or nil pointer dereference #10576

Closed RikVerstijnen closed 1 year ago

RikVerstijnen commented 1 year ago

Describe the bug

Runtime error which makes the add-on crash.

Steps to reproduce

  1. Start add-on

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

interval: 10s # control cycle 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: 'xxxxx'

# 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: info
  lp-1: info
  lp-2: info
  cache: info
  db: info
  ocpp: info
  tibber-pulse: info
  tesla: info
  openevse: info

# 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: xxxxx
      uri: xxxxx

# 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_grid
#     type: template
#     template: tibber-pulse
#     usage: grid
#     token: xxxxx
#     homeid: xxxxx

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

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

  - name: pv_huis
    type: template
    template: solaredge-inverter
    usage: pv

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

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

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

#   - name: pv_garage
#     type: template
#     template: solaredge-inverter
#     usage: pv

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

  - name: my_charger_meter
    type: template
    template: shelly-3em
    usage: charge
    host: xxxxx # IP-Adresse oder Hostname 

# 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: openevse
    host: 192.168.2.205 # IP-Adresse oder Hostname
    user: xxxxx
    password: xxxxx

#   - name: my_charger
#     type: template
#     template: ocpp 

# 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: # Wird in der Benutzeroberfläche angezeigt (Optional)
    accessToken: xxxxx
    refreshToken: xxxxx
    vin: # Erforderlich, wenn mehrere Fahrzeuge des Herstellers vorhanden sind (Optional)
    capacity:  # Akkukapazität in kWh (Optional) 

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

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
  - title: EV lader # display name for UI
    charger: my_charger # charger
    vehicle: my_car
    mode: now
    meter: my_charger_meter # 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: false # set defaults when vehicle disconnects
    phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
    minCurrent: 6 # 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: 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)
    # 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.294 # EUR/kWh
    # zones:
    #   - days: Mo-Fr
    #     hours: 2-5
    #     price: 0.2 # EUR/kWh
    #   - days: Sa,So
    #     price: 0.15 # EUR/kWh

    # or variable via tibber
    type: tibber
    token: xxxxx # access token

    # # or variable via awattar
    # type: awattar
    # region: de # optional, choose at for Austria

  planner:
    # planner tariff can be used for target charging if not grid tariff is specified

    # GrünStromIndex (Germany only) or ElectricityMaps provide CO2 intensity forecast

    # type: grünstromindex
    # zip: <zip>
    type: tibber
    token: xxxxx # access token
    # type: electricitymaps
    # uri: <uri>
    # token: <token>
    # zone: DE

    # # or variable Nordpool via elering.ee (only for LT, LV, EE, FI)
    # type: elering
    # region: ee # or lt, lv, fi

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

# 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/10/30 13:52:06 evcc 0.121.5
[main  ] INFO 2023/10/30 13:52:06 using config file: /config/evcc.yaml
[main  ] INFO 2023/10/30 13:52:06 starting ui and api at :7070
[db    ] INFO 2023/10/30 13:52:06 using sqlite database: /data/evcc.db
[mqtt  ] INFO 2023/10/30 13:52:06 connecting evcc-226508584 at tcp://192.168.2.200:1883
[site  ] WARN 2023/10/30 13:52:13 battery configured but residualPower is missing or <= 0 (add residualPower: 100 to site), see https://docs.evcc.io/en/docs/reference/configuration/site#residualpower
[site  ] INFO 2023/10/30 13:52:13 site config:
[site  ] INFO 2023/10/30 13:52:13   meters:      grid ✓ pv ✓ battery ✓
[site  ] INFO 2023/10/30 13:52:13     grid:      power ✓ energy ✗ currents ✗
[site  ] INFO 2023/10/30 13:52:13     pv 1:      power ✓ energy ✗ currents ✗
[site  ] INFO 2023/10/30 13:52:13     battery 1: power ✓ energy ✗ currents ✗ soc ✓ capacity ✗
[site  ] INFO 2023/10/30 13:52:13   vehicles:
[site  ] INFO 2023/10/30 13:52:13     vehicle 1: range ✓ finish ✓ status ✓ climate ✗ wakeup ✓
[lp-1  ] INFO 2023/10/30 13:52:13 loadpoint 1:
[lp-1  ] INFO 2023/10/30 13:52:13   mode:        now
[lp-1  ] INFO 2023/10/30 13:52:13   charger:     power ✓ energy ✓ currents ✗ phases ✗ wakeup ✗
[lp-1  ] INFO 2023/10/30 13:52:13   meters:      charge ✓
[lp-1  ] INFO 2023/10/30 13:52:13     charge:    power ✓ energy ✓ currents ✓
[lp-1  ] INFO 2023/10/30 13:52:13 vehicle updated: unknown -> Rita
[site  ] WARN 2023/10/30 13:52:13 interval <30s can lead to unexpected behavior, see https://docs.evcc.io/docs/reference/configuration/interval
[lp-1  ] ERROR 2023/10/30 13:52:13 vehicle odometer: asleep
[lp-1  ] INFO 2023/10/30 13:52:13 car disconnected
[lp-1  ] ERROR 2023/10/30 13:59:03 charge timer: Get "http://192.168.2.205/status": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x17cad5b]

goroutine 199 [running]:
github.com/evcc-io/evcc/charger.(*OpenEVSE).Status(0xc00111ee38?)
    github.com/evcc-io/evcc/charger/openevse.go:156 +0xdb
github.com/evcc-io/evcc/core.(*Loadpoint).updateChargerStatus(0xc000798000)
    github.com/evcc-io/evcc/core/loadpoint.go:892 +0x3c
github.com/evcc-io/evcc/core.(*Loadpoint).Update(0xc000798000, 0x3ff0000000000000?, 0x0, 0x0?, 0x0?, 0x3ff0000000000000, 0xc0008fcd38, 0x0)
    github.com/evcc-io/evcc/core/loadpoint.go:1526 +0x212
github.com/evcc-io/evcc/core.(*Site).update(0xc0015b8800, {0x31cc5b8?, 0xc000798000})
    github.com/evcc-io/evcc/core/site.go:781 +0x67a
github.com/evcc-io/evcc/core.(*Site).Run(0xc0015b8800, 0xc000fd7860, 0x2540be400)
    github.com/evcc-io/evcc/core/site.go:875 +0x2e5
github.com/evcc-io/evcc/cmd.runRoot.func4()
    github.com/evcc-io/evcc/cmd/root.go:282 +0x25
created by github.com/evcc-io/evcc/cmd.runRoot in goroutine 1
    github.com/evcc-io/evcc/cmd/root.go:281 +0x1a13

What type of operating system are you running?

HomeAssistant Add-on

Version

0.121.5

andig commented 1 year ago

Closed in https://github.com/evcc-io/evcc/commit/70fdc88c609a54843eafaf0c274a81ff701b78c7. You will probably see an error message now. If that happens please run with --log trace and lets see the result.