mbillow / ha-chargepoint

Home Assistant ChargePoint EV Charger Integration
MIT License
44 stars 6 forks source link

Crash after setup: "KeyError: 'familyName'" #18

Closed Forge36 closed 1 year ago

Forge36 commented 1 year ago

I'm not seeing an issue template. Let me know if you need more details.

I've configured a new account and I'm getting a crash after restarting homeassistant.

#This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/chargepoint/__init__.py:107
Integration: ChargePoint (documentation, issues)
First occurred: 12:17:13 PM (1 occurrences)
Last logged: 12:17:13 PM

Error setting up entry <username> for chargepoint
Traceback (most recent call last):
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/homeassistant/config_entries.py", line 365, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/volume1/@appdata/homeassistant/config/custom_components/chargepoint/__init__.py", line 107, in async_setup_entry
    client: ChargePoint = await hass.async_add_executor_job(
  File "/var/packages/python310/target/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/python_chargepoint/client.py", line 84, in __init__
    account: ChargePointAccount = self.get_account()
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/python_chargepoint/client.py", line 42, in check_login
    return func(*args, **kwargs)
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/python_chargepoint/client.py", line 221, in get_account
    return ChargePointAccount.from_json(account)
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/python_chargepoint/types.py", line 88, in from_json
    user = ChargePointUser.from_json(json["user"])
  File "/volume1/@appstore/homeassistant/env/lib/python3.10/site-packages/python_chargepoint/types.py", line 50, in from_json
    family_name=json["familyName"],
KeyError: 'familyName'
Forge36 commented 1 year ago

re-reading the stack I realized this was a python-chargepoint issue not specific to this addon. Unfortunately I don't know how to report issues upstream (I could e-mail). However reading the code from https://pypi.org/project/python-chargepoint/#files suggested this may be a profile setup issue on my part.

Turns out my account is old enough that I setup my profile without a last name (which is currently a required field). Editing my profile on chargepoint's website resolved this error.