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 call error #22

Closed
tjorim opened this issue May 25, 2023 · 3 comments
Closed

Service call error #22

tjorim opened this issue May 25, 2023 · 3 comments

Comments

@tjorim
Copy link

tjorim commented May 25, 2023

Tried to call the following service:

service: carbu_com.get_lowest_fuel_price_on_route
data:
  fuel_type: diesel
  country: BE
  from_postalcode: '2470'
  to_postalcode: '2490'
  ors_api_key: '123xyz_real_key'

Getting the following errors:

This error originated from a custom integration.

Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/carbu_com/utils.py:422
Integration: Carbu.com (documentation, issues)
First occurred: 14:41:48 (2 occurrences)
Last logged: 14:43:08

websocket_api script: Error executing script. Unexpected error for call_service at pos 1:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1849, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1889, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/carbu_com/__init__.py", line 128, in handle_get_lowest_fuel_price_on_route
    station_info = await hass.async_add_executor_job(lambda: session.getPriceOnRoute(country, fuel_type, from_postalcode, to_postalcode, ors_api_key))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/carbu_com/__init__.py", line 128, in <lambda>
    station_info = await hass.async_add_executor_job(lambda: session.getPriceOnRoute(country, fuel_type, from_postalcode, to_postalcode, ors_api_key))
  File "/config/custom_components/carbu_com/utils.py", line 422, in getPriceOnRoute
    assert from_location is not None
AssertionError

And

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/carbu_com/utils.py:422
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 14:41:48 (2 occurrences)
Last logged: 14:43:08

[546767443936] Error handling message: Unknown error (unknown_error) Jorim Tielemans from 127.0.0.1 (Mozilla/5.0 (Linux; Android 13; A063 Build/TKQ1.221220.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.53 Mobile Safari/537.36 Home Assistant/beta-10008-d81913b7-10008 (Android 13; A063))
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 647, in handle_execute_script
    await script_obj.async_run(msg.get("variables"), context=context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1849, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1889, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/carbu_com/__init__.py", line 128, in handle_get_lowest_fuel_price_on_route
    station_info = await hass.async_add_executor_job(lambda: session.getPriceOnRoute(country, fuel_type, from_postalcode, to_postalcode, ors_api_key))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/carbu_com/__init__.py", line 128, in <lambda>
    station_info = await hass.async_add_executor_job(lambda: session.getPriceOnRoute(country, fuel_type, from_postalcode, to_postalcode, ors_api_key))
  File "/config/custom_components/carbu_com/utils.py", line 422, in getPriceOnRoute
    assert from_location is not None
AssertionError
@myTselection
Copy link
Owner

Indeed, it seems the OpenRouteService response is not stable any longer. The convertion of postal codes to city's seems to fail, also for postal codes that used to work in the past.
I already experimented with here api instead of OpenRouteService, but I couldn't get it to work properly neither so far.

myTselection added a commit that referenced this issue May 25, 2023
alternative geocoding api used since v4.1.0
@myTselection
Copy link
Owner

please try with new release 4.1.0 with new (experimental) API. Documentation updated too (no more API key required). But only very limited tests executed...

@tjorim
Copy link
Author

tjorim commented May 25, 2023

Great, seems to work for me!

@tjorim tjorim closed this as completed May 25, 2023
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

2 participants