Chouffy / home_assistant_tgtg

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

Error 410 on first installation: "code":"ENTITY_DISABLED","message":"Entity ItemId(1234) is not active" #82

Closed OldShaterhan closed 1 year ago

OldShaterhan commented 1 year ago

System Health details

System Information

version core-2023.7.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.4
os_name Linux
os_version 6.1.21-v8
arch aarch64
timezone Europe/Warsaw
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4716 Installed Version | 1.32.1 Stage | running Available Repositories | 1273 Downloaded Repositories | 20
Airly can_reach_server | ok -- | -- requests_remaining | 7 requests_per_day | 100
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
GIOŚ can_reach_server | pending -- | --
Home Assistant Supervisor host_os | Home Assistant OS 10.3 -- | -- update_channel | stable supervisor_version | supervisor-2023.07.1 agent_version | 1.5.1 docker_version | 23.0.6 disk_total | 116.5 GB disk_used | 15.2 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.7.1), File editor (5.6.0), Node-RED (14.4.1), RPC Shutdown (2.4), Mosquitto broker (6.2.1), Spotify Connect (0.12.4), Grocy (0.19.1), Home Assistant Google Drive Backup (0.111.1), AdGuard Home (4.8.12), ESPHome (2023.7.0), Zigbee2MQTT (1.32.1-1), Matter Server (4.8.3), Music Assistant BETA (2.0.0b59)
Dashboards dashboards | 7 -- | -- resources | 1 views | 19 mode | storage
Recorder oldest_recorder_run | 23 maja 2023 12:11 -- | -- current_recorder_run | 23 lipca 2023 00:13 estimated_db_size | 1403.11 MiB database_engine | sqlite database_version | 3.41.2
Spotify api_endpoint_reachable | pending -- | --

Checklist

Describe the issue

Integration cannot set up.

Reproduction steps

  1. Setup integration using data from tgtg.py script

Please note this is a brand new account.

Debug logs

Error while setting up tgtg platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, 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 76, in setup_platform
    add_entities([TGTGSensor(each_item_id)])
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tgtg/sensor.py", line 96, in __init__
    self.update()
  File "/config/custom_components/tgtg/sensor.py", line 189, 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","message":"Entity ItemId(1234) is not active"}]}')

Diagnostics dump

No response

Chouffy commented 1 year ago

Hi @OldShaterhan Did you add any favorites in your TGTG account? or did you specified some item id? I would guess that you just copy pasted the configuration option section, including the optional sections with

    item:
      # item_id 1
      - 1234

This isn't correct. Try to remove the whole tgtg entry from your configuration.yaml, and replace it with the content of the tgtg_get_token script, as outlined in the installation steps

OldShaterhan commented 1 year ago

Yes, I added optional property (I thought I have only token-generator code taken and exemplary removed).