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

Device Discovery: Check if device is known before trying to connect (DRY) #969

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CloCkWeRX
Copy link

@CloCkWeRX CloCkWeRX commented Jul 24, 2022

Fixes #968

I'm unclear why the else-if condition exists with basically duplicate logic, so removed the first version in favour of the second

Testing locally by:

  • Remove device
  • Restart
  • Let it be discovered.

Regression test results

  • Removed specific device (bfa****gola)
  • config/integrations -> Download diagnostics -> confirmed device key not present in the data array.
  • Started device discovery (discovered ok)
    image

The device + entity are successfully added
(For some reason, I can't control it still, but I assume it is unrelated)

@CloCkWeRX CloCkWeRX changed the title In all scenarios, check if device is known and try to connect Device Discovery: Check if device is known before trying to connect (DRY) Jul 24, 2022
@CloCkWeRX CloCkWeRX marked this pull request as ready for review July 24, 2022 05:42
@palfrey
Copy link

palfrey commented Aug 12, 2023

Applied this manually locally, and it definitely gets rid of the exception, but still wondering about the actual underlying cause given I can't configure the device!

@sanyatuning
Copy link

I have the same problem when starting after a power loss.

  File "/config/custom_components/localtuya/__init__.py", line 142, in _device_discovered
    device = hass.data[DOMAIN][TUYA_DEVICES][device_id]
KeyError: 'bf****'

I think this will fix some errors like #1376

@rospogrigio pls review this

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

Successfully merging this pull request may close these issues.

Exception in callback _SelectorDatagramTransport._read_ready() - KeyError: (specific key)
3 participants