ha-rewe icon indicating copy to clipboard operation
ha-rewe copied to clipboard

Addon stopped working

Open simon-mueller opened this issue 2 years ago • 8 comments

The problem

The addon doesn't retrieve any data.

What version of Home Assistant Core has the issue?

2024.2.2

What version of Rewe Integration has the issue?

2024.01.0

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-02-17 10:30:38.490 DEBUG (MainThread) [custom_components.rewe.sensor] Sensor async_setup_entry
2024-02-17 10:30:38.811 ERROR (MainThread) [custom_components.rewe.sensor] Cannot retrieve discounts for: 840377 - Maybe a typo or the server rejected the request.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/rewe/sensor.py", line 135, in async_update
    data = await hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/rewe/sensor.py", line 202, in fetch_rewe_discounts
    data = self._session.get(url).json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2024-02-17 10:30:38.816 ERROR (MainThread) [custom_components.rewe.sensor] Cannot retrieve data for: '840377'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/rewe/sensor.py", line 135, in async_update
    data = await hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/rewe/sensor.py", line 202, in fetch_rewe_discounts
    data = self._session.get(url).json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/rewe/sensor.py", line 193, in async_update
    _LOGGER.exception('{}'.format(url, data['error']))
                                  ^^^
NameError: name 'url' is not defined

Additional information

It stopped working on Feb, 7th. I install the homeassistant updates quite promptly. So maybe this has to do with a new version of homeassistant itself.

simon-mueller avatar Feb 18 '24 17:02 simon-mueller

This happened due to API changes in the REWE backend and is fixed in a dedicated branch: https://github.com/foo-git/rewe-discounts/tree/additional_retrieval_method

olant avatar Feb 25 '24 20:02 olant

Do you have a corresponding github issue in the REWE backend repository to fix this problem?

DominikLudwig1995 avatar Mar 04 '24 08:03 DominikLudwig1995

Do you have a corresponding github issue in the REWE backend repository to fix this problem?

Not needed, its fixed in the backend repo. I will need to merge it within the HA integration which I haven't had the time yet. But a fix will definitely come.

https://github.com/foo-git/rewe-discounts/releases/tag/v2.6

FaserF avatar Mar 04 '24 18:03 FaserF

Should now be working again with the latest version of this integration 2024.03.0

FaserF avatar Mar 17 '24 01:03 FaserF

It's still not working for me. In the logs I can see this:

2024-03-17 15:44:57.824 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.rewe_840377 exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored

simon-mueller avatar Mar 17 '24 14:03 simon-mueller

It's still not working for me. In the logs I can see this:

2024-03-17 15:44:57.824 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.rewe_840377 exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored

This has nothing to do with this here, see: https://github.com/FaserF/ha-rewe/issues/14

FaserF avatar Mar 17 '24 15:03 FaserF

Did they make changes to the API again?

This error originated from a custom integration.

Logger: custom_components.rewe.sensor
Source: custom_components/rewe/sensor.py:204
integration: Rewe Discounts (documentation, issues)
First occurred: March 31, 2024 at 09:54:29 (4 occurrences)
Last logged: 16:00:28

FAIL: In the returned query, no data was found. The API output seems to have changed and the code needs to be adjusted. Please report it to https://github.com/foo-git/rewe-discounts and not the HA integration developer!
Traceback (most recent call last):
  File "/config/custom_components/rewe/sensor.py", line 166, in async_update
    for category in data['categories']:
                    ~~~~^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/rewe/sensor.py", line 204, in async_update
    for filter in data['filters']:
                  ~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

simon-mueller avatar Apr 02 '24 14:04 simon-mueller

Yes, has changed again, see: https://github.com/foo-git/rewe-discounts/issues/19

FaserF avatar Apr 03 '24 13:04 FaserF