bretterer / home-assistant-rivian

Rivian (Unofficial) Integration for Home Assistant
Apache License 2.0
125 stars 20 forks source link

Rivian entities not updating #150

Closed roopesh closed 6 months ago

roopesh commented 7 months ago

What's happening: When I take an action in the app or in HA, it's not reflected in HA e.g. opening the Frunk, the Frunk sensor never changes to open even though the action does take place. The app is updating. I'm getting this error:

2024-04-05 05:59:01.027 ERROR (MainThread) [custom_components.rivian.coordinator] Rivian api exception: Error occurred while communicating with Rivian.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1173, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 884, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 899, in getaddrinfo
    return await self.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 963, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Try again
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 637, in __graphql_query
    response = await self._session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1187, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host rivian.com:443 ssl:default [Try again]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/config/custom_components/rivian/coordinator.py", line 77, in _async_update_data
    resp = await self._fetch_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/rivian/coordinator.py", line 134, in _fetch_data
    return await self.api.get_live_charging_session(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 469, in get_live_charging_session
    return await self.__graphql_query(headers, url, graphql_json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 648, in __graphql_query
    raise RivianApiException(
rivian.exceptions.RivianApiException: Error occurred while communicating with Rivian.

If I reload the integration, everything gets reflected properly for that exact moment in time.

I'm wondering if I should delete the integration and re-add it. If I do that, do I need to unpair HA as a key and repair HA?

natekspencer commented 7 months ago

I see a connection error to rivian.com, which is generally networking related. Is your HA instance connected via WiFi or ethernet? Or can you verify that this is continuing to happen regularly?

roopesh commented 7 months ago

I'm 99% sure it's not an internet/connectivity issue. I just tested it again and I opened the frunk using the HA button, which does work - the frunk opens, then about 45s-60s later see this error in the logs and the status in HA never updates. However, if I reload the integration it will get the correct status... and then start logging this error, too. 😕

2024-04-05 08:47:53.308 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140298447187136] Error occurred while communicating with Rivian.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1173, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 884, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 899, in getaddrinfo
    return await self.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 963, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Try again
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 637, in __graphql_query
    response = await self._session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1187, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host rivian.com:443 ssl:default [Try again]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/rivian/cover.py", line 128, in async_open_cover
    await self.entity_description.open_cover(self.coordinator)
  File "/config/custom_components/rivian/coordinator.py", line 355, in send_vehicle_command
    if response := await self.api.send_vehicle_command(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 565, in send_vehicle_command
    response = await self.__graphql_query(headers, url, graphql_json)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rivian/rivian.py", line 648, in __graphql_query
    raise RivianApiException(
rivian.exceptions.RivianApiException: Error occurred while communicating with Rivian.
roopesh commented 7 months ago

When I reload the integration, I get these logs:

2024-04-05 08:52:43.491 INFO (MainThread) [custom_components.rivian] Rivian integration is starting under version 1.1.1. Please report issues at https://github.com/bretterer/home-assistant-rivian/issues
2024-04-05 08:52:51.798 ERROR (MainThread) [rivian.rivian] Cannot connect to host api.rivian.com:443 ssl:default [Try again]
2024-04-05 08:52:54.672 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up rivian.binary_sensor
2024-04-05 08:52:54.711 INFO (MainThread) [homeassistant.components.button] Setting up rivian.button
2024-04-05 08:52:54.712 INFO (MainThread) [homeassistant.components.climate] Setting up rivian.climate
2024-04-05 08:52:54.713 WARNING (MainThread) [homeassistant.components.climate] Entity None (<class 'custom_components.rivian.climate.RivianClimateEntity'>) implements HVACMode(s): off, heat_cool, heat and therefore implicitly supports the turn_on/turn_off methods without setting the proper ClimateEntityFeature. Please create a bug report at https://github.com/bretterer/home-assistant-rivian/issues
2024-04-05 08:52:54.714 INFO (MainThread) [homeassistant.components.cover] Setting up rivian.cover
2024-04-05 08:52:54.716 INFO (MainThread) [homeassistant.components.device_tracker] Setting up rivian.device_tracker
2024-04-05 08:52:54.717 INFO (MainThread) [homeassistant.components.image] Setting up rivian.image
2024-04-05 08:52:54.718 INFO (MainThread) [homeassistant.components.lock] Setting up rivian.lock
2024-04-05 08:52:54.720 INFO (MainThread) [homeassistant.components.number] Setting up rivian.number
2024-04-05 08:52:55.418 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for number.quicksilver_charge_limit (<class 'custom_components.rivian.number.RivianNumberEntity'>) took 0.698 seconds. Please create a bug report at https://github.com/bretterer/home-assistant-rivian/issues
2024-04-05 08:52:55.419 INFO (MainThread) [homeassistant.components.select] Setting up rivian.select
2024-04-05 08:52:55.421 INFO (MainThread) [homeassistant.components.sensor] Setting up rivian.sensor
2024-04-05 08:52:55.448 INFO (MainThread) [homeassistant.components.switch] Setting up rivian.switch
2024-04-05 08:52:55.449 INFO (MainThread) [homeassistant.components.update] Setting up rivian.update
2024-04-05 08:52:56.337 ERROR (MainThread) [homeassistant.components.image] Platform rivian does not generate unique IDs. ID 7PDSGABA8RN033482-dark-overhead already exists - ignoring image.quicksilver_overhead_dark
2024-04-05 08:52:56.337 ERROR (MainThread) [homeassistant.components.image] Platform rivian does not generate unique IDs. ID 7PDSGABA8RN033482-light-overhead already exists - ignoring image.quicksilver_overhead_light

and a few moments later

2024-04-05 08:53:51.569 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_light: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side_light_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.579 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_in_use_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_in-use_dark_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.648 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_charging_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side-charging_dark_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.682 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_rear_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_rear_dark_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.692 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_rear_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side-rear_dark_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.696 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side_dark_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.698 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_overhead_light: Error getting new image from https://rivian.com/mobile/static/img/v1/vehicle/r1s/2021/adventure/ext/la-silver/20ad1-brit-at/r1s_2021_adventure_ext_la-silver_20ad1-brit-at_overhead_light_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.701 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_rear_light: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side-rear_light_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.702 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_side_charging_light: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_side-charging_light_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.706 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_rear_light: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_rear_light_large_@3x.png: [Errno -3] Try again
2024-04-05 08:53:51.711 ERROR (MainThread) [homeassistant.components.image] image.quicksilver_front_dark: Error getting new image from https://rivian.com/mobile/static/img/v2/vehicle/r1s/2021/adventure/ext/la-silver/21aer-brit-as/r1s_2021_adventure_ext_la-silver_21aer-brit-as_front_dark_large_@3x.png: [Errno -3] Try again

FWIW I also disabled Adguard to see if that could be a problem. Didn't help anything.

roopesh commented 7 months ago

WiFi or ethernet?

Ethernet

natekspencer commented 7 months ago

Do you have IPv6 enabled?

roopesh commented 7 months ago

Annoyingly, yes IPv6 was enabled. I've disabled it, restarted, permanently disabled Adguard and I'm seeing mix results - sometimes it works, sometimes it doesn't. Gonna keep watching it for a while to see what happens over time. If both these fix it, I'll turn on Adguard again to see if it was the problem. I can't imagine it being the problem, though.

natekspencer commented 7 months ago

Adguard shouldn't be the problem, but I have seen mixed results with IPv6 in a number of integrations.

roopesh commented 7 months ago

My whole HA server started crapping out today. My host CPU was pegged. As some hygiene, I removed an old HA VM snapshot (>3 months old) and everything seems to be great now. I can't imagine how it's related, but somehow it must be. I know maintaining old snapshots isn't free, but I didn't think it'd cause these types of issues. Hopefully this fixes it. Life with a #homelab LOL!