core icon indicating copy to clipboard operation
core copied to clipboard

Launch Library becomes unavailable often - does not restart

Open peyn opened this issue 9 months ago • 1 comments

The problem

As mentioned here (https://github.com/home-assistant/core/issues/114094) the Launch Library often times out and has its sensors set to "Unavailable" state. All fine. Except, the library seems to be very unstable - seems like the updates are at random times, especially if a timeout was met: image

To add salt to injury, every time I reload the integration's config the data is read correctly. I even created an automation to do that. It would be great if the data was retrieved at specific time interval (30 minutes?) and/or we could have a setting to change that interval.

What version of Home Assistant Core has the issue?

core-2024.5.2

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

Launch Library

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Error description states:
Error fetching launch_library data: Timeout while fetching data from https://ll.thespacedevs.com/2.2.0/dashboard/starship/

Additional information

No response

peyn avatar May 09 '24 13:05 peyn

Hey there @ludeeus, @durgnomis-drol, mind taking a look at this issue as it has been labeled with an integration (launch_library) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of launch_library 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 launch_library 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)


launch_library documentation launch_library source (message by IssueLinks)

home-assistant[bot] avatar May 09 '24 13:05 home-assistant[bot]

Hi,

Some more information about the issue.

You can see in the image pasted below that Next Launch information quite often cannot read the data from Starship related API. This affects not only the Starship related sensor, but all available from the Launch Library. However, right after the "Next Launch" sensor state is set to "Unavailable" my own automation kicks in which triggers yet another refresh of the state - which ends with a success. image

This results in all sensors being updated: image

The reason for that, in my opinion, is that the Starship api is hella slow... This is the Network > Timing from Chrome (on 1GB/1GB internet connection): image

And no wonder, as far as I can see it reads all the information it has related to the Starship. Which is a lot - about 1,5 MB: image

What surprises me is that, it_seems, there is no caching of the data returned by API, even though Starship events are so rare. The server puts together all this information every time the request is made - thus the long response time.

I looked into the code of Launch Library, but I don't really know Python and the Home Assistant is a quite complex project already, so I had no luck in finding anything. My ideas at this point are:

  1. After the initial Starship refresh, if it fails, refresh it one more time
  2. Do not make all sensors "Unavailable" when Starship refresh fails, make only the ones related to Starship
  3. Change the Starship related data provider, e.g. https://nextspaceflight.com/starship/ - would require new additional logic for reading and/or parsing of the data. Maybe multiple providers with an option to select the one to be used?
  4. Add an option to disable the Starship information update.

Kind regards, Mateusz

peyn avatar May 11 '24 09:05 peyn

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.