core: (new) reolink NVR shows error

The problem

Using today’s Reolink integration from https://github.com/home-assistant/core/pull/84081 on <dev> code, with admin/password and dns-name for the NVR, it seems to basically work, except I saw the below error. Otherwise my NVR seems to be working OK, and IIRC the HACS version (different install of HA here) was working OK too.

I’m not using any proxy etc, and in fact the NVR is connected (wired) to the same switch as my dev machine, which is running this code.

2022-12-29 15:58:02.356 ERROR (MainThread) [reolink_ip.api] Host nvr.roberts:443: API error: API returned HTTP status ERROR code 502/Bad Gateway..
2022-12-29 15:58:02.358 ERROR (MainThread) [homeassistant.components.reolink] Unexpected error fetching reolink.NVR data: API returned HTTP status ERROR code 502/Bad Gateway.
Traceback (most recent call last):
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/homeassistant/helpers/update_coordinator.py", line 181, in _async_update_data
    return await self.update_method()
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/homeassistant/components/reolink/__init__.py", line 60, in async_device_config_update
    await host.update_states()  # Login session is implicitly updated here, so no need to explicitly do it in a timer
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/homeassistant/components/reolink/host.py", line 124, in update_states
    return await self._api.get_states()
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/venv/lib/python3.10/site-packages/reolink_ip/api.py", line 863, in get_states
    response = await self.send(body)
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/venv/lib/python3.10/site-packages/reolink_ip/api.py", line 2369, in send
    raise e
  File "/Users/simonroberts/src/github/home-assistant/home-assistant-core/venv/lib/python3.10/site-packages/reolink_ip/api.py", line 2355, in send
    raise ApiError("API returned HTTP status ERROR code {}/{}.".format(response.status, response.reason))
reolink_ip.exceptions.ApiError: API returned HTTP status ERROR code 502/Bad Gateway.

What version of Home Assistant Core has the issue?

Home Assistant 2023.2.0.dev0 Frontend 20221228.0 - latest

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Reolink

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The Json error on intial setup, I have seen and experianced before. I am not sure why that happens. I tried implementing a retry but that was not accepted upstream.

I will try to discussus if we can implement the retry for 502 and json error.

I will also see if I can reduce API calls by making a single request for all channels instead of a request per channel.

@lyricnz I made a PR to the upstream library that will fix this issue: https://github.com/JimStar/reolink_ip/pull/11