Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service "refresh_previous_consumption_data" failed #1179

Open
2 tasks done
mikesumbler opened this issue Jan 19, 2025 · 4 comments
Open
2 tasks done

Service "refresh_previous_consumption_data" failed #1179

mikesumbler opened this issue Jan 19, 2025 · 4 comments
Assignees
Labels
awaiting release confirmation Waiting confirmation on new release fixing the issue bug Something isn't working

Comments

@mikesumbler
Copy link

Describe the bug

Hi,

Trying to refresh gas consumption data grab from OE to fill a gap on my gas meter sensor from the 9th to 13th Jan (inc.).

As per issue #983 I tried to run the refresh_previous_consumption_data service using the developer tools and got failed, unknown error message.

Reproduction steps

Developer Tools>Actions>Selected refres service > added kWh (or m3) entity > set date to 8/1/25 > perform action

Expected behaviour

Backfill data gap

Tariff Code

? - can't find a tariff code in any of my rate data

Integration Version

13.5.3

Home Assistant Version

2025.1.2

Fresh Install?

Fresh install

Home Assistant Logs

`Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:526
First occurred: 1:54:02 PM (2 occurrences)
Last logged: 2:11:00 PM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'OctopusEnergyPreviousAccumulativeGasConsumptionKwh' object has no attribute 'async_refresh_previous_consumption_data'
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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1067, in _handle_entity_call
partial(getattr(entity, func), **data), # type: ignore[arg-type]
~~~~~~~^^^^^^^^^^^^^^
AttributeError: 'OctopusEnergyPreviousAccumulativeGasConsumptionKwh' object has no attribute 'async_refresh_previous_consumption_data'

Confirmation

  • I confirm that I cannot find my solution within the documentation
  • I confirm that I cannot find my solution within the FAQ
@mikesumbler mikesumbler added the bug Something isn't working label Jan 19, 2025
@BottlecapDave
Copy link
Owner

Hello. As per the docs and the logs you've posted, you're targeting the wrong entity. You say this doesn't work with the m3 version of the entity. What error are you getting for this entity?

@mikesumbler
Copy link
Author

Hi

Thank you for looking at this.

I retried with the following action woth the m3 entity:

action: octopus_energy.refresh_previous_consumption_data data: start_date: "2025-01-08" target: entity_id: >- sensor.octopus_energy_gas_e6s10315512161_9212685601_previous_accumulative_consumption_m3

Still the same response:

`
Traceback (most recent call last):
File "/config/custom_components/octopus_energy/gas/init.py", line 65, in calculate_gas_consumption_and_cost
rate = next(r for r in rate_data if r["start"] == consumption_from and r["end"] == consumption_to)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
msg.get("variables"), context=context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
self._handle_exception(
~~~~~~~~~~~~~~~~~~~~~~^
ex, continue_on_error, self._log_exceptions or log_exceptions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
raise exception
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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/config/custom_components/octopus_energy/gas/previous_accumulative_consumption_cubic_meters.py", line 182, in async_refresh_previous_consumption_data
await async_refresh_previous_gas_consumption_data(
...<8 lines>...
)
File "/config/custom_components/octopus_energy/statistics/refresh.py", line 154, in async_refresh_previous_gas_consumption_data
consumption_and_cost = calculate_gas_consumption_and_cost(
consumption_data,
...<4 lines>...
calorific_value
)
File "/config/custom_components/octopus_energy/gas/init.py", line 67, in calculate_gas_consumption_and_cost
raise Exception(f"Failed to find rate for consumption between {consumption_from} and {consumption_to}")
Exception: Failed to find rate for consumption between 2025-01-09 00:00:00+00:00 and 2025-01-09 00:30:00+00:00
`

@BottlecapDave
Copy link
Owner

Thanks for supplying the logs. That's actually a different response (but same outcome :)). It kooks like OE is returning more data than the integration requested, which is why it's erroring. This should be fixed in the next release.

@BottlecapDave
Copy link
Owner

This issue should be fixed as part of v13.5.4. Please let me know if it hasn't.

@BottlecapDave BottlecapDave added the awaiting release confirmation Waiting confirmation on new release fixing the issue label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release confirmation Waiting confirmation on new release fixing the issue bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants