evcc-io / evcc

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

panic: interface conversion: interface {} is nil, not string #9835

Closed eriwave closed 1 year ago

eriwave commented 1 year ago

Describe the bug

After updating evcc from 0.119.3 to 0.119.5 add-on doesn't start in HA, with the following log:

Using config file: /config/evcc.yaml
starting evcc: 'EVCC_DATABASE_DSN=/data/evcc.db evcc --config /config/evcc.yaml'
[main  ] INFO 2023/09/10 21:08:08 evcc 0.119.5
[main  ] INFO 2023/09/10 21:08:08 using config file: /config/evcc.yaml
[main  ] INFO 2023/09/10 21:08:08 starting ui and api at :7070
[lp-1  ] WARN 2023/09/10 21:08:13 locking phase config to 1p for switchable charger
[site  ] INFO 2023/09/10 21:08:13 site config:
[site  ] INFO 2023/09/10 21:08:13   meters:      grid ✓ pv ✓ battery ✗
[site  ] INFO 2023/09/10 21:08:13     grid:      power ✓ energy ✗ currents ✗
[site  ] INFO 2023/09/10 21:08:13     pv 1:      power ✓ energy ✓ currents ✗
[site  ] INFO 2023/09/10 21:08:13   vehicles:
[site  ] INFO 2023/09/10 21:08:13     vehicle 1: range ✓ finish ✓ status ✓ climate ✓ wakeup ✓
[lp-1  ] INFO 2023/09/10 21:08:13 loadpoint 1:
[lp-1  ] INFO 2023/09/10 21:08:13   mode:        pv
[lp-1  ] INFO 2023/09/10 21:08:13   charger:     power ✓ energy ✗ currents ✓ phases ✓ wakeup ✗
[lp-1  ] INFO 2023/09/10 21:08:13   meters:      charge ✓
[lp-1  ] INFO 2023/09/10 21:08:13     charge:    power ✓ energy ✗ currents ✓
[lp-1  ] DEBUG 2023/09/10 21:08:13 phase timer inactive
[lp-1  ] DEBUG 2023/09/10 21:08:13 pv timer inactive
[lp-1  ] DEBUG 2023/09/10 21:08:13 guard timer inactive
[lp-1  ] INFO 2023/09/10 21:08:13 vehicle updated: unknown -> ID.4
[lp-1  ] DEBUG 2023/09/10 21:08:13 max charge current: 6A
[site  ] DEBUG 2023/09/10 21:08:13 ----
[lp-1  ] DEBUG 2023/09/10 21:08:13 charge power: 1383W
[site  ] DEBUG 2023/09/10 21:08:13 pv power: 0W
[site  ] DEBUG 2023/09/10 21:08:13 grid power: 1755W
[site  ] DEBUG 2023/09/10 21:08:13 site power: 1755W
[lp-1  ] DEBUG 2023/09/10 21:08:14 vehicle odometer: 10966km
[lp-1  ] DEBUG 2023/09/10 21:08:14 charge currents: [6 0 0]A
[lp-1  ] DEBUG 2023/09/10 21:08:14 charger status: C
[lp-1  ] INFO 2023/09/10 21:08:14 car connected
[lp-1  ] DEBUG 2023/09/10 21:08:14 pv timer elapse
[lp-1  ] DEBUG 2023/09/10 21:08:14 pv timer inactive
[lp-1  ] DEBUG 2023/09/10 21:08:14 charger: guard elapse
[lp-1  ] DEBUG 2023/09/10 21:08:14 guard timer inactive
panic: interface conversion: interface {} is nil, not string
goroutine 478 [running]:
github.com/mabunixda/wattpilot.(*Wattpilot).GetRFID(...)
    github.com/mabunixda/wattpilot@v1.6.0/wattpilot.go:712
github.com/evcc-io/evcc/charger.(*Wattpilot).Identify(0xc000b13c40?)
    github.com/evcc-io/evcc/charger/fronius-wattpilot.go:135 +0x65
github.com/evcc-io/evcc/core.(*Loadpoint).createSession(0xc0005f6000)
    github.com/evcc-io/evcc/core/loadpoint_session.go:40 +0xff
github.com/evcc-io/evcc/core.(*Loadpoint).evVehicleConnectHandler(0xc0005f6000)
    github.com/evcc-io/evcc/core/loadpoint.go:470 +0x265
reflect.Value.call({0x21f9840?, 0xc000a23c70?, 0x10?}, {0x2724e59, 0x4}, {0x4e2f220, 0x0, 0x7f82e1d175b8?})
    reflect/value.go:596 +0xce7
reflect.Value.Call({0x21f9840?, 0xc000a23c70?, 0x0?}, {0x4e2f220?, 0xc000c650c8?, 0xc00033e6a0?})
    reflect/value.go:380 +0xb9
github.com/asaskevich/EventBus.(*EventBus).doPublish(0x22f7d20?, 0xc000ea7a40, {0x2731659?, 0xc000a23c80?}, {0x0?, 0xc00033e670?, 0x10?})
    github.com/asaskevich/EventBus@v0.0.0-20200907212545-49d423059eef/event_bus.go:160 +0x4d
github.com/asaskevich/EventBus.(*EventBus).Publish(0xc000b12d60, {0x2731659, 0x7}, {0x0, 0x0, 0x0})
    github.com/asaskevich/EventBus@v0.0.0-20200907212545-49d423059eef/event_bus.go:144 +0x5bf
github.com/evcc-io/evcc/core.(*Loadpoint).updateChargerStatus(0xc0005f6000)
    github.com/evcc-io/evcc/core/loadpoint.go:886 +0x46b
github.com/evcc-io/evcc/core.(*Loadpoint).Update(0xc0005f6000, 0x0?, 0x0, 0x0?, 0x0?, 0x0, 0xc000980090, 0x0)
    github.com/evcc-io/evcc/core/loadpoint.go:1498 +0x212
github.com/evcc-io/evcc/core.(*Site).update(0xc00145b800, {0x31667d8?, 0xc0005f6000})
    github.com/evcc-io/evcc/core/site.go:755 +0x5ba
github.com/evcc-io/evcc/core.(*Site).Run(0xc00145b800, 0xc000d34960, 0x6fc23ac00)
    github.com/evcc-io/evcc/core/site.go:850 +0x206
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

My setup is:

Steps to reproduce

  1. Start HA add-on after upgrading to 0.119.5

Configuration details

EVCC_DATABASE_DSN=/tmp2/evcc.db evcc --config /tmp2/evcc.yaml discuss:

[main  ] INFO 2023/09/10 22:42:41 evcc 0.119.5
[main  ] INFO 2023/09/10 22:42:41 using config file: /tmp2/evcc.yaml
[main  ] FATAL 2023/09/10 22:42:41 Could not open browser.
[main  ] FATAL 2023/09/10 22:42:41 Go to https://github.com/evcc-io/evcc/discussions/new?category=erste-hilfe and post the following:
[main  ] FATAL 2023/09/10 22:42:41 <!-- Detaillierte Problembeschreibung bitte hier -->

<details><summary>Konfiguration (/tmp2/evcc.yaml)</summary>

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

interval: 30s # control cycle interval

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

# sponsor token: *****
# sponsortoken: *****

# 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: grid
#    type: template
#    template: fronius-gen24
#    usage: grid
#    host: 192.168.1.192 # IP-Adresse oder Hostname
#    port: 502 # Port (Optional) 
  - name: grid
    type: template
    template: fronius-solarapi-v1
    usage: grid
    host: 192.168.1.192
  - name: pv
    type: template
    template: fronius-gen24
    usage: pv
    host: 192.168.1.192 # IP-Adresse oder Hostname
    port: 502 # Port (Optional)

# 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: wattpilot
    type: template
    template: fronius-wattpilot
    host: 192.168.1.191 # IP-Adresse oder Hostname
    password: *****

# 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: ID4
    type: template
    template: id
    title: ID.4 # Wird in der Benutzeroberfläche angezeigt (Optional)
    user: *****
    password: *****
    vin: *****
    capacity: 77 # Akkukapazität in kWh (Optional) 
#    onIdentify: # set defaults when vehicle is identified
    #mode: pv # enable PV-charging when vehicle is identified
    #minSoc: 20 # immediately charge to 20% regardless of mode unless "off" (disabled)
    #targetSoc: 80 # limit charge to 80%

# site describes the EVU connection, PV and home battery
site:
  title: Home # display name for UI
  meters:
    grid: grid # grid meter
    pv:
      - pv # list of pv inverters/ meters
    #battery:
    #  - battery # list of battery meters
    #aux:
    #  - aux # list of auxiliary meters for adjusting grid operating point
  residualPower: 0 # additional household usage margin
  prioritySoc: 0 # 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: 0 # ignore battery charging if AC consumption is above this value
  smartCostLimit: 0 # set cost limit for automatic charging in PV mode

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
  - title: Car Port # display name for UI
    charger: wattpilot # charger
    vehicle: ID4
    #meter: charge # charge meter
    mode: pv # 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
    phases: 1 # 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.1046 # EUR/kWh
    zones:
      - days: Mo-Fr
        hours: 0-7
        price: 0.0493 # EUR/kWh
      - days: Sa
        hours: 0-9:30
        price: 0.0493 # EUR/kWh
      - days: Sa
        hours: 14-20
        price: 0.0493 # EUR/kWh
      - days: Sa
        hours: 22-0
        price: 0.0493 # EUR/kWh
      - days: So
        price: 0.0493 # EUR/kWh

    # or variable tariffs
    # type: tibber
    # 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%)
  feedin:
    # rate for feeding excess (pv) energy to the grid
    type: fixed
    price: 0.07 # 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: *****
    # zone: DE

# 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: *****
  #   recipients: *****
  #   - # list of recipient ids
  # - type: telegram
  #   token: *****
  #   chats: *****
  #   - # list of chat ids
  # - type: email
  #   uri: smtp://<user: *****
  # - type: ntfy
  #   uri: https://<host>/<topics>
  #   priority: <priority>
  #   tags: <tags>

</details>
Version: `0.119.5`

Log details

EVCC_DATABASE_DSN=/tmp2/evcc.db evcc --config /tmp2/evcc.yaml --log debug
[main  ] INFO 2023/09/10 22:38:22 evcc 0.119.5
[main  ] INFO 2023/09/10 22:38:22 using config file: /tmp2/evcc.yaml
[main  ] INFO 2023/09/10 22:38:22 starting ui and api at :7070
[main  ] ERROR 2023/09/10 22:38:25 creating vehicle ID4 failed: cannot create vehicle 'template': cannot create vehicle 'id': Get "https://emea.bff.cariad.digital/user-login/v1/authorize?client_id=a24fba63-34b3-4d43-b181-942111e6bda8%40apps_vw-dilab_com&code_challenge=WjMgoZSX7-lJNu6Rx90qJ-uAjs_R0ZZ6VMLIbfU4lvQ&code_challenge_method=S256&redirect_uri=weconnect%3A%2F%2Fauthenticated&response_type=code+id_token+token&scope=openid+profile+badge+cars+vin&nonce=XSKSyGMLtyqjNvYkvgoxUWIifQqORQpOPtLnkhnNNDP&state=101c8016-9502-453d-9540-931727c2bfa7": dial tcp: lookup emea.bff.cariad.digital on 192.168.1.254:53: no such host
[lp-1  ] WARN 2023/09/10 22:38:25 locking phase config to 1p for switchable charger
[site  ] INFO 2023/09/10 22:38:25 site config:
[site  ] INFO 2023/09/10 22:38:25   meters:      grid ✓ pv ✓ battery ✗
[site  ] INFO 2023/09/10 22:38:25     grid:      power ✓ energy ✗ currents ✗
[site  ] INFO 2023/09/10 22:38:25     pv 1:      power ✓ energy ✓ currents ✗
[site  ] INFO 2023/09/10 22:38:25   vehicles:
[site  ] INFO 2023/09/10 22:38:25     vehicle 1: range ✗ finish ✗ status ✗ climate ✗ wakeup ✗
[lp-1  ] INFO 2023/09/10 22:38:25 loadpoint 1:
[lp-1  ] INFO 2023/09/10 22:38:25   mode:        pv
[lp-1  ] INFO 2023/09/10 22:38:25   charger:     power ✓ energy ✗ currents ✓ phases ✓ wakeup ✗
[lp-1  ] INFO 2023/09/10 22:38:25   meters:      charge ✓
[lp-1  ] INFO 2023/09/10 22:38:25     charge:    power ✓ energy ✗ currents ✓
[lp-1  ] DEBUG 2023/09/10 22:38:25 phase timer inactive
[lp-1  ] DEBUG 2023/09/10 22:38:25 pv timer inactive
[lp-1  ] DEBUG 2023/09/10 22:38:25 guard timer inactive
[lp-1  ] INFO 2023/09/10 22:38:25 vehicle updated: unknown -> ID.4 (offline)
[lp-1  ] DEBUG 2023/09/10 22:38:25 max charge current: 6A
[site  ] DEBUG 2023/09/10 22:38:25 ----
[lp-1  ] DEBUG 2023/09/10 22:38:25 charge power: 1396W
[site  ] DEBUG 2023/09/10 22:38:26 pv power: 0W
[site  ] DEBUG 2023/09/10 22:38:26 grid power: 3973W
[site  ] DEBUG 2023/09/10 22:38:26 site power: 3973W
[lp-1  ] DEBUG 2023/09/10 22:38:26 charge currents: [6 0 0]A
[lp-1  ] DEBUG 2023/09/10 22:38:26 charger status: C
[lp-1  ] INFO 2023/09/10 22:38:26 car connected
[lp-1  ] DEBUG 2023/09/10 22:38:26 pv timer elapse
[lp-1  ] DEBUG 2023/09/10 22:38:26 pv timer inactive
[lp-1  ] DEBUG 2023/09/10 22:38:26 charger: guard elapse
[lp-1  ] DEBUG 2023/09/10 22:38:26 guard timer inactive
panic: interface conversion: interface {} is nil, not string

