grocy: Can't install component

Describe the bug I have followed the instructions in readme for installing the custom component using HACS (I’m on a Rasberry Pi 3 with Hassio and have Grocy from the add-on store). When I try to add the integration from the UI (step 10) it spins for a while and just returns to the list of integrations.

I also tried adding the configuration (details below) to configuration.yaml, with similar results. I do get a message in the HA logs that 2020-08-15 11:15:18 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for grocy 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. but still don’t see any states (or services) from the custom component in developer tools and Grocy says the API Key has never been used.

To Reproduce Steps to reproduce the behavior:

  1. Install Grocy from the Add-on store
  2. In the ‘Network’ section of the add-on config, input 9192 in the host field.
  3. Go to Grocy > Wrench icon > Manage API keys > Add
  4. Install the Grocy integration component using HACS
  5. Restart Home Assistant
  6. In the HA UI go to “Configuration” -> “Integrations” click “+” and search for “Grocy”
  7. After spinning for a while the panel will close and return to the list of integrations.

Expected behavior Trying to use the grocy component to integrate tasks and lists within HA.

Are you using HASSIO to run grocy? Yes

configuration.yaml entry

grocy:
  url: "http://a0d7b954_grocy"
  api_key: "FvoGibgK2UVSo0Uudyoq6Unchitu5vhCQKmrLWk4rkze07DgCz"
  verify_ssl: false
  port: 9192
  sensor:
    - enabled: true
  binary_sensor:
    - enabled : true

Additional context Have been facing this issue since HA 110 - just updated to 114 and still have the same experience.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15

Most upvoted comments

You’re right - redoing http://192.168.0.66 produces the “Unknown error occurred”, but in the logs it shows “400 Client Error: Bad Request for url: http://192.168.0.66:9192/api/stock”. When I key this into a browser I get the same error, but if I change it to https it works. And then setting the API URL to https://192.168.0.66 it works.

It looks like the reason for the unknown error is that in handling this error it gets another exception. The relevant part of the log is below:

2020-08-19 11:16:46 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
    await self.hass.async_add_executor_job(client.stock)
  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 435, in stock
    raw_stock = self._api_client.get_stock()
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 475, in get_stock
    parsed_json = self._do_get_request("stock")
  File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 443, 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: 400 Client Error: Bad Request for url: http://192.168.0.66: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 73, 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 125, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 145, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 54, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 103, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 153, 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 201, 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