Home-Assistant-custom-components-Tauron-AMIplus icon indicating copy to clipboard operation
Home-Assistant-custom-components-Tauron-AMIplus copied to clipboard

Download Stats Service Fails with Keyerror for Username

Open ajmckee opened this issue 10 months ago • 2 comments

When calling the download statistics service, script fails with unknown key error for username. This only occurs when calling the download service, otherwise all appears fine. Everything else is working.

Logger: homeassistant.components.automation.new_automation
Source: helpers/script.py:526
integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 22:56:00 (5 occurrences)
Last logged: 23:22:09

New Automation: Error executing script. Unexpected error for call_service at pos 1: 'username'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2795, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tauron_amiplus/services.py", line 44, in async_handle_service
    await TauronAmiplusStatisticsUpdater.manually_update(self._hass, start_date, config_entry)
  File "/config/custom_components/tauron_amiplus/statistics.py", line 32, in manually_update
    username = entry.data[CONF_USERNAME]
               ~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'username'

ajmckee avatar Jan 29 '25 22:01 ajmckee

I have this same problem. And statictics no auto update. Update only if I restart Home Assistant

ArmenVanlasso avatar May 02 '25 23:05 ArmenVanlasso

I have this same problem. And statictics no auto update. Update only if I restart Home Assistant

In relation to the no update, that is a tauron thing, despite it being 2024, it appears a button pusher is needed as they have not updated stats for my account since 2nd of May.

ajmckee avatar May 05 '25 13:05 ajmckee

Fixed in v2.7.0

PiotrMachowski avatar Aug 14 '25 04:08 PiotrMachowski