drakhart / ha-super-soco-custom

Custom component for integrating your Super Soco or Vmoto Soco motorcycle into Home Assistant. It provides meaningful data like power status, battery percentage, location and a lot more.
MIT License
17 stars 3 forks source link

Last Warning no longer available. #10

Closed apbarratt closed 1 year ago

apbarratt commented 1 year ago

My last warning entity has become unavailable and I'm seeing regularly errors in my log because of it.

Here's the latest one for when the integration appears to be attempting to get the information it's asking for:

This error originated from a custom integration.

Logger: custom_components.super_soco_custom
Source: custom_components/super_soco_custom/vmoto_soco_api.py:121 
Integration: Super Soco Custom (documentation, issues) 
First occurred: 12:11:37 (1 occurrences) 
Last logged: 12:11:37

999, message='', url=URL('https://app.vmotosoco-service.com/app/v1/deviceWarn/findDeviceWarnPageByUserId')
Traceback (most recent call last):
  File "/config/custom_components/super_soco_custom/coordinator.py", line 542, in _get_last_warning_data
    res = await self._client.get_warning_list(self._user_id, 1, 1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/super_soco_custom/vmoto_soco_api.py", line 75, in get_warning_list
    return await self._api_wrapper(url, headers, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/super_soco_custom/vmoto_soco_api.py", line 121, in _api_wrapper
    res.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 999, message='', url=URL('https://app.vmotosoco-service.com/app/v1/deviceWarn/findDeviceWarnPageByUserId')

Everything else appears to be working okay, I'm getting live data for battery, location, etc just as usual. I assume vmoto must have changed something somewhere. Let me know if there's anything I can provide :)

apbarratt commented 1 year ago

Prior to this error, I'd attempted deleting the entity for last warning to see if it would come back. I've now reloaded the integration and the entity has indeed returned, but I have more errors:

Logger: homeassistant
Source: components/sensor/__init__.py:532 
First occurred: 12:16:44 (1 occurrences) 
Last logged: 12:16:44

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 521, in state
    if value.tzinfo is None:
       ^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'tzinfo'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 970, in _async_registry_updated
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 532, in state
    raise ValueError(
ValueError: Invalid datetime: sensor.bike_last_warning has timestamp device class but provides state unknown:<class 'str'> resulting in ''str' object has no attribute 'tzinfo''

and an almost identical one:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:532 
Integration: Sensor (documentation, issues) 
First occurred: 12:16:44 (2 occurrences) 
Last logged: 12:16:44

Error adding entities for domain sensor with platform super_soco_custom
Error while setting up super_soco_custom platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 521, in state
    if value.tzinfo is None:
       ^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'tzinfo'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 471, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 749, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 850, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 532, in state
    raise ValueError(
ValueError: Invalid datetime: sensor.bike_last_warning has timestamp device class but provides state unknown:<class 'str'> resulting in ''str' object has no attribute 'tzinfo''
drakhart commented 1 year ago

Hi, Andy! Thanks for reporting these errors. I'm indeed getting the 1st one too. I'll take a look at both of them when I have some spare time.

drakhart commented 1 year ago

As you mention this is a problem with the API server (on their end). It even crashes when you try to fetch the warning messages in the official app v1.0.7 (going to menu > Message > Alarm Message), which is the latest version afaik.

When intercepting traffic from the app you can see that it simply returns this response with no further details:

{
  "success": false,
  "status": 999,
  "message": "System Error",
  "data": null
}

I'm afraid that we'll have to wait for an API fix from Vmoto Soco.

apbarratt commented 1 year ago

It's interesting seeing that they stay true to form with their error codes. Unpleasant catastrophic failure is 999 on the API, and likewise when the ECU needs replacing on their bikes it's error 99 that flashes on the display.

drakhart commented 1 year ago

Nice easter egg indeed (if that's in fact an intended thing), but to be honest their lack of respect for any HTTP and REST standards makes me wanna cry inside.

drakhart commented 1 year ago

I forgot to mention: that response (and every other response for that matter) actually comes as 200 OK. And many other things I've seen. 🤷

drakhart commented 1 year ago

It looks like the warnings endpoint started working again today, but I'm unable to reconnect the HA integration and check because it's not sending the SMS code. Can someone please confirm?

drakhart commented 1 year ago

I can confirm that the last warning entity is available again.

Screenshot_2023-09-02-09-41-53-61_c3a231c25ed346e59462e84656a70e50