netsoft-ruidias / ha-custom-component-sodexo

Sodexo - Custom Component for Home Assistant
MIT License
4 stars 6 forks source link

[homeassistant.config_entries] Error unloading entry Sodexo NIF #4

Open taduo opened 11 months ago

taduo commented 11 months ago

Hi,

It was not working so I've deleted the Integration entrie and re-added, as worked in the past, but this time it did not.

Home Assistant 2023.8.2 Supervisor 2023.08.1 Operating System 10.4 Frontend 20230802.0 - latest

2023-08-19 21:17:06.289 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry Sodexo 2xxxxxxx0 for sodexo
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 544, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sodexo/__init__.py", line 34, in async_unload_entry
    hass.data[DOMAIN].pop(entry.entry_id)
KeyError: 'd6777b122a633a3e769083f6a664b0d3'
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sodexo/__init__.py", line 34, in async_unload_entry
    hass.data[DOMAIN].pop(entry.entry_id)
KeyError: 'd6777b122a633a3e769083f6a664b0d3'
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sodexo/__init__.py", line 34, in async_unload_entry
    hass.data[DOMAIN].pop(entry.entry_id)
KeyError: 'd6777b122a633a3e769083f6a664b0d3

And retried delete, redownload integration, restart HA, added again:

2023-08-19 21:32:13.714 DEBUG (MainThread) [custom_components.myedenred.api.myedenred] Done getting card details and their movements.
2023-08-19 21:34:08.574 DEBUG (MainThread) [custom_components.sodexo.config_flow] Starting async_step_user...
2023-08-19 21:34:21.932 DEBUG (MainThread) [custom_components.sodexo.config_flow] Starting async_step_user...
2023-08-19 21:34:21.932 DEBUG (MainThread) [custom_components.sodexo.api] Logging in...
2023-08-19 21:34:22.360 DEBUG (MainThread) [custom_components.sodexo.config_flow] Config is valid!
2023-08-19 21:34:22.362 DEBUG (MainThread) [custom_components.sodexo] async_setup
2023-08-19 21:34:22.368 DEBUG (MainThread) [custom_components.sodexo.api] Logging in...
2023-08-19 21:34:22.418 DEBUG (MainThread) [custom_components.sodexo.api] Getting account details...
2023-08-19 21:34:23.349 ERROR (MainThread) [homeassistant.components.sensor] sodexo: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 938, in async_device_update
    await self.async_update()
  File "/config/custom_components/sodexo/sensor.py", line 117, in async_update
    account = await api.getAccountDetails(token)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sodexo/api.py", line 53, in getAccountDetails
    amount = float(data[2].strip().replace(",", "."))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'Cartão: ************XXX9'
taduo commented 9 months ago

This is due to the new system they have I believe. As I have an old card "Cartão Antigo" and a new card "Novo Cartão", on https://minhaconta.sodexobeneficios.pt/

/?cardSource=b image

/?cardSource=f image

Is this possible to fix or add to handle this?