Chouffy / home_assistant_tgtg

TooGoodToGo items stock as sensor in Home Assistant
MIT License
65 stars 18 forks source link

TGTG API Error 410 during startup #89

Closed LarsStegman closed 10 months ago

LarsStegman commented 10 months ago

System Health details

System Information

version core-2023.11.0
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.6
os_name Linux
os_version 6.1.59
arch x86_64
timezone Europe/Amsterdam
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4469 Installed Version | 1.33.0 Stage | running Available Repositories | 1324 Downloaded Repositories | 30
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 11.1 -- | -- update_channel | stable supervisor_version | supervisor-2023.10.1 agent_version | 1.6.0 docker_version | 24.0.6 disk_total | 30.8 GB disk_used | 17.2 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Zigbee2MQTT (1.33.2-1), File editor (5.6.0), Mosquitto broker (6.3.1), Terminal & SSH (9.7.1), ESPHome (2023.10.6)
Dashboards dashboards | 3 -- | -- resources | 26 views | 15 mode | storage
Recorder oldest_recorder_run | 31 oktober 2023 om 08:21 -- | -- current_recorder_run | 4 november 2023 om 09:45 estimated_db_size | 1062.96 MiB database_engine | sqlite database_version | 3.41.2

Checklist

Describe the issue

Sensors fail to work

Error while setting up tgtg platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tgtg/sensor.py", line 77, in setup_platform
    add_entities([TGTGSensor(each_item_id)])
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tgtg/sensor.py", line 97, in __init__
    self.update()
  File "/config/custom_components/tgtg/sensor.py", line 190, in update
    self.tgtg_answer = tgtg_client.get_item(item_id=self.item_id)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/tgtg/__init__.py", line 287, in get_item
    raise TgtgAPIError(response.status_code, response.content)
tgtg.exceptions.TgtgAPIError: (410, b'{"errors":[{"code":"ENTITY_DISABLED"}]}')

Reproduction steps

Config:

sensor:
  - platform: tgtg
    email: !secret tgtg_username
    access_token: !secret tgtg_access_token
    refresh_token: !secret tgtg_refresh_token
    user_id: !secret tgtg_user_id
    cookie: !secret tgtg_cookie
    scan_interval: 180
    item:
      - xxxxx  # this contains actual IDs in my config. All the secrets also exist
  1. Restart Home Assistant
  2. The error will show up in the logs

I think this might be related to a new version of Home Assistant, because the problem started occurring after updating to 2023.11

Debug logs

Too big to paste, 15MB of data.

Diagnostics dump

No response

tjorim commented 10 months ago

Try checking if all items (IDs) still exist.

LarsStegman commented 10 months ago

Yes, that solved it. Looks like they did some clean up, because a lot of inactive stores were removed.