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.9k stars 30.97k forks source link

SwitchBot KeyError #57471

Closed ripburger closed 3 years ago

ripburger commented 3 years ago

The problem

Previous UTF-8 error is resolved (thx!), but now I am getting this KeyError:

Error setting up entry Garage Door Opener for switchbot Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/switchbot/init.py", line 83, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 156, in async_config_entry_first_refresh await self._async_refresh(log_failures=False, raise_on_auth_failed=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 456, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 489, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 462, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 273, in state value = self.native_value File "/usr/src/homeassistant/homeassistant/components/switchbot/sensor.py", line 93, in native_value return self.data["data"][self._sensor] File "/usr/src/homeassistant/homeassistant/components/switchbot/entity.py", line 41, in data return self.coordinator.data[self._idx] KeyError: 'fd8fb77b2006'

What is version of Home Assistant Core has the issue?

2021.10.3

What was the last working version of Home Assistant Core?

2021.9

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SwitchBot

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

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

Hey there @danielhiversen, @renierm26, mind taking a look at this issue as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


switchbot documentation switchbot source (message by IssueLinks)

RenierM26 commented 3 years ago

Hi @ripburger,

This generally happens when scanning for btle advertisements doesn't return the specific device. (Usually due to signal strength or interference)

You could try to increase the scan time and allow the device more time to respond to the scan.

image

RenierM26 commented 3 years ago

You can find this under entry options.