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: 'price' #18

Open
Jopand opened this issue May 9, 2023 · 2 comments
Open

KeyError: 'price' #18

Jopand opened this issue May 9, 2023 · 2 comments

Comments

@Jopand
Copy link

Jopand commented May 9, 2023

In HA 2023.5.2 I get the following errors in the log (sensors are not updated):

First occurred: 8. maj 2023 kl. 13.29.09 (32 occurrences)
Last logged: 21.44.45

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 204, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 349, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 146, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
if (state := self.state) is None:
File "/config/custom_components/fuelprices_dk/sensor.py", line 91, in state
return float(self._fuelCompany.getProductPrice(self._productKey))
File "/config/custom_components/fuelprices_dk/fuelprices_dk_api.py", line 215, in getProductPrice
return self._products[productKey]["price"]
KeyError: 'price'

@pawjensen
Copy link

for me it is the CircleK sensor that are not updating

Logger: homeassistant.components.sensor
Source: custom_components/fuelprices_dk/fuelprices_dk_api.py:215
Integration: Sensor (documentation, issues)
First occurred: 14:21:22 (2 occurrences)
Last logged: 14:21:22

Error adding entities for domain sensor with platform fuelprices_dk
Error while setting up fuelprices_dk platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 846, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/fuelprices_dk/sensor.py", line 91, in state
    return float(self._fuelCompany.getProductPrice(self._productKey))
  File "/config/custom_components/fuelprices_dk/fuelprices_dk_api.py", line 215, in getProductPrice
    return self._products[productKey]["price"]
KeyError: 'price'

@pawjensen
Copy link

The fuel name has change at circleK, add a "." after the name and it is working

FUEL_COMPANIES = {
    "circlek": {
        "name": "Circle K",
        "url": "https://www.circlek.dk/priser",
        "products": {
            OCTANE_95: {"name": "miles95."},
            OCTANE_95_PLUS: {"name": "milesPLUS95."},
            DIESEL: {"name": "miles Diesel B7."},
            DIESEL_PLUS: {"name": "milesPLUS Diesel."},
            ELECTRIC: {"name": "El Lynlader."},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants