mandarons / ha-bouncie

Home Assistant custom integration for Bouncie.com - track your car stuff in Home Assistant
BSD 3-Clause "New" or "Revised" License
30 stars 4 forks source link

[BUG] 'NoneType' object is not subscriptable (access_token) #31

Closed Basserra closed 1 year ago

Basserra commented 1 year ago

I cannot add the integration to my HomeAssistant, as after I input the details in the 'add integration' configuration, it throws an 'unexpected error.' I may have misconfigured Bouncie.dev or just the URL/URi, but I'm not certain which is what in this regard.

This error originated from a custom integration.

Logger: custom_components.bouncie.const
Source: custom_components/bouncie/config_flow.py:41
Integration: Bouncie (documentation, issues)
First occurred: 12:25:06 (3 occurrences)
Last logged: 12:32:38

'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/config/custom_components/bouncie/config_flow.py", line 64, in async_step_user
    info = await validate_input(self.hass, user_input)
  File "/config/custom_components/bouncie/config_flow.py", line 41, in validate_input
    result = await bouncie_client.get_access_token()
  File "/usr/local/lib/python3.10/site-packages/bounciepy/async_rest_api_client.py", line 85, in get_access_token
    self._set_access_token(access_token=data["access_token"])
TypeError: 'NoneType' object is not subscriptable

I don't know if it's just failing to grab the access_token due to firewall or authentication. But, what's strange to me with this, is that it would add the integration before; but could not setup the entities as it was complaining about "Nicknames." So I gave my vehicles nicknames in Bouncie, then the above/title issue started.

Logger: homeassistant.components.sensor
Source: custom_components/bouncie/sensor.py:165
Integration: Sensor (documentation, issues)
First occurred: 11:43:18 (4 occurrences)
Last logged: 12:10:54

Error while setting up bouncie platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/bouncie/sensor.py", line 136, in async_setup_entry
    [
  File "/config/custom_components/bouncie/sensor.py", line 137, in <listcomp>
    BouncieSensor(coordinator, sensor, dict(vehicle_info))
  File "/config/custom_components/bouncie/sensor.py", line 165, in __init__
    name=self._vehicle_info["nickName"],
KeyError: 'nickName'

---

Logger: homeassistant.components.device_tracker
Source: custom_components/bouncie/device_tracker.py:42
Integration: Device tracker (documentation, issues)
First occurred: 11:43:18 (4 occurrences)
Last logged: 12:10:54

Error while setting up bouncie platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/bouncie/device_tracker.py", line 19, in async_setup_entry
    [
  File "/config/custom_components/bouncie/device_tracker.py", line 20, in <listcomp>
    BouncieVehicleTracker(coordinator, vehicle_info)
  File "/config/custom_components/bouncie/device_tracker.py", line 42, in __init__
    self._attr_unique_id = slugify(f'{self._vehicle_info["nickName"]} tracker')
KeyError: 'nickName'

Configuration HA 'add integration' config (these strings are randomly generated and are not my actual ones)

Bouncie.dev config

Additional context My HA instance 2023.4.4 is accessable from the internet with a valid certificate on my registered domain. Bouncie Integration 2.5.0 installed through HACS 1.32.1. I have three vehicles registered & 'authorized devices' and will be adding two more.

Thanks for this project and your time!

mandarons commented 1 year ago

redirect_uri just needs to match in both - on bouncie.dev website and in HA Bouncie integration configuration page. They both seem exactly the same, per above.

Try completely removing the integration, rebooting the HA and add it again with above configuration.