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

KeyError when fetching pricing (sometimes) #6

Open
boralyl opened this issue Nov 4, 2020 · 1 comment
Open

KeyError when fetching pricing (sometimes) #6

boralyl opened this issue Nov 4, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@boralyl
Copy link
Owner

boralyl commented Nov 4, 2020

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to logs and see error (note the component still seems to work):
Logger: homeassistant.helpers.entity
Source: custom_components/steam_wishlist/entities.py:111
First occurred: November 3, 2020, 3:30:03 PM (1 occurrences)
Last logged: November 3, 2020, 3:30:03 PM
Update for sensor.steam_wishlist fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/steam_wishlist/entities.py", line 80, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 126, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 73, in async_call
    await self.hass.async_add_hass_job(self._job)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  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/steam_wishlist/entities.py", line 137, in state
    return self.is_on
  File "/config/custom_components/steam_wishlist/entities.py", line 111, in is_on
    pricing = self.coordinator.data[self.game["steam_id"]]
KeyError: '274520'

Home Assistant Version: 0.117.2

Custom Component Version: Latest

@boralyl boralyl added the bug Something isn't working label Nov 4, 2020
@boralyl
Copy link
Owner Author

boralyl commented Nov 11, 2020

This also popped up when I changed line 111 above to catch the KeyError and return False. It just bubbled up in the device_state_attributes propery.

Logger: homeassistant.helpers.entity
Source: custom_components/steam_wishlist/entities.py:148
First occurred: 3:18:58 PM (1 occurrences)
Last logged: 3:18:58 PM
Update for sensor.steam_wishlist fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/steam_wishlist/entities.py", line 80, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 126, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 73, in async_call
    await self.hass.async_add_hass_job(self._job)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  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 323, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/config/custom_components/steam_wishlist/entities.py", line 148, in device_state_attributes
    self.game["steam_id"], self.coordinator.data[self.game["steam_id"]]
KeyError: ''

This game does exist as a sensor and is in my config (Darkwood) so may need to add some better logging to figure out what's going on.

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

1 participant