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

Tractive integration not working. #111457

Open
alexandertonino opened this issue Feb 26, 2024 · 41 comments
Open

Tractive integration not working. #111457

alexandertonino opened this issue Feb 26, 2024 · 41 comments

Comments

@alexandertonino
Copy link

The problem

Hi,
I have this issue for a while now: Positions are not shown, battery percentage and other sensors are not loaded correctly.
I have 4 devices from tractive.

What version of Home Assistant Core has the issue?

core-2024.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

tractive

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tractive/

Diagnostics information

home-assistant_tractive_2024-02-26T08-16-17.243Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.device_tracker
Source: helpers/entity_platform.py:344
Integration: Geräte-Tracker (documentation, issues)
First occurred: 25. Februar 2024 um 21:13:43 (1 occurrences)
Last logged: 25. Februar 2024 um 21:13:43

Error while setting up tractive platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 344, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/tractive/device_tracker.py", line 31, in async_setup_entry
    entities = [TractiveDeviceTracker(client, item) for item in trackables]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tractive/device_tracker.py", line 48, in __init__
    f"{TRACKER_HARDWARE_STATUS_UPDATED}-{item.tracker_details['_id']}",
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^^
TypeError: byte indices must be integers or slices, not str

Additional information

No response

@home-assistant
Copy link

Hey there @Danielhiversen, @zhulik, @bieniu, mind taking a look at this issue as it has been labeled with an integration (tractive) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tractive can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tractive Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tractive documentation
tractive source
(message by IssueLinks)

@gurmukhp
Copy link

I am also facing this issue. It keeps saying "failed setup, will retry". Have tried to restart and uninstall and reinstall integration, but still no luck.

There were issues last year around "too many requests", but I'm not sure if this is the same problem.

Is there another version we can use? I just need presence detection.

@bieniu
Copy link
Member

bieniu commented Feb 29, 2024

@alexandertonino There are 6 animals configured on your account, so you receive a too many requests error. A change to the backend library is needed to fix this zhulik/aiotractive#20

@gurmukhp
Copy link

gurmukhp commented Mar 2, 2024

Is it possible to get a customised plugin? I only have one tracker and just need to know if it's home or not. That should reduce the API requests significantly?

@bieniu
Copy link
Member

bieniu commented Mar 4, 2024

customised plugin

What do you mean? You can use aiotractive package from my branch https://github.com/bieniu/aiotractive/tree/too-many-requests

@gurmukhp
Copy link

gurmukhp commented Mar 6, 2024

Thanks, I'm looking for a Home Assistant plugin that only checks the location of the device, I don't need the other things like battery status, inside wifi zone etc. I assume this will reduce the chance of there being timeouts? I have quite a lot of automations set up to trigger when my pet is not at home and at the moment, none of them are triggering. Is thre a quick and dirty way to get location updates into Home Assistant? It doesn't even matter if the timeout period is something like 5 minutes or so.

thanks

@bieniu
Copy link
Member

bieniu commented Jun 2, 2024

Hi. Are you still experiencing this problem?

@bieniu
Copy link
Member

bieniu commented Jun 2, 2024

Hi @Raouzer Sorry for tagging you directly. Are you still experiencing the too many requests problem?

@bieniu
Copy link
Member

bieniu commented Jun 2, 2024

Due to the fact that the PR fixing the problem in the backand library has remained unanswered for many months, I have prepared a workaround for the problem on the HA side. Is anyone able to test them? This zip must be unpacked into the custom_components folder. Unfortunately, this version of the integration works with HA 2024.6 (beta).
tractive_too_many_requests_fix_v1.zip

@Raouzer
Copy link

Raouzer commented Jun 2, 2024

Hi,

Yes I have the problem again since 2024.05.

Before, I was still able to retrieve information from one tracker (Others are disabled on HA) .

I am currently in 2024.05.1. I will wait for the 2024.06 release to test your solution.

Regards

@Raouzer
Copy link

Raouzer commented Jun 7, 2024

Hi bieniu,

i juste updated my Home assistant to 2024.6.

First after the update, whitout unzip the library, the tractive integration failed to setup.

After unzip de library, i have always the same result.

2024-06-07 10_55_02-Clipboard

This error originated from a custom integration.

Logger: custom_components.tractive.config_flow
Source: custom_components/tractive/config_flow.py:58
integration: Tractive
First occurred: 10:43:56 AM (1 occurrences)
Last logged: 10:43:56 AM

Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiotractive/api.py", line 92, in authenticate
    async with self.session.request(
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 696, in _request
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 429, message='Too Many Requests', url=URL('https://graph.tractive.com/3/auth/token')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/tractive/config_flow.py", line 58, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tractive/config_flow.py", line 34, in validate_input
    user_id = await client.user_id()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiotractive/api.py", line 49, in user_id
    await self.authenticate()
  File "/usr/local/lib/python3.12/site-packages/aiotractive/api.py", line 115, in authenticate
    raise TractiveError from error
aiotractive.exceptions.TractiveError

Regards

@bieniu
Copy link
Member

bieniu commented Jun 7, 2024

Please attach a log file.

@Raouzer
Copy link

Raouzer commented Jun 7, 2024

Hi,

Logs here

Removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 8, 2024

First of all, please notice that three custom integrations (starlink, midea_ac_lan, irm_kmi) are blocking event loop. This could have negative impact on other integrations or even on the entire Home Assistant instance. You should enable debug mode (this will protect your HA instance).
I opened an issue for starlink, please provide more data (HA version, integration version) archerne/hastarlink#13
Please open an issue here (I don't have enough data to fill up the form) https://github.com/georgezhao2010/midea_ac_lan/issues
You should update irm-kmi integration jdejaegh/irm-kmi-ha#39

Please use this custom version: tractive_too_many_requests_fix_v2.zip

@Raouzer
Copy link

Raouzer commented Jun 8, 2024

Hi,

Thanks! Starlink was removed to install the official integration. Irm_kml removed too. Midea on debug mode.

For tractive, no more results.

image

I didn't see anything about tractive on logs:

Removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 9, 2024

Try this one tractive_too_many_requests_fix_v3.zip

Add this to your configuration.yaml:

logger:
  default: error
  logs:
    aiotractive: debug
    custom_components.tractive: debug

@Raouzer
Copy link

Raouzer commented Jun 9, 2024

Hi,

The integration pass the setup state for the first start but all devices/entities are unavailable.

After a reload, the integration can't pass the setup state anymore.

image

Logs:

removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 9, 2024

It seems that Tractive changed too many requests message. Try this one tractive_too_many_requests_fix_v4.zip

@Raouzer
Copy link

Raouzer commented Jun 9, 2024

Hi,

One device have entities availables, the entities of others devices are unavailables.

image

image

image

Logs:

Removed

Regards.

@bieniu
Copy link
Member

bieniu commented Jun 9, 2024

Looking at the log, the integration setup was successful, the too many requests event was detected and the attempt to get data was repeated with a delay. In this case, the platforms (sensor, binary_sensor, etc.) will be configured before the integration receives complete data and the entities will be unavailable at the start. They should become available after the first event from the API, just wait about 3 minutes.
Try this version tractive_too_many_requests_fix_v5.zip

@Raouzer
Copy link

Raouzer commented Jun 10, 2024

Hi,

After 12h, all devices and entities are unavailables.

Logs here:

Removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 10, 2024

One more tractive_too_many_requests_fix_v6.zip

@Raouzer
Copy link

Raouzer commented Jun 11, 2024

Hi,

New logs :
Removed

After a restart, i have two possible results:

  • Every devices / entites are unavailables.
  • One random device and own entities are availables

Regards

@bieniu
Copy link
Member

bieniu commented Jun 12, 2024

Hmm that's strange 🤔

@Raouzer
Copy link

Raouzer commented Jun 13, 2024

Hi,

At the moment, i have only one devices and entites linked available on tractive integration. But on log, i can see data from others devices...

If that can help you.

Logs :

Removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 16, 2024

Let's try a different approach... tractive_too_many_requests_fix_v7.zip

@Raouzer
Copy link

Raouzer commented Jun 16, 2024

Hi,

Unfortunatly, the integration can't setup.

Logs

Removed

Regards

@Kokahontas13

This comment was marked as off-topic.

@bieniu
Copy link
Member

bieniu commented Jun 17, 2024

Unfortunatly, the integration can't setup.

What do yo mean? I can see that integration works and 6 trackers get events from the Tractive API.

@bieniu
Copy link
Member

bieniu commented Jun 17, 2024

I increased sleep time, please test and attach the log file tractive_too_many_requests_fix_v8.zip

@Raouzer
Copy link

Raouzer commented Jun 17, 2024

Hi,

I meant that :

image

Here log vor V8:

Removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 17, 2024

Last log was totally different, did you get the right file?

@Raouzer
Copy link

Raouzer commented Jun 17, 2024

Hum,

I'm having a lot of slowness at the moment on HA. I deleted the custom tractive folder to verify that this was not the cause. I also did update 2024.6.3 to fix a bug on Unify protect.

This is the last file.

Regards

@bieniu
Copy link
Member

bieniu commented Jun 19, 2024

One more version tractive_too_many_requests_fix_v9.zip

@Raouzer
Copy link

Raouzer commented Jun 20, 2024

Hi,

The integration can't load.

image

image

Logs:

removed

Regards

@bieniu
Copy link
Member

bieniu commented Jun 20, 2024

@Raouzer
Copy link

Raouzer commented Jun 20, 2024

Hi,

That's great, i have now every devices and entites availables !

image

Logs:
removed

Thanks !

Regards

@bieniu
Copy link
Member

bieniu commented Jun 20, 2024

This is very good news! The worse part is that I had to modify the backend library to achieve this. We need to reach the author of aiotractive to resolve this issue.

@Raouzer
Copy link

Raouzer commented Jun 20, 2024

That's realy strange, it seems like it's random.

After a restart of HA, intregration failed to setup anymore.

image

Logs:

removed

Regards

@Raouzer
Copy link

Raouzer commented Jun 20, 2024

Hi,

Intregration back available after a manual reload :) . I have to wait 10 - 15 minutes after the HA restart to do this manual reload. If i do it too early that's not working.

home-assistant_2024-06-20T14-16-41.794Z.log

regards

@bieniu
Copy link
Member

bieniu commented Jun 20, 2024

Based on the log, I can say that there were a lot of "too many requests" errors, but eventually the integration was configured for all trackers. Entities should become available when the API sends new data.

If you restart HA frequently, you will often receive "too many requests" errors. There's nothing we can do about it.

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

No branches or pull requests

6 participants