grocy: Errors on not using products

Describe the bug I removed stock from my grocy addon configuration, as I don’t use them. Now the integration throws a lot of errors relating to products.

To Reproduce Steps to reproduce the behavior:

  1. change to stock: false in addon config
  2. Restart home assistant
  3. Check logs

Are you using HASSIO to run grocy? Yes

configuration.yaml entry

Your grocy component config entry

Additional context

2020-03-18 19:54:16 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/grocy/__init__.py", line 220, in async_update_expiring_products
    self.client.expiring_products, [True]))
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 161, in expiring_products
    raw_expiring_product = self.volatile_stock().expiring_products
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 158, in volatile_stock
    return self._api_client.get_volatile_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 314, in get_volatile_stock
    return CurrentVolatilStockResponse(parsed_json)
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 199, in __init__
    self._expiring_products = [CurrentStockResponse(product) for product in parsed_json.get('expiring_products')]
TypeError: 'NoneType' object is not iterable

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 26 (13 by maintainers)

Most upvoted comments

I replaced it, but I had to reboot. Then it worked! Still got the entity sensor.grocy_shopping_list though.

Thx ! If you didn’t disable shopping list, I can’t check more. Disable stock does not disable shopping list (Grocy behavior). Maybe you should disable shopping list too. Can you check log to see if you have some warning about it ?

Thanks again for your feedback and time. I will do a PR after your report.

Regards

2020-03-19 11:43:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/grocy/config_flow.py", line 89, in _test_credentials
    client.stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 164, in stock
    raw_stock = self._api_client.get_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 366, in get_stock
    parsed_json = self._do_get_request("stock")
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 334, in _do_get_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://192.168.1.78:9192/api/stock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 163, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 50, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/grocy/config_flow.py", line 35, in async_step_user
    user_input["port"],user_input["verify_ssl"]
  File "/config/custom_components/grocy/config_flow.py", line 92, in _test_credentials
    _LOGGER.exception(e)
NameError: name '_LOGGER' is not defined
2020-03-19 11:43:59 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/grocy/config_flow.py", line 89, in _test_credentials
    client.stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 164, in stock
    raw_stock = self._api_client.get_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 366, in get_stock
    parsed_json = self._do_get_request("stock")
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 334, in _do_get_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://192.168.1.78:9192/api/stock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 163, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 50, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/grocy/config_flow.py", line 35, in async_step_user
    user_input["port"],user_input["verify_ssl"]
  File "/config/custom_components/grocy/config_flow.py", line 92, in _test_credentials
    _LOGGER.exception(e)
NameError: name '_LOGGER' is not defined
2020-03-19 11:44:33 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/grocy/config_flow.py", line 89, in _test_credentials
    client.stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 164, in stock
    raw_stock = self._api_client.get_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 366, in get_stock
    parsed_json = self._do_get_request("stock")
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 334, in _do_get_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://192.168.1.78:9192/api/stock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 163, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 50, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/grocy/config_flow.py", line 35, in async_step_user
    user_input["port"],user_input["verify_ssl"]
  File "/config/custom_components/grocy/config_flow.py", line 92, in _test_credentials
    _LOGGER.exception(e)
NameError: name '_LOGGER' is not defined
2020-03-19 11:44:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/config/custom_components/grocy/config_flow.py", line 89, in _test_credentials
    client.stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 164, in stock
    raw_stock = self._api_client.get_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 366, in get_stock
    parsed_json = self._do_get_request("stock")
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 334, in _do_get_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://192.168.1.78:9192/api/stock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 163, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 50, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/grocy/config_flow.py", line 35, in async_step_user
    user_input["port"],user_input["verify_ssl"]
  File "/config/custom_components/grocy/config_flow.py", line 92, in _test_credentials
    _LOGGER.exception(e)
NameError: name '_LOGGER' is not defined

TY for checking so quickly 😃

I released 0.14.0 of pygrocy like an hour ago, so that version should include the latest changes.