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

SmartEnergy - EPEX Spot: Get lowest price interval call fails #141

Open
clutwo opened this issue Jul 13, 2024 · 3 comments
Open

SmartEnergy - EPEX Spot: Get lowest price interval call fails #141

clutwo opened this issue Jul 13, 2024 · 3 comments

Comments

@clutwo
Copy link

clutwo commented Jul 13, 2024

Trying to get lowest (or highest) price interval service call fails with SmartEnergy. Same thing works for Awattar (at).

image

As far as I can tell, this is the relevant log:

2024-07-13 12:51:17.777 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140305739194160] Error handling message: Unknown error (unknown_error) Clemens from 192.168.1.7 (Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0)
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 793, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1770, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 465, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 529, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, 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(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 2731, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/init.py", line 118, in get_lowest_price_interval
return _find_extreme_price_interval(call, lambda a, b: a < b)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot/init.py", line 148, in _find_extreme_price_interval
coordinator = entries[next(iter(device_entry.config_entries))]
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '01J2JXSEXMM33Y0Z7GN7NXPJCN'

@bdynamic
Copy link

bdynamic commented Jul 14, 2024

I have the same Problem. Before reporting this error I updated to the latest git version

Update: Switching from SMARD.de backend to Tibber (de) Backend solved the problem for me

This is my error log:

`2024-07-14 10:27:44.645 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration epex_spot which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-07-14 10:27:56.258 ERROR (MainThread) [custom_components.epex_spot.SourceShell] no data found for <custom_components.epex_spot.EPEXSpot.SMARD.SMARD object at 0x7f8468a4e0>
2024-07-14 10:27:56.260 ERROR (MainThread) [custom_components.epex_spot.SourceShell] no data found for <custom_components.epex_spot.EPEXSpot.SMARD.SMARD object at 0x7f8468a4e0>
2024-07-14 10:27:57.022 ERROR (SyncWorker_2) [pyhik.hikvision] Unable to fetch deviceInfo, error: HTTPConnectionPool(host='192.168.188.89', port=80): Max retries exceeded with url: /ISAPI/System/deviceInfo (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7fbb1850>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2024-07-14 10:27:57.238 ERROR (SyncWorker_2) [homeassistant.components.hikvision.binary_sensor] Hikvision event stream has no data, unable to set up
2024-07-14 10:27:57.425 ERROR (MainThread) [tibber.home] Error in rt_subscribe
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/tibber/home.py", line 439, in _start
async for data in self._tibber_control.realtime.sub_manager.session.subscribe(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'session'
2024-07-14 10:28:05.550 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{ (as_timestamp(now()) + states('sensor.print_time_left') | int) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 573, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2364, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 1, in top-level template code
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2056, in forgiving_int_filter
raise_no_default("int", value)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1668, in raise_no_default
raise ValueError(
ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (as_timestamp(now()) + states('sensor.print_time_left') | int) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}' but no default was specified

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 699, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 575, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (as_timestamp(now()) + states('sensor.print_time_left') | int) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}' but no default was specified
2024-07-14 10:28:05.559 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ (as_timestamp(now()) + states('sensor.print_time_left') | int) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}' but no default was specified') while processing template 'Template<template=({{ (as_timestamp(now()) + states('sensor.print_time_left') | int) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.calculated_time_printend'

AttributeError: 'NoneType' object has no attribute 'items'
2024-07-14 10:29:01.423 ERROR (MainThread) [tibber.realtime] Watchdog: Connection is down, 2024-07-14 10:29:11.423069
2024-07-14 10:29:14.824 DEBUG (MainThread) [custom_components.epex_spot.extreme_price_interval] no data available yet: earliest_start=2024-07-14 06:00:00+02:00, latest_end=2024-07-14 19:30:00+02:00
`

@c2who
Copy link

c2who commented Jul 14, 2024

I have the same error.

The KeyError: '01J2S2GX9EXHSMDDPN1T595C0V' is the unique_id of an epex_spot_sensor with "most expensive" price mode. If I delete this sensor, the problem is gone and the service call is working again.

Epex_spot_sensor's with "cheapest" price mode are not affecting the service calls.

Edit: Looks like it only happens when the device_id was provided in the service call.

@mampfes
Copy link
Owner

mampfes commented Jul 20, 2024

SmartEnergy API is current down: #143
So, investigation has to wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants