Commit Graph

259 Commits

Author SHA1 Message Date
Zach Berger ebbff7b60e
Add Awair Local API support (#75535) 2022-08-11 09:01:35 -04:00
Jc2k a0adfb9e62
Fix serialization of Xiaomi BLE reauth flow (#76095)
* Use data instead of context to fix serialisation bug

* Test change to async_start_reauth
2022-08-02 21:38:38 +01:00
Jc2k f043203b56
Add optional context parameter to async_start_reauth (#76077) 2022-08-02 18:20:37 +02:00
J. Nick Koston 80a9659524
Update to bleak 0.15 (#75941) 2022-07-29 17:53:33 -07:00
Marc Mueller d09fff595c
Rename existing TypeVars referencing Self type (#75473) 2022-07-20 03:03:22 +02:00
J. Nick Koston 32311f240b
Avoid converting discovery_info dataclasses to dict that will be thrown away in config flows (#75451)
* 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
```
2022-07-19 18:50:30 +02:00
J. Nick Koston fde3489e86
Relocate BluetoothServiceInfo to helpers.service_info (#75195) 2022-07-14 11:36:54 -07:00
J. Nick Koston 666f715e76
Avoid importing MQTT into core for ServiceInfo dataclass (#74418)
* Avoid importing MQTT into core for discovery dataclass

Likely fixes #73863

* relo

* adjust

* rename

* rename

* rename

* adjust missed imports

* drop compat

* fix conflict correctly

* Update homeassistant/helpers/config_entry_flow.py

* fix black from trying to fix the conflict in github
2022-07-14 11:09:09 -05:00
epenet 16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
J. Nick Koston cd03c49fc2
Wait for config entry platform forwards (#73806) 2022-07-09 17:27:42 +02:00
J. Nick Koston a697672944
Add bluetooth integration (#74653)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-07-08 18:55:31 -05:00
Erik Montnemery 00810235c9
Track tasks adding entities (#73828)
* Track tasks adding entities

* Update homeassistant/config_entries.py

* fix cast tests

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-29 09:38:35 +02:00
J. Nick Koston bb8b51eda3
Fix typos in ConfigEntryState.recoverable (#73449) 2022-06-13 10:56:08 -10:00
J. Nick Koston 7a422774b6
Prevent config entries from being reloaded while they are setting up (#73387) 2022-06-12 23:05:08 -07:00
epenet f91aa33c5f
Add FlowResultType enum to data entry flow (#72955) 2022-06-07 22:02:44 -07:00
J. Nick Koston 2e47cee72a
Fix setup race when config entry is in a setup retry state (#73145) 2022-06-06 22:48:49 -07:00
epenet 627d6f7803
Ensure description_placeholders is always typed (#72716) 2022-05-31 10:33:34 +02:00
J. Nick Koston f9bd384e6c
Stop waiting for setup retry upon discovery (#72738) 2022-05-30 20:24:34 -07:00
J. Nick Koston 4a5679db08
Prevent config entries from being reloaded concurrently (#72636)
* Prevent config entries being reloaded concurrently

- Fixes Config entry has already been setup when
  two places try to reload the config entry at the
  same time.

- This comes up quite a bit:
  https://github.com/home-assistant/core/issues?q=is%3Aissue+sort%3Aupdated-desc+%22Config+entry+has+already+been+setup%22+is%3Aclosed

* Make sure plex creates mocks in the event loop

* drop reload_lock, already inherits
2022-05-28 10:49:55 +02:00
Franck Nijhof 7d2deae592
Clean up use of deprecated async_get_registry methods (#72001) 2022-05-17 13:40:19 +02:00
Marc Mueller c1d2017988
Improve typing for core add_job and run_job methods (#70702) 2022-04-25 23:50:01 +02:00
Martin Hjelmare 09b4b7eb37
Remove hass.helpers from config_entries (#70660) 2022-04-25 14:21:03 +02:00
Ville Skyttä 05ddd773ff
Fix _abort_if_unique_id_configured updates type hint (#68730) 2022-03-29 09:24:15 +02:00
Marc Mueller 911b159281
Cleanup after pylint update (#68657) 2022-03-26 00:34:12 +01:00
Marc Mueller 53245c6523
Update pylint to 2.13.0 (#68656) 2022-03-25 15:14:48 -07:00
Marc Mueller ec980a574b
Improve typing [util.decorator] (#67087) 2022-02-23 20:58:42 +01:00
Erik Montnemery c496748125
Add WS API for removing a config entry from a device (#66188)
* 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
2022-02-21 10:11:18 +01:00
Marc Mueller 8d2fb72cc3
Add type ignore error codes [core] (#66773) 2022-02-17 23:09:22 -08:00
J. Nick Koston 0ec89ae5da
Teach _async_abort_entries_match about entry options (#66662) 2022-02-16 18:15:31 +01:00
Erik Montnemery 335a918118
Create MQTT discovery flow when manual config is present (#66248)
* Create MQTT discovery flow when manual config is present

* Change to integration_discovery flow

* Add test

* Add default handler for integration_discovery
2022-02-11 10:31:51 +01:00
Erik Montnemery f5fff95e8b
Tweak constant config_entries.DISCOVERY_SOURCES (#66249) 2022-02-10 11:12:38 +01:00
J. Nick Koston ff59f1ee51
Add INTEGRATION_DISCOVERY to DISCOVERY_SOURCES (#65811) 2022-02-05 10:36:04 -06:00
epenet 494ef2f9b2
Adjust config_entry UpdateListenerType signature (#65410)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-02 09:56:34 -08:00
Franck Nijhof 9e33a3014c
Automatically add entry title as name placeholder in reauth (#64078) 2022-01-18 14:18:16 -08:00
epenet 59c84f9586
Explicitly allow Mapping type hint in config entry async_update_entry (#63986)
* 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>
2022-01-14 04:06:19 +01:00
Marc Mueller 12757a8cd2
Update typing - collections.abc (1) (#63933)
* Update typing - collections.abc (1)

* Additional typing updates
2022-01-12 07:56:35 +01:00
Franck Nijhof f4aa18de31
Replace hass.helpers: async_call_later() (#63929) 2022-01-11 13:30:59 -08:00
Erik Montnemery 8d6e2ae354
Import persistent notification part 1 (#63898) 2022-01-11 17:24:59 +01:00
epenet 34a967c48a
Explicitely allow Platform enum in config_entries (#63581)
* Explicitely allow Platform enum in config_entries

* Undo argument name change and conversion to string

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-09 06:08:04 +01:00
Marc Mueller b0f72f59da
Use imports from `core` (#63458) 2022-01-05 14:55:38 +01:00
Tobias Sauerwein 2c904c0974
Bump mypy to 0.930 (#62642)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-12-27 17:55:17 +01:00
Ruslan Sayfutdinov 55f4962c06
Fix pylint plugin which checks relative imports (#62693) 2021-12-23 11:14:47 -08:00
Ville Skyttä 5bf67cac66
Use RegistryEntryDisabler (#60436) 2021-12-15 23:25:40 +02:00
Ville Skyttä 7db3246de4
Make config entry disabled_by an enum (#60445)
* Make config entry disabled_by an enum

* Update homeassistant/config_entries.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-12-15 20:53:21 +01:00
Marcel van der Veldt 7c7df5bb51
Change check for existence of options flow (#61147)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-12-07 12:50:34 -08:00
epenet b65b25c1bb
Move MqttServiceInfo to init.py (#60905)
Co-authored-by: epenet <epenet@users.noreply.github.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-12-03 19:34:48 +01:00
epenet 358922db56
Use dataclass for HassioServiceInfo (#60824)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-03 14:05:56 +01:00
epenet ec1c52d945
Use dataclass for SsdpServiceInfo (#59931)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-29 06:10:07 -10:00
epenet 75057949d1
Adjust async_step_discovery methods for BaseServiceInfo (#60285)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-24 19:30:02 -06:00
epenet 0dcfd55c84
Adjust async_step_usb signature for strict typing (#59773)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-16 19:03:50 +01:00