Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in icon intensity = INTENSITY[index] KeyError: 'very high' #7

Open
dr-harper opened this issue Nov 22, 2021 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@dr-harper
Copy link

I was running into an error with this plugin when the carbon intensity of the grid was "very high".

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 522, in _async_add_entity
    original_icon=entity.icon,
  File "/config/custom_components/carbon_intensity_uk/sensor.py", line 38, in icon
    intensity = INTENSITY[index]
KeyError: 'very high'

I managed to get this working again by changing the const.py file to include versions of the values without the underscore:

INTENSITY = {
    "very_low" : 0,
    "very low" : 0,
    "low" : 1,
    "moderate": 2,
    "high": 3,
    "very_high": 4,
    "very high": 4,
}

I haven't properly tested this but it seems to be working. It might be possible to delete the very_low and very_high values.

@jscruz jscruz added the bug Something isn't working label Nov 28, 2021
@jscruz jscruz added this to the 0.0.4 milestone Nov 28, 2021
@jscruz
Copy link
Owner

jscruz commented Nov 28, 2021

Thanks @dr-harper, I'll fix this issue in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants