Coder Social home page Coder Social logo

Comments (2)

jensihnow avatar jensihnow commented on June 10, 2024 1

Same here, sometimes just flooding the log:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 137, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 270, in _async_refresh
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/spacex/sensor.py", line 559, in state
    self._state = launch_data["payloads_detail"][0]["name"]
IndexError: list index out of range

The value spacex_next_launch_payload (sensor.next_launch_payload) is unavailable. Looking at the API response (https://api.spacexdata.com/v4/launches/next) I see the payload very well undefined:

  "fairings": {
    "reused": null,
    "recovery_attempt": null,
    "recovered": null,
    "ships": []
  },
  "links": {
    "patch": {
      "small": null,
      "large": null
    },
    "reddit": {
      "campaign": null,
      "launch": null,
      "media": null,
      "recovery": null
    },
    "flickr": {
      "small": [],
      "original": []
    },
    "presskit": null,
    "webcast": null,
    "youtube_id": null,
    "article": null,
    "wikipedia": null
  },
  "static_fire_date_utc": null,
  "static_fire_date_unix": null,
  "net": false,
  "window": null,
  "rocket": "5e9d0d95eda69973a809d1ec",
  "success": null,
  "failures": [],
  "details": null,
  "crew": [],
  "ships": [],
  "capsules": [],
  "payloads": [],
  "launchpad": "5e9e4501f509094ba4566f84",
  "flight_number": 165,
  "name": "Transporter-5",
  "date_utc": "2022-05-25T18:27:00.000Z",
  "date_unix": 1653503220,
  "date_local": "2022-05-25T14:27:00-04:00",
  "date_precision": "hour",
  "upcoming": true,
  "cores": [
    {
      "core": "5f57c53d0622a6330279009f",
      "flight": 8,
      "gridfins": true,
      "legs": true,
      "reused": true,
      "landing_attempt": null,
      "landing_success": null,
      "landing_type": null,
      "landpad": null
    }
  ],
  "auto_update": true,
  "tbd": false,
  "launch_library_id": "949421ac-3802-499b-b383-d8274de7e147",
  "id": "6243ae24af52800c6e919258"
}

I guess this needs to be caught in code as SpaceX is not providing this data for each launch. I wonder if there is more values which might be missing and the code path should handle this accordingly.

from haspacex.

adam-olson avatar adam-olson commented on June 10, 2024

Looks like it is happening again.

2022-06-20 14:50:50 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 137, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 270, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in _stringify_state if (state := self.state) is None: File "/config/custom_components/spacex/sensor.py", line 559, in state self._state = launch_data["payloads_detail"][0]["name"] IndexError: list index out of range

from haspacex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.