G-Two / homeassistant-subaru

Subaru STARLINK custom component for Home Assistant.
Apache License 2.0
54 stars 6 forks source link

Integration Availability #80

Open tango2590 opened 1 year ago

tango2590 commented 1 year ago

Integration sensors keep becoming unavailable. Tried reloading a few times with no luck. Yesterday I had some issues with the HTTP 500 error, but reloading seemed to fix it. But ever since, the integration seems unstable. Remote start and Polling fail occasionally. Here's a couple lines from the log:

Remote Start/Polling:

 File "/usr/local/lib/python3.10/site-packages/subarulink/controller.py", line 1276, in _parse_vehicle_status
    status[sc.HEADING] = int(data.get(api.API_HEADING))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Binary Sensors:

  File "/config/custom_components/subaru/binary_sensor.py", line 227, in icon
    return BINARY_SENSOR_ICONS[self.device_class][self.is_on]
  File "/config/custom_components/subaru/binary_sensor.py", line 242, in is_on
    return self.get_current_value() in ON_VALUES[self.device_class]
  File "/config/custom_components/subaru/binary_sensor.py", line 247, in get_current_value
    if data := self.coordinator.data.get(self.vin):
AttributeError: 'NoneType' object has no attribute 'get'
stboch commented 1 year ago

@tango2590 Please provide a Diagnostic from within Home-Assistant, you can find it under the integration ... menu or the Device Page

tango2590 commented 1 year ago

Sorry for the delay. This is from shortly after the issue. Initial issue occurred April 1st @ 0800, diagnostic download from 0811. config_entry-subaru-44ae93c0db73d340fad430110cdae677.json.txt

tango2590 commented 1 year ago

Integration (and I specifically mean remote starts) have been fine for a few days, but it just happened again for some reason, It appears the Notification is formatted a little different too. Still a HTTP 500 error though. Screenshot of notification and new diagnostic log attached. config_entry-subaru-44ae93c0db73d340fad430110cdae677.json (1).txt

Screenshot 2023-04-06 at 20 50 29
stboch commented 1 year ago

This new issue is known just started today. Working on an update to the latest API version.

G-Two commented 1 year ago

Fix for 404 error has been released as 0.7.6

@tango2590 As for the other errors, I was not able to duplicate, nor did I see any issues with your diagnostic data. Let me know if it persists, and if you can, please paste in the full stack traces the next time the error happens.

Mark612 commented 1 year ago

Fix for 404 error has been released as 0.7.6

I couldn't connect all day yesterday, and 0.7.6 fixed the issue. Thank you.

tango2590 commented 6 months ago

The "int() as a string" error happened again today when attempting a remote start. What's weird is the remote start command worked 11 minutes prior to this second request. I haven't seen this error since April so not sure what's causing it to randomly happen.

This error originated from a custom integration.

Logger: custom_components.subaru
Source: helpers/update_coordinator.py:300
Integration: Subaru (HACS) (documentation, issues)
First occurred: 08:20:23 (2 occurrences)
Last logged: 08:25:23

Unexpected error fetching subaru_data data: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/subaru/__init__.py", line 108, in async_update_data
    return await _refresh_subaru_data(hass, entry, vehicles, controller)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/subaru/__init__.py", line 198, in _refresh_subaru_data
    await refresh_subaru(vehicle, controller)
  File "/config/custom_components/subaru/remote_service.py", line 133, in refresh_subaru
    success = await controller.fetch(vin, force=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 569, in fetch
    result = await self._fetch_status(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 1058, in _fetch_status
    status = self._parse_vehicle_status(js_resp, vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subarulink/controller.py", line 1285, in _parse_vehicle_status
    status[sc.HEADING] = int(data.get(api.API_HEADING))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
G-Two commented 5 months ago

The heading returned from the Subaru API seems to be problematic. It is sometimes null. When it is provided it is seldom correct. The integration doesn't use it, so I might just remove it from subarulink since it provides little value and frequent errors.

tango2590 commented 5 months ago

I saw the change on the python package, but that actually seems to have exacerbated the issue. Previously, the HTTP 500 error only occurred occasionally. But since the change 2 days ago, every remote start attempt results in the HTTP 500 error. Does the HA integration need a change now that headers are no longer used?

G-Two commented 4 months ago

It's not related because I haven't updated this custom component to use subarulink 0.7.10 yet. But even if it were, the changes are all on the client side parsing and have nothing to do with HTTP requests, so they shouldn't cause an HTTP 500.

I'm not sure what you mean when you say that headers are no longer used. Which headers?

tango2590 commented 4 months ago

I just know the headers were removed in the python package, which is when this integration began giving me consistent issues. Might just be a coincidence though. Since then, there's been about an 70% chance that the integration fails a command such as remote start with an HTTP 500 error. Prior to those changes, the integration worked almost flawlessly, with an error occuring maybe a couple times per month at most.