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.43k stars 30.66k forks source link

[superpetcare] Integration fails when cat status is unknown #51408

Closed thewishy closed 3 years ago

thewishy commented 3 years ago

The problem

On initial setup of a Sure catflap, your cats do not necessarily have have an in / out status. (Effectively, it can be null)

I believe this was the cause of the integration failing to load with KeyError: 'status'.

Workaround: Make sure all cats have a location, this can be done manually via the Sure website. I'm guessing this will be a pain to repro, unfortunately I didn't dump any data while my account was in this state.

What is version of Home Assistant Core has the issue?

core-2021.5.5

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

superpetcare

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Jun 02 16:21:32 nandi hass[3088]: 2021-06-02 16:21:32 ERROR (MainThread) [homeassistant.setup] Error during setup of component surepetcare
Jun 02 16:21:32 nandi hass[3088]: Traceback (most recent call last):
Jun 02 16:21:32 nandi hass[3088]:   File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 248, in _async_setup_component
Jun 02 16:21:32 nandi hass[3088]:     result = await task
Jun 02 16:21:32 nandi hass[3088]:   File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/surepetcare/__init__.py", line 88, in async_setup
Jun 02 16:21:32 nandi hass[3088]:     await spc.async_update()
Jun 02 16:21:32 nandi hass[3088]:   File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/surepetcare/__init__.py", line 150, in async_update
Jun 02 16:21:32 nandi hass[3088]:     self.states = await self.surepy.get_entities()
Jun 02 16:21:32 nandi hass[3088]:   File "/srv/homeassistant/lib/python3.8/site-packages/surepy/__init__.py", line 253, in get_entities
Jun 02 16:21:32 nandi hass[3088]:     surepy_entities[entity_id] = Pet(data=entity)
Jun 02 16:21:32 nandi hass[3088]:   File "/srv/homeassistant/lib/python3.8/site-packages/surepy/entities/pet.py", line 37, in __init__
Jun 02 16:21:32 nandi hass[3088]:     self.state = PetState(data["status"])
Jun 02 16:21:32 nandi hass[3088]: KeyError: 'status'


### Additional information

_No response_
probot-home-assistant[bot] commented 3 years ago

Hey there @benleb, mind taking a look at this issue as its been labeled with an integration (surepetcare) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

Danielhiversen commented 3 years ago

Duplicate of https://github.com/home-assistant/core/issues/50150 Will be fixed when a new version https://github.com/benleb/surepy is available https://github.com/benleb/surepy/blob/master/surepy/entities/pet.py#L48