Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API returns 404 #102

Open
4 tasks done
skinkie opened this issue Jan 18, 2024 · 5 comments
Open
4 tasks done

API returns 404 #102

skinkie opened this issue Jan 18, 2024 · 5 comments

Comments

@skinkie
Copy link

skinkie commented Jan 18, 2024

System Health details

System Information

version core-2024.1.3
installation_type Unknown
dev false
hassio false
docker false
user skinkie
virtualenv false
python_version 3.11.4
os_name Linux
os_version 6.1.51-0-rpi
arch aarch64
timezone Europe/Amsterdam
config_dir /home/skinkie/.homeassistant
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4915
Installed Version 1.33.0
Stage running
Available Repositories 1379
Downloaded Repositories 5
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Dashboards
dashboards 1
resources 1
views 5
mode storage
Recorder
oldest_recorder_run January 11, 2024 at 9:17 AM
current_recorder_run January 18, 2024 at 10:10 AM
estimated_db_size 580.99 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

TGTG api returns 404

Reproduction steps

  1. Start ha
  2. Observe log.

Debug logs

2024-01-18 10:10:44.864 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up tgtg platform for sensor
Traceback (most recent call last):
  File "/home/skinkie/.local/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/skinkie/.homeassistant/custom_components/tgtg/sensor.py", line 81, in setup_platform
    add_entities([TGTGSensor(each_item_id)])
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/skinkie/.homeassistant/custom_components/tgtg/sensor.py", line 102, in __init__
    self.update()
  File "/home/skinkie/.homeassistant/custom_components/tgtg/sensor.py", line 212, in update
    self.tgtg_orders = tgtg_client.get_active()["orders"]
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/skinkie/.homeassistant/deps/lib/python3.11/site-packages/tgtg/__init__.py", line 426, in get_active
    raise TgtgAPIError(response.status_code, response.content)
tgtg.exceptions.TgtgAPIError: (404, b'')

Diagnostics dump

I guess if it fails to start you cannot reach this point.

@skinkie
Copy link
Author

skinkie commented Jan 18, 2024

With some hacking I disabled the orders in two places. That allows for starting the integration.

@Cafun
Copy link

Cafun commented Feb 17, 2024

So, I'm currious.. What did you do to make it work again?

@skinkie
Copy link
Author

skinkie commented Feb 17, 2024

--- sensor.py
+++ /home/skinkie/.homeassistant/custom_components/tgtg/sensor.py
@@ -188,6 +188,7 @@
 
         orders_placed = 0
         total_quantity_ordered = 0
+        """
         for order in self.tgtg_orders:
             if "item_id" in order:
                 if order["item_id"] == str(self.item_id):
@@ -198,6 +199,7 @@
                         data[ATTR_PICKUP_WINDOW_CHANGED] = order["pickup_window_changed"]
                     if "cancel_until" in order:
                         data[ATTR_CANCEL_UNTIL] = order["cancel_until"]
+        """
         data[ATTR_ORDERS_PLACED] = orders_placed
         if total_quantity_ordered > 0:
             data[ATTR_TOTAL_QUANTITY_ORDERED] = total_quantity_ordered
@@ -209,7 +211,7 @@
         """
         global tgtg_client
         self.tgtg_answer = tgtg_client.get_item(item_id=self.item_id)
-        self.tgtg_orders = tgtg_client.get_active()["orders"]
+        # self.tgtg_orders = tgtg_client.get_active()["orders"]
 
         self.store_name = self.tgtg_answer["display_name"]
         self.item_qty = self.tgtg_answer["items_available"]

@JackPoint
Copy link

Can you submit this as a PR? That would help everyone

@skinkie
Copy link
Author

skinkie commented Mar 1, 2024

Can you submit this as a PR? That would help everyone

This is not a fix. This is hack to ignore orders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants