It has not been added yet to the default HACS repository. You can add a custom repository to your HACS pointing to https://github.com/djtimca/haspacex and then it should show up in your search.
How did I miss that. Iām an utter noob. My next issue is probably noob related but Iāve searched for an answer but not sure what is going on.
So I added the repository and when I go on integrations within HACS and HA itself, searching for SpaceX, nothing is found. Is this blatantly obvious what is going on? Thanks
I reinstalled and it appeared. My bad, newbie issues I guess. Thanks for the massive effort which has been put in here. Iāll install the entities and get back to you. Thanks
After some hours without problems I see those errors popup.
Maybe the data location is not reachable on SpaceX sideā¦
But still let you know these errors are there:
2020-09-05 02:03:28 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 36, in async_update_data
spacex_next_launch = await api.get_next_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 41, in get_next_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-05 02:05:02 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 36, in async_update_data
spacex_next_launch = await api.get_next_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 41, in get_next_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-05 02:05:13 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 36, in async_update_data
spacex_next_launch = await api.get_next_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 41, in get_next_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-05 02:05:28 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 36, in async_update_data
spacex_next_launch = await api.get_next_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 41, in get_next_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-05 02:07:03 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
That looks like the issue. That was actually what drove me nuts about just using a REST sensor because their data seems to regularly timeout. I will take a look and see if I canāt handle that more gracefully though.
If it is a timeout their sideā¦ hopefully all the rockets wonāt get a timeout when they launch themā¦ haha
Its ok for me to have theseā¦ at certain moment the info will be updated.
Pushed an update today that will hopefully solve those errors.
Even easier to install now - has been added to the HACS Default repository so you should just be able to search for SpaceX under integrations and it will be available for installation.
Lots of errors are gone now. I have some new errors to check:
2020-09-11 03:05:18 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 49, in async_update_data
spacex_latest_launch = await api.get_latest_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 59, in get_latest_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-11 03:22:32 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 43, in async_update_data
spacex_next_launch = await api.get_next_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 45, in get_next_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-09-11 03:30:26 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 37, in async_update_data
spacex_starman = await api.get_roadster_status()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 31, in get_roadster_status
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Thanks for watching the logs @poudenes! Looks like the API sometimes returns data but it isnāt valid. Iāve updated my API wrapper and added more graceful handling in the latest version (006) which is now available on HACS (you may need to Update Information on the integration to see it).
There will be a moment that you have alle the errors handling correct
Actually just pushed 007 as well - noticed I only caught this error for one of the API calls. Now handled for all.
Your last update (008) gives also some errors:
2020-09-16 08:15:28 ERROR (MainThread) [custom_components.spacex] Unexpected error fetching SpaceX data:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 66, in get_latest_launch
return json.loads(response)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/spacex/__init__.py", line 55, in async_update_data
spacex_latest_launch = await api.get_latest_launch()
File "/usr/local/lib/python3.8/site-packages/spacexpypi/__init__.py", line 68, in get_latest_launch
raise ValueError("Error decoding SpaceX Data (%s).", error)
ValueError: ('Error decoding SpaceX Data (%s).', JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
return await self.update_method()
File "/config/custom_components/spacex/__init__.py", line 61, in async_update_data
raise ConfigEntryNotReady
homeassistant.exceptions.ConfigEntryNotReady
Tim, thanks for your work on the integration. Love it!
This is working great for me.
I was able to convert the speed data for Starman to Mach with:
- platform: template
sensors:
starman_mach:
friendly_name: "Starman Speed"
unit_of_measurement: 'Mach'
value_template: "{{ states('sensor.spacex_starman_speed') | float / 1235 | round(0) }}"
icon_template: mdi:speedometer
Iām trying something similar with Distance to AU, but it seems the HA doesnāt like to divide by exponentials. The formula I have is velocity / 1.496e+8
, which if Iām using the previous template for speed, would be something like below. Oddly enough, the template test page gives the correct result, but when checking the config, it seems that HA doesnāt like the notiation.
starman_au:
friendly_name: "Starman Distance"
unit_of_measurement: 'AU'
value_template: "{{ states('sensor.spacex_starman_distance') | float / 1.496e+8 | round(0) }}"
icon_template: mdi:map-marker-distance
Any ideas how to get this to work?
Got it to work by removing the uppercase AU
from the sensor name. Formatted correctly in above examples.
Iāll add this as a new feature in a coming releaseā¦ easier to have it as attributes on the sensor I would think! Thanks for the formulas!
Just pushed version 010 which includes an attribute for machspeed on the Starman Speed sensor and au_distance on the Starman Distance sensor.
Version 012 is now up which includes new sensors for next_confirmed_launch_date and next_confirmed_launch_time which will only populate once a launch has been confirmed. This will give you a simpler way to display only confirmed information. This version also includes a significant rewrite to take advantage of version 0.115 and the data update coordinator and adds devices to the integration to simplify adding them to Lovelace. (Note that means that this integration now requires version 0.115 minimum.
Enjoy!
Hi Tim,
Iāve just installed your SpaceX integration today and love it. Exactly what I was looking for as my son loves watching the launches live on YouTube. Iām just wondering what timezone the launch times are in though and if there is a way to adjust them?
For example, Iām in the UK and todayās (28/09/2020) launch time is showing on HA as 1.22pm. I believe the actual launch time is 10:22 a.m. EDT which should be 14:22 GMT or 15:22 local time for us Brits (because weāre still in British Summer Time)
Thank you for sharing your fantastic integration.