core: ElectricityMaps Co2Signal integration stopped working

The problem

ElectricityMaps Co2Signal integration stopped working.

It seems like the endpoint https://api-access.electricitymaps.com/free-tier/home-assistant used by this integration is no longer available (see logs below).

Free HA API access is still being provided by ElectricityMaps, but probably the endpoint changed: https://api-portal.electricitymaps.com/ https://static.electricitymaps.com/api/docs/index.html

What version of Home Assistant Core has the issue?

core-2024.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

co2signal

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-01-31 19:07:19.487 DEBUG (MainThread) [aioelectricitymaps.electricitymaps] Doing request: GET https://api-access.electricitymaps.com/free-tier/home-assistant {'zone': 'IT-NO'}
2024-01-31 19:07:19.601 DEBUG (MainThread) [aioelectricitymaps.electricitymaps] Got response with status 404 and body: {"message":"no Route matched with those values"}
2024-01-31 19:07:19.601 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/root/homeassistant/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/auth.py", line 233, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 320, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 416, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/co2signal/config_flow.py", line 120, in async_step_country
    return await self._validate_and_create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/co2signal/config_flow.py", line 148, in _validate_and_create
    await fetch_latest_carbon_intensity(self.hass, em, data)
  File "/root/homeassistant/lib/python3.11/site-packages/homeassistant/components/co2signal/helpers.py", line 19, in fetch_latest_carbon_intensity
    return await em.latest_carbon_intensity_by_country_code(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/aioelectricitymaps/decorators.py", line 11, in inner
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/aioelectricitymaps/electricitymaps.py", line 112, in latest_carbon_intensity_by_country_code
    return CarbonIntensityResponse.from_dict(result)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/dataclasses_json/api.py", line 70, in from_dict
    return _decode_dataclass(cls, kvs, infer_missing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/homeassistant/lib/python3.11/site-packages/dataclasses_json/core.py", line 172, in _decode_dataclass
    field_value = kvs[field.name]
                  ~~~^^^^^^^^^^^^
KeyError: 'status'

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 24 (11 by maintainers)

Most upvoted comments

Working for me as well. Will close this issue.

A fix has been deployed with the help of @madsnedergaard. If you guys could confirm it’s working for you as well that would be much appreciated. It might require a DNS flush on your devices though.

Working for me. Thanks

Seems okay for me

Thanks to @VIKTORVAV99 from EM, this should, hopefully, be solved in a couple of minutes 😃

Did you configured the integration to use your home location or a country code?

tbh, no idea. Any way to check?

I have however created a new service using home location - and it works fine… I’ve also created a new service using country code (AU) - that works fine too.

my point was more your suggestion of using CloudFlare DNS (Which is one of the resolvers I do use) - it returns exactly the same results as Google and my ISP provided resolver.

Regardless, it doesn’t seem the fix by @madsnedergaard is working everywhere. And he asked for feedback.

That is strange indeed, but thanks for reporting it. Let’s see if it still occurs after 2024.2 release 😃

It is not the HA update, we (Electricity Maps) are having a small issue related to a API migration.

Besides, with 2024.2 there will be a update of the endpoint