home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.83k stars 30.91k forks source link

Update for sensor.seventeentrack_package_*** fails for archived packages #24597

Closed Spirituss closed 5 years ago

Spirituss commented 5 years ago

Home Assistant release with the issue:

Home Assistant 0.94.3

Last working Home Assistant release (if known): None

Operating environment (Hass.io/Docker/Windows/etc.):

Raspberry Pi, Raspbian Stretch

Component/platform:

https://www.home-assistant.io/components/seventeentrack/

Description of problem: In case you marked any package in 17track app as archived, it still stays on Home Assistant entity registry and repeating error with sensor update takes place in log file.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

sensor:
  - platform: seventeentrack 
    username: !secret 17track_username
    password: !secret 17track_password   

Traceback (if applicable):

2019-06-18 02:10:37 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.seventeentrack_package_raspberry_power_49 fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/seventeentrack/sensor.py", line 225, in async_update
    p for p in self._data.packages
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 375, in async_device_update
    await self.async_update()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/seventeentrack/sensor.py", line 233, in async_update
    self.hass.async_create_task(reg.async_remove(self.entity_id))
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_registry.py", line 165, in async_remove
    self.entities.pop(entity_id)
KeyError: 'sensor.seventeentrack_package_raspberry_power_49'

Entity registry: Screen Shot 2019-06-18 at 13 47 18

Additional information: Steps to reproduce:

  1. Package added to 17track app.
  2. Package delivered to address.
  3. Package marked as Archived in 17track app.
ghost commented 5 years ago

Hey there @bachya, mind taking a look at this issue as its been labeled with a integration (seventeentrack) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

Spirituss commented 5 years ago

I close this issue since it stops repeating in HA 0.96 but new similar issue has blown up, see https://github.com/home-assistant/home-assistant/issues/25555.