ljmerza / ha-our-groceries

Our Groceries Integration for Home Assistant
MIT License
38 stars 8 forks source link

Error when calling `remove_from_list` service #34

Closed jampez77 closed 1 year ago

jampez77 commented 1 year ago

Version of the custom_component

OG: 1.5.1 HA OS: 9.4 HA: 2023.1.2

Configuration

username: !secret jamie_email
password: !secret our_groceries_password

service: ourgroceries.remove_from_list
data:
  list_id: 06WNLv3Pqyfm6zratC4GF3
  items: Black Ink (HP301 - Deskjet 2542)

Describe the bug

Calling remove_from_list service returns an error and item(s) remains on list.

Debug log


2023-01-09 15:45:28.112 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281473535619136] 'value'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/ourgroceries/__init__.py", line 85, in async_service_handler
    await getattr(services, method['method'])(**params)
  File "/config/custom_components/ourgroceries/__init__.py", line 250, in async_remove_from_list
    internal_items = await self._lookup_items(internal_id, items)
  File "/config/custom_components/ourgroceries/__init__.py", line 228, in _lookup_items
    return self._lookup_data(response['list']['items'], 'value', items)
  File "/config/custom_components/ourgroceries/__init__.py", line 217, in _lookup_data
    lookup[data[value_key]] = data['id']
KeyError: 'value'