soloam / ha-fireflyiii-integration

FireflyIII Integration for Home Assistant
MIT License
22 stars 1 forks source link

Error when adding bills #36

Open AndreiGavriliu opened 5 months ago

AndreiGavriliu commented 5 months ago

Hi,

First of all, thanks for your work, this is just what I was looking for!

I'm using HA 2024.06.4 with the integration 1.0.5. I tried addint only 3 accounts and the bills and this happens:

homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.645 INFO (MainThread) [homeassistant.components.sensor] Setting up fireflyiii_integration.sensor
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.649 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.fireflyiii_integration entity: sensor.fireflyiii_<account_1>_asset_account
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.661 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.fireflyiii_integration entity: sensor.fireflyiii_<account_2>_account_dummy_asset_account
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.663 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up fireflyiii_integration.binary_sensor
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.664 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.fireflyiii_integration entity: binary_sensor.fireflyiii_server_status
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.670 INFO (MainThread) [homeassistant.components.calendar] Setting up fireflyiii_integration.calendar
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.676 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new calendar.fireflyiii_integration entity: calendar.fireflyiii_bills
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:37.676 ERROR (MainThread) [homeassistant.components.calendar] Error adding entity calendar.fireflyiii_bills for domain calendar with platform fireflyiii_integration
homeassistant-5c5bc4778b-55tm4 homeassistant Traceback (most recent call last):
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
homeassistant-5c5bc4778b-55tm4 homeassistant     await entity.add_to_platform_finish()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
homeassistant-5c5bc4778b-55tm4 homeassistant     self.async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 545, in async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     super().async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     self._async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
homeassistant-5c5bc4778b-55tm4 homeassistant                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
homeassistant-5c5bc4778b-55tm4 homeassistant     state = self._stringify_state(available)
homeassistant-5c5bc4778b-55tm4 homeassistant             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
homeassistant-5c5bc4778b-55tm4 homeassistant     if (state := self.state) is None:
homeassistant-5c5bc4778b-55tm4 homeassistant                  ^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 528, in state
homeassistant-5c5bc4778b-55tm4 homeassistant     if (event := self.event) is None:
homeassistant-5c5bc4778b-55tm4 homeassistant                  ^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/calendar.py", line 110, in event
homeassistant-5c5bc4778b-55tm4 homeassistant     events = self.fireflyiii_events(get_pay=True, get_paied=False)
homeassistant-5c5bc4778b-55tm4 homeassistant              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/calendar.py", line 142, in fireflyiii_events
homeassistant-5c5bc4778b-55tm4 homeassistant     summary=f"{bill.name} {output_money(bill.value,bill.currency,self.locale)}",
homeassistant-5c5bc4778b-55tm4 homeassistant                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/integrations/fireflyiii_functions.py", line 47, in output_money
homeassistant-5c5bc4778b-55tm4 homeassistant     return format_currency(value, target_currency, locale=locale)
homeassistant-5c5bc4778b-55tm4 homeassistant            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/numbers.py", line 777, in format_currency
homeassistant-5c5bc4778b-55tm4 homeassistant     locale = Locale.parse(locale)
homeassistant-5c5bc4778b-55tm4 homeassistant              ^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/core.py", line 330, in parse
homeassistant-5c5bc4778b-55tm4 homeassistant     parts = parse_locale(identifier, sep=sep)
homeassistant-5c5bc4778b-55tm4 homeassistant             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/core.py", line 1242, in parse_locale
homeassistant-5c5bc4778b-55tm4 homeassistant     raise ValueError(f"expected only letters, got {lang!r}")
homeassistant-5c5bc4778b-55tm4 homeassistant ValueError: expected only letters, got ''
homeassistant-5c5bc4778b-55tm4 homeassistant 2024-06-27 08:38:41.706 ERROR (MainThread) [homeassistant.components.sensor] fireflyiii_integration: Error on device update!
homeassistant-5c5bc4778b-55tm4 homeassistant Traceback (most recent call last):
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 729, in _async_add_entity
homeassistant-5c5bc4778b-55tm4 homeassistant     await entity.async_device_update(warning=False)
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update
homeassistant-5c5bc4778b-55tm4 homeassistant     await self.async_update()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 529, in async_update
homeassistant-5c5bc4778b-55tm4 homeassistant     await self.coordinator.async_request_refresh()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 262, in async_request_refresh
homeassistant-5c5bc4778b-55tm4 homeassistant     await self._debounced_refresh.async_call()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in async_call
homeassistant-5c5bc4778b-55tm4 homeassistant     await task
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh
homeassistant-5c5bc4778b-55tm4 homeassistant     await self._async_refresh(log_failures=True)
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
homeassistant-5c5bc4778b-55tm4 homeassistant     self.async_update_listeners()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
homeassistant-5c5bc4778b-55tm4 homeassistant     update_callback()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 491, in _handle_coordinator_update
homeassistant-5c5bc4778b-55tm4 homeassistant     self.async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 545, in async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     super().async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     self._async_write_ha_state()
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
homeassistant-5c5bc4778b-55tm4 homeassistant     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
homeassistant-5c5bc4778b-55tm4 homeassistant                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
homeassistant-5c5bc4778b-55tm4 homeassistant     state = self._stringify_state(available)
homeassistant-5c5bc4778b-55tm4 homeassistant             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
homeassistant-5c5bc4778b-55tm4 homeassistant     if (state := self.state) is None:
homeassistant-5c5bc4778b-55tm4 homeassistant                  ^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 528, in state
homeassistant-5c5bc4778b-55tm4 homeassistant     if (event := self.event) is None:
homeassistant-5c5bc4778b-55tm4 homeassistant                  ^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/calendar.py", line 110, in event
homeassistant-5c5bc4778b-55tm4 homeassistant     events = self.fireflyiii_events(get_pay=True, get_paied=False)
homeassistant-5c5bc4778b-55tm4 homeassistant              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/calendar.py", line 142, in fireflyiii_events
homeassistant-5c5bc4778b-55tm4 homeassistant     summary=f"{bill.name} {output_money(bill.value,bill.currency,self.locale)}",
homeassistant-5c5bc4778b-55tm4 homeassistant                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/config/custom_components/fireflyiii_integration/integrations/fireflyiii_functions.py", line 47, in output_money
homeassistant-5c5bc4778b-55tm4 homeassistant     return format_currency(value, target_currency, locale=locale)
homeassistant-5c5bc4778b-55tm4 homeassistant            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/numbers.py", line 777, in format_currency
homeassistant-5c5bc4778b-55tm4 homeassistant     locale = Locale.parse(locale)
homeassistant-5c5bc4778b-55tm4 homeassistant              ^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/core.py", line 330, in parse
homeassistant-5c5bc4778b-55tm4 homeassistant     parts = parse_locale(identifier, sep=sep)
homeassistant-5c5bc4778b-55tm4 homeassistant             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant-5c5bc4778b-55tm4 homeassistant   File "/usr/local/lib/python3.12/site-packages/babel/core.py", line 1242, in parse_locale
homeassistant-5c5bc4778b-55tm4 homeassistant     raise ValueError(f"expected only letters, got {lang!r}")
homeassistant-5c5bc4778b-55tm4 homeassistant ValueError: expected only letters, got ''

I checked the entities and it created 3:

I'm guessing that, because the calendar creation failed, the also was not created. I then disabled the Bills category and all 3 accounts appeared

Is there anything I missed?

Cheers, Andrei

soloam commented 5 months ago

Hello @AndreiGavriliu this is a bug! I'll look into it as soon as possible! I'll try to check it tomorrow!

Thank you for the report