djtimca / HASpaceX

Home Assistant integration for SpaceX Next Launch and Starman data.
https://github.com/djtimca/HASpaceX
Apache License 2.0
32 stars 5 forks source link

Error adding entities #16

Closed basdejong95 closed 4 years ago

basdejong95 commented 4 years ago

Since the crew-1 mission, the spacex integration fails to add the entities for the next launch.

Logger: homeassistant.components.sensor
Source: custom_components/spacex/sensor.py:467
Integration: Sensor (documentation, issues)
First occurred: 10:11:32 PM (2 occurrences)
Last logged: 10:11:32 PM

Error adding entities for domain sensor with platform spacex
Error while setting up spacex platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/config/custom_components/spacex/sensor.py", line 467, in state
    self._state = launch_data["mission_name"]
KeyError: 'mission_name'

Logger: homeassistant.components.binary_sensor
Source: custom_components/spacex/binary_sensor.py:144
Integration: Binary sensor (documentation, issues)
First occurred: 10:11:32 PM (2 occurrences)
Last logged: 10:11:32 PM

Error adding entities for domain binary_sensor with platform spacex
Error while setting up spacex platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 158, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/config/custom_components/spacex/binary_sensor.py", line 144, in is_on
    if launch_data["is_tentative"] is True:
KeyError: 'is_tentative'
djtimca commented 4 years ago

Appears that the SpaceXData API is currently down which is resulting in these errors. I can try to release a patch at some point that will fail more gracefully, but until they fix the issues it will continue to not work. As an alternative you can try my RocketLaunch.Live sensor at https://github.com/djtimca/harocketlaunchlive which will also give you the SpaceX launches.

thijsdejong commented 4 years ago

Appears that the SpaceXData API is currently down which is resulting in these errors. I can try to release a patch at some point that will fail more gracefully, but until they fix the issues it will continue to not work. As an alternative you can try my RocketLaunch.Live sensor at https://github.com/djtimca/harocketlaunchlive which will also give you the SpaceX launches.

I think it would be a good idea to move away from the deprecated v3 api onto the v4 api.

djtimca commented 4 years ago

Thanks @thijsdejong - the documentation on the API is still stuck at v3... had to muddle through queries to get structure etc. so there might still be some issues come up, but latest will now be working in HA (for now).

basdejong95 commented 4 years ago

@djtimca thank you for the effort! Working great again!

thijsdejong commented 4 years ago

@djtimca Perhaps this is useful to you: https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/README.md . Taken from https://github.com/r-spacex/SpaceX-API