core: Error fetching co2signal data
The problem
Every hour, I’m getting an Error fetching co2signal data in my logs. However, data seems to populate, except once an hour when the call fails.

What is version of Home Assistant Core has the issue?
core-2021.8.0
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
co2signal
Link to integration documentation on our website
https://www.home-assistant.io/integrations/co2signal/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2021-08-04 16:18:49 ERROR (SyncWorker_7) [homeassistant.components.co2signal] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/co2signal/__init__.py", line 119, in get_data
data = CO2Signal.get_latest(
File "/usr/local/lib/python3.9/site-packages/CO2Signal/co2signal.py", line 34, in get_latest
latest_data = (requests
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
--- snip ---
2021-08-04 17:18:49 ERROR (SyncWorker_1) [homeassistant.components.co2signal] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/co2signal/__init__.py", line 119, in get_data
data = CO2Signal.get_latest(
File "/usr/local/lib/python3.9/site-packages/CO2Signal/co2signal.py", line 34, in get_latest
latest_data = (requests
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2021-08-04 17:18:49 ERROR (MainThread) [homeassistant.components.co2signal] Error fetching co2signal data:
Additional information
Since this is configured from the new energy component, I’m not sure how to gather more information to help, sorry.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 32 (7 by maintainers)
Hi! Product Manager at electricityMap (and CO2 signal) here.
We’re currently experiencing a large influx of CO2signal beta-users, which has interfered with the activation of new tokens and the performance of the API. We’re currently investigating this issue - I’ll make an update on this issue when we know more!
Hello again,
We believe we have a fix now.
It seems that the root issue was the memory, so we’ve tried to increase it quite a bit, and currently, the checks are looking promising. Let’s hope this resolves it!
Hi all,
Thanks for highlighting some of these issues. We are aware that they are issues with the CO2 Signal API especially in terms of error handling and the overall UX of the service. I’m seeing a lot of issues due to using lat/lon and not being able to find the right country codes. Several users have also reached out to us regarding this, and have unfortunately spent a long time on setup even though we do not have data for the zone yet.
I’m wondering whether we should open a new issue around potentially adding functionality into home assistant to test whether there is actually real-time data for the zone the user is trying to get data from? That way we’ll be able to potentially save a lot of people from troubleshooting. I’d be happy to help however I can.
In the short term, for the people in this thread, and I am not quite sure how this integration is set up, I think the easiest solution is to find the relevant country codes by looking at our live map on electricitymap.org in case the lat/lon is having issues.
Specifically for the US, as I see a lot of comments about that. We do have data for all of the US, but most of the data is delayed by up to 24 hours which does indeed mean that the CO2 Signal API won’t work for most of the grids colored grey. Unfortunately, there’s not much for us to do except hope that the data providers will allow for real-time data in the future.
The team is really excited about your interest in the API. We’re a fairly small team and are not able to dedicate as much time as we want to on this, but hopefully, we can integrate some of the feedback we’ve received to make it a bit more stable and easier to use.
Same here, new setup of the integration -> unexpected error
I just got my API key and tried to set up the co2 sensor myself. I am getting
Unexpected erroron the config flow dialogue. I get this error when theUse home locationoption is selected.When i take a look at the logs, I see this as the culprit:
This is a distinct/different stack trace from the one @andriej posted. I am more than happy to open a new issue if it turns out that the two stack traces are not related.
EDIT I tried again with manually supplying the lat/lon and got a different error:
Which seemed suspicious… so i tried do do things manually:
So they may be having some issues w/ their API endpoint
That did the trick for me. Instead of using my home location i used a country code and it worked
On Fri, Aug 6, 2021, 23:27 Simone Chemelli @.***> wrote:
Here the list of available zones: http://api.electricitymap.org/v3/zones
Simone
Thanks for confirming, @Kongkille . I suspected that the HA launch would be the ‘hug of death’.
I am still not able to add the integration successfully, though. I’ll try again in a few days.
It looks like two things need to happen:
For me it’s back online since a couple of minutes 👍