goroutine 421 [running]:
github.com/mabunixda/wattpilot.(*Wattpilot).GetRFID(...)
        github.com/mabunixda/wattpilot@v1.6.0/wattpilot.go:712
github.com/evcc-io/evcc/charger.(*Wattpilot).Identify(0xc000bedb40?)
        github.com/evcc-io/evcc/charger/fronius-wattpilot.go:135 +0x65
github.com/evcc-io/evcc/core.(*Loadpoint).createSession(0xc0007cc800)
        github.com/evcc-io/evcc/core/loadpoint_session.go:40 +0xff
github.com/evcc-io/evcc/core.(*Loadpoint).evVehicleConnectHandler(0xc0007cc800)
        github.com/evcc-io/evcc/core/loadpoint.go:470 +0x265
reflect.Value.call({0x21f9840?, 0xc00081acc0?, 0x10?}, {0x2724e59, 0x4}, {0x4e2f220, 0x0, 0x7fe5bc6305b8?})
        reflect/value.go:596 +0xce7
reflect.Value.Call({0x21f9840?, 0xc00081acc0?, 0x0?}, {0x4e2f220?, 0xc0009b10c8?, 0xc000b2b050?})
        reflect/value.go:380 +0xb9
github.com/asaskevich/EventBus.(*EventBus).doPublish(0x22f7d20?, 0xc000f50360, {0x2731659?, 0xc00081acd0?}, {0x0?, 0xc000b2b040?, 0x10?})
        github.com/asaskevich/EventBus@v0.0.0-20200907212545-49d423059eef/event_bus.go:160 +0x4d
github.com/asaskevich/EventBus.(*EventBus).Publish(0xc000becec0, {0x2731659, 0x7}, {0x0, 0x0, 0x0})
        github.com/asaskevich/EventBus@v0.0.0-20200907212545-49d423059eef/event_bus.go:144 +0x5bf
github.com/evcc-io/evcc/core.(*Loadpoint).updateChargerStatus(0xc0007cc800)
        github.com/evcc-io/evcc/core/loadpoint.go:886 +0x46b
github.com/evcc-io/evcc/core.(*Loadpoint).Update(0xc0007cc800, 0x0?, 0x0, 0x0?, 0x0?, 0x0, 0xc0009e6320, 0x0)
        github.com/evcc-io/evcc/core/loadpoint.go:1498 +0x212
github.com/evcc-io/evcc/core.(*Site).update(0xc000949000, {0x31667d8?, 0xc0007cc800})
        github.com/evcc-io/evcc/core/site.go:755 +0x5ba
github.com/evcc-io/evcc/core.(*Site).Run(0xc000949000, 0xc000f0eba0, 0x6fc23ac00)
        github.com/evcc-io/evcc/core/site.go:850 +0x206
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

evcc version 0.119.5

andig commented 1 year ago

Already fixed on master

eriwave commented 1 year ago

OK sorry for the noise, I think I searched only in open issues and did not notice previous ones already closed. Btw, just a suggestion, in new bug template it might be better to ask people to output evcc discuss than to ask to 'Show evcc configuration file evcc.yaml', as it could prevent accidental leak of passwords.

andig commented 1 year ago

Good suggestion, thank you!