* Avoid converting BluetoothServiceInfo to a dict for default discovery
Fixes
```
2022-07-19 09:46:48.303 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/helpers/discovery_flow.py", line 74, in _async_process_pending_flows
await gather_with_concurrency(
File "/Users/bdraco/home-assistant/homeassistant/util/async_.py", line 201, in gather_with_concurrency
return await gather(
File "/Users/bdraco/home-assistant/homeassistant/util/async_.py", line 199, in sem_task
return await task
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 222, in async_init
flow, result = await task
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 249, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1484, in async_step_bluetooth
return await self.async_step_discovery(dataclasses.asdict(discovery_info))
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1239, in asdict
return _asdict_inner(obj, dict_factory)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1246, in _asdict_inner
value = _asdict_inner(getattr(obj, f.name), dict_factory)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1280, in _asdict_inner
return copy.deepcopy(obj)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 271, in _reconstruct
state = deepcopy(state, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 231, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: Cannot pickle Objective-C objects
```
* Avoid converting BluetoothServiceInfo to a dict for default discovery
Fixes
```
2022-07-19 09:46:48.303 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/helpers/discovery_flow.py", line 74, in _async_process_pending_flows
await gather_with_concurrency(
File "/Users/bdraco/home-assistant/homeassistant/util/async_.py", line 201, in gather_with_concurrency
return await gather(
File "/Users/bdraco/home-assistant/homeassistant/util/async_.py", line 199, in sem_task
return await task
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 222, in async_init
flow, result = await task
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 249, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1484, in async_step_bluetooth
return await self.async_step_discovery(dataclasses.asdict(discovery_info))
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1239, in asdict
return _asdict_inner(obj, dict_factory)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1246, in _asdict_inner
value = _asdict_inner(getattr(obj, f.name), dict_factory)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dataclasses.py", line 1280, in _asdict_inner
return copy.deepcopy(obj)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 271, in _reconstruct
state = deepcopy(state, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 231, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: Cannot pickle Objective-C objects
```
* Add WS API for removing a config entry from a device
* Address review comments
* Address review comments
* Remove entity cleanup from ConfigEntries
* Update + add tests
* Improve comments in test
* Add negative test
* Refactor according to review comments
* Add back async_remove_config_entry_device
* Remove unnecessary error handling
* Simplify error handling
* Create MQTT discovery flow when manual config is present
* Change to integration_discovery flow
* Add test
* Add default handler for integration_discovery
* Allow MappingProxyType in async_update_entry
* Add setup type hints to ps4
* Adjust type hint to Mapping
Co-authored-by: epenet <epenet@users.noreply.github.com>
* Explicitely allow Platform enum in config_entries
* Undo argument name change and conversion to string
Co-authored-by: epenet <epenet@users.noreply.github.com>
- If a config flow set a unique id and then did an await to
return control to the event loop, another discovery with
the same unique id could start and it would not see
the first one because it was still uninitialized. We now
check uninitialized flows when setting the unique id
* Change config entry state to an enum
* Allow but deprecate EntryState str equality comparison
* Test fixes
* Rename to ConfigEntryState
* Remove str comparability backcompat
* Update new occurrences of strs cropped up during review
config_entries.async_setup will skip ignored and disabled integrations
but bootstrap would still load them in memory even though they would
never be setup.
If we pass a string to ConfigEntryNotReady or raise it from
another exception we now log the string passed or the
string generated by the original exception.
With #47201 this makes it easy for developers to still show
the reason why setup failed without having to worry about log
spam from additional attempts by rasing ConfigEntryNotReady
from the original exception.
* Unused pylint suppression cleanups
* Remove outdated pylint bug references
* Add flake8-noqa config and note to run it every now and then
* Add codes to noqa's
* Unused noqa cleanups
* Extend WS API result when enabling an entity
* Fix tests
* Fix tests
* Move updated registry entry to sub dict
* Address review comments
* Increase test coverage
* add persistent notification for reauth config flow
* remove log
* Update homeassistant/config_entries.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update homeassistant/config_entries.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* fix logic for determining when to dismiss notification
* add comment
* improve tests to ensure notifications only get dismissed when all in progress config flows of a given type are complete
* Update homeassistant/config_entries.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* handle context is None when accessing source
* add guard to show_advanced_options
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Chris Talkington <chris@talkingtontech.com>
* Remove unnecessary exception re-wraps
* Preserve exception chains on re-raise
We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.
The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.
Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.
* Fix mistaken re-wrap in homematicip_cloud/hap.py
Missed the difference between HmipConnectionError and
HmipcConnectionError.
* Do not hide original error on plex new cert validation error
Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
* Add support for reload_on_update to _abort_if_unique_id_configured
async_update_entry now avoids firing update listeners and writing
the storage if there are no actual changes.
* Actually add the tests
* collapse branch
* Update homeassistant/config_entries.py
Co-authored-by: Franck Nijhof <git@frenck.dev>
* handle entries that lack the ability to reload
* reduce
* adjust konnected tests
* update axis tests
* fix blocking
* more mocking
* config flow tests outside of test_config_flow
* reduce
* volumio
* Update homeassistant/config_entries.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* set reload_on_update=False for integrations that implement self._abort_if_unique_id_configured(updates= and a reload listen
* get rid of copy
* revert test change
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Ensure a deleted intergration can be removed
* Update homeassistant/config_entries.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Don't expose flows that aren't initialised.
If a flow init does not return immediately then there is a window where our
behaviour is screwy:
* Can try to configure a flow that isn't ready
* Can show notifications for discoveries that might yet return an abort
This moves the flow discovery events and notifications to after the flow is
initialised and hides flows that don't have a cur_step from async_progress
* Fix tradfri test
* Black.
* Lint fixes
* Mechanism to rediscover a discovery that was ignored
* Add core config entry tests for new rediscover step
* Add tests for homekit_controller implementation of async_step_rediscover
* Rename rediscover to unignore
* Comment the new ignore/unignore mechanisms
* Add unique ID to config entries
* Unload existing entries with same unique ID if flow with unique ID is
finished
* Remove unused exception
* Fix typing
* silence pylint
* Fix tests
* Add unique ID to Hue
* Address typing comment
* Tweaks to comments
* lint
* Add and improve core and config_entries type hints
* Complete and improve config_entries type hints
* More entity registry type hints
* Complete helpers.event type hints
* Refactor the Somfy auth implementation
* Typing
* Migrate Somfy to OAuth2 flow helper
* Add tests
* Add more tests
* Fix tests
* Fix type error
* More tests
* Remove side effect from constructor
* implementation -> auth_implementation
* Make get_implementation async
* Minor cleanup + Allow picking implementations.
* Add support for extra authorize data