Commit Graph

285 Commits (c51e644203a0c93a791bc0d342d14a56728078fc)

Author SHA1 Message Date
Erik Montnemery cc5c8bf5e3
Make helpers.frame.report_usage work when called from any thread (#139836)
* Make helpers.frame.report_usage work when called from any thread

* Address review comments, update tests

* Add test

* Update test

* Update recorder test

* Update tests
2025-03-05 19:37:34 +01:00
Erik Montnemery cfaf18f942
Improve the mock_integration_frame test fixture (#139850)
* Improve the mock_integration_frame test fixture

* Update test
2025-03-05 18:42:34 +01:00
epenet 030a1460de
Log a warning when replacing existing config entry with same unique id (#130567)
* Log a warning when replacing existing config entry with same unique id

* Exclude mobile_app

* Ignore custom integrations

* Apply suggestions from code review

* Apply suggestions from code review

* Update config_entries.py

* Fix handler

* Adjust and add tests

* Apply suggestions from code review

* Apply suggestions from code review

* Update comment

* Update config_entries.py

* Apply suggestions from code review
2025-02-28 14:20:39 +01:00
Josef Zweck e59ec8f867
Add ability to get callback when a config entry state changes (#138943)
* Add entry_on_state_change_helper

* undo black

* remove unload

* no coro

* Add tests

* Don't accept coro

* Review feedback

* Add error test

* Make it callback type

* Make it callback type

* Removal test

* change type
2025-02-21 11:55:56 +01:00
Erik Montnemery e0795e6d07
Improve config entry state transitions when unloading and removing entries (#138522)
* Improve config entry state transitions when unloading and removing entries

* Update integrations which check for a single loaded entry

* Update tests checking state after unload fails

* Update homeassistant/config_entries.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-02-17 18:16:57 +01:00
Erik Montnemery efd7ddeb89
Improve tests of removing and unloading config entries (#138432)
* Improve tests of removing and unloading config entries

* Fix unnecessary coroutine
2025-02-14 13:06:07 +01:00
Erik Montnemery 6abf7b525a
Improve test coverage of config subentries and fix related issues (#138321)
Improve test coverage of config subentries
2025-02-11 21:46:56 +01:00
Erik Montnemery 77486b9306
Improve config_entries tests (#138274)
* Improve config_entries tests

* Drop unnecessary use of OrderedDict
2025-02-11 13:17:54 +01:00
Erik Montnemery 428cc1a951
Update signature of platforms' async_setup_entry in tests (#138271) 2025-02-11 13:17:39 +01:00
Erik Montnemery 4b34d1bbb5
Merge config subentry feature branch to dev (#136121)
* Reapply "Add support for subentries to config entries" (#133470) (#136061)

* Reapply "Add support for subentries to config entries" (#133470)

This reverts commit ecb3bf79f3.

* Update test snapshot

* Add config subentry support to device registry (#128157)

* Add config subentry support to device registry

* Apply suggestions from code review

* Update syrupy serializer

* Update snapshots

* Address review comments

* Allow a device to be connected to no or a single subentry of a config entry

* Update snapshots

* Revert "Allow a device to be connected to no or a single subentry of a config entry"

This reverts commit ec6f613151cb4a806b7961033c004b71b76510c2.

* Update test snapshots

* Bump release version in comments

* Rename config_subentries to config_entries_subentries

* Add config subentry support to entity registry (#128155)

* Add config subentry support to entity registry

* Update syrupy serializer

* Update snapshots

* Update snapshots

* Accept suggested changes

* Clean registries when removing subentry (#136671)

* Clean up registries when removing subentry

* Update tests

* Clean up subentries from deleted devices when removing config entry (#136669)

* Clean up subentries from deleted devices when removing config entry

* Move

* Add config subentry support to entity platform (#128161)

* Add config subentry support to entity platform

* Rename subentry_id to config_subentry_id

* Store subentry type in subentry (#136687)

* Add reconfigure support to config subentries (#133353)

* Add reconfigure support to config subentries

* Update test

* Minor adjustment

* Rename supported_subentry_flows to supported_subentry_types

* Address review comments

* Add subentry support to kitchen sink (#136755)

* Add subentry support to kitchen sink

* Add subentry reconfigure support to kitchen_sink

* Update kitchen_sink tests with subentry type stored in config entry

* Update kitchen_sink

* Update kitchen_sink

* Adjust kitchen sink tests

* Fix hassfest

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Improve docstrings and strings.json

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-02-10 16:40:07 +01:00
epenet 364556a7dd
Prefer from...import...as over import...as in core tests (#136146) 2025-01-21 09:28:17 +01:00
epenet 3342904330
Use new ServiceInfo location in core tests (#136067) 2025-01-20 14:04:58 +01:00
epenet 5df7092f41
Improve formatting in core files (#135256)
* Adjust core files formatting

* Adjust translations script
2025-01-10 09:08:37 +01:00
Erik Montnemery ecb3bf79f3
Revert "Add support for subentries to config entries" (#133470)
Revert "Add support for subentries to config entries (#117355)"

This reverts commit ad15786115.
2024-12-18 13:51:05 +01:00
Erik Montnemery ad15786115
Add support for subentries to config entries (#117355)
* Add support for subentries to config entries

* Improve error handling and test coverage

* Include subentry_id in subentry containers

* Auto-generate subentry_id and add optional unique_id

* Tweak

* Update tests

* Fix stale docstring

* Address review comments

* Typing tweaks

* Add methods to ConfigEntries to add and remove subentry

* Improve ConfigSubentryData typed dict

* Update test snapshots

* Adjust tests

* Fix unique_id logic

* Allow multiple subentries with None unique_id

* Add number of subentries to config entry JSON representation

* Add subentry translation support

* Allow integrations to implement multiple subentry flows

* Update translations schema

* Adjust exception text

* Change subentry flow init step to user

* Prevent creating a subentry with colliding unique_id

* Update tests

* Address review comments

* Remove duplicaetd unique_id collision check

* Remove change from the future

* Improve test coverage

* Add default value for unique_id
2024-12-12 20:16:18 +01:00
Sid 9e98e446a2
Bump ruff to 0.8.0 (#131273) 2024-11-22 16:53:26 +01:00
epenet 9add3a6c9b
Add ability to pass integration domain to report_usage (#130705)
* Add ability to pass integration domain to report_usage

* Adjust

* Fix

* Add tests

* Update test_frame.py

* Update test_frame.py

* Update test_frame.py

* Update test_frame.py

* Update test_frame.py

* Update test_frame.py

* Finish tests

* Docstring

* Replace logger warning with report_usage

* Improve

* docstring

* Improve tests

* Adjust docstring for exclude_integrations

* Fix behavior and improve tests
2024-11-21 16:01:36 +01:00
epenet deeb55ac50
Add ability to set HA breaking version in report_usage (#130858)
* Add ability to set breaking version in report_usage

* Adjust tests

* Adjust test

* Adjust tests

* Rename breaks_in_version => breaks_in_ha_version
2024-11-20 21:41:57 +01:00
epenet f1ce7ee8ce
Adjust logging for OptionsFlow deprecation (#130360) 2024-11-11 21:02:09 +01:00
epenet 353ccf3ea7
Only apply OptionsFlowWithConfigEntry deprecation to core (#130054)
* Only apply OptionsFlowWithConfigEntry deprecation to core

* Fix match string in pytest.raises

* Improve coverage
2024-11-08 15:55:19 +01:00
Erik Montnemery 536e686892
Don't create repairs asking user to remove duplicate flipr config entries (#130058)
* Don't create repairs asking user to remove duplicate flipr config entries

* Improve comments
2024-11-07 17:38:10 +01:00
Erik Montnemery c5e3ba536c
Don't create repairs asking user to remove duplicate ignored config entries (#130056) 2024-11-07 17:07:23 +01:00
epenet 03d5b18974
Remove options property from OptionFlow (#129890)
* Remove options property from OptionFlow

* Update test_config_entries.py

* Partial revert of "Remove deprecated property setters in option flows (#129773)"

* Partial revert "Use new helper properties in crownstone options flow (#129774)"

* Restore onewire init

* Restore onvif

* Restore roborock

* Use deepcopy in onewire

* Restore steam_online

* Restore initial options property in OptionsFlowWithConfigEntry

* re-add options property in SchemaOptionsFlowHandler

* Restore test

* Cleanup
2024-11-06 23:28:01 +01:00
Erik Montnemery 4ac35d40cd
Fix create flow logic for single config entry integrations (#129807)
* Fix create flow logic for single config entry integrations

* Adjust MQTT test
2024-11-04 15:45:29 +01:00
Erik Montnemery 4784199038
Fix aborting flows for single config entry integrations (#129805) 2024-11-04 13:59:10 +01:00
epenet 89eb395e2d
Add OptionsFlow helper for a mutable copy of the config entry options (#129718)
* Add OptionsFlow helper for a mutable copy of the config entry options

* Add tests

* Improve coverage

* error_if_core=False

* Adjust report

* Avoid mutli-line ternary
2024-11-03 20:37:58 +01:00
epenet ab5b9dbdc9
Add OptionsFlow helpers to get the current config entry (#129562)
* Add OptionsFlow helpers to get the current config entry

* Add tests

* Improve

* Add ValueError to indicate that the config entry is not available in `__init__` method

* Use a property

* Update config_entries.py

* Update config_entries.py

* Update config_entries.py

* Add a property setter for compatibility

* Add report

* Update config_flow.py

* Add tests

* Update test_config_entries.py
2024-11-01 12:54:35 +01:00
epenet b626c9b450
Ensure entry_id is set on reauth/reconfigure flows (#129319)
* Ensure entry_id is set on reauth/reconfigure flows

* Improve

* Improve

* Use report helper

* Adjust deprecation date

* Update config_entries.py

* Improve message and adjust tests

* Apply suggestions from code review

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

---------

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
2024-11-01 10:29:58 +01:00
epenet 696efe349e
Log type as well as value for unique_id checks (#129575) 2024-10-31 15:10:27 +01:00
G Johansson a4f210379d
Raise on non-string unique id for config entry (#125950)
* Raise on non-string unique id for config entry

* Add test update entry

* Fix breaking

* Add check get_entry_by_domain_and_unique_id

* Naming

* Add test

* Fix logic

* No unique id

* Fix tests

* Fixes

* Fix gardena

* Not related to this PR

* Update docstring and comment

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-10-30 18:09:50 +01:00
G Johansson 3db6d82904
Add name to description placeholders automatically for reauth flows (#129232)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-10-30 17:38:59 +01:00
Robert Resch 380974eed4
Remove hassio from ALLOWED_USED_COMPONENTS and move some functions to helper (#127228)
* Remove hassio from ALLOWED_USED_COMPONENTS

* Move HassioServiceInfo to helpers.service_info

* Deprecate moved functions

* Add note about deprecation

* Fix tests

* Implement suggestion

* Typo

* Update pyproject.toml

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-10-30 12:43:41 +01:00
Erik Montnemery da11a72b4c
Create repair asking user to remove duplicate config entries (#127948)
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-10-29 13:10:56 +01:00
epenet 350a27575f
Prevent leak of current_entry context variable (#128145) 2024-10-16 18:02:37 +02:00
epenet 99eb466223
Add updates argument to update_reload_and_abort helper (#127781)
* Add updates argument to update_reload_and_abort helper

* Also apply to airvisual_pro

* Rename argument

* docstring

* Use modern syntax

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestion

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestion

* Docstring

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-10-09 07:47:18 +02:00
epenet 5836a85340
Prevent `async_create_entry` from reauth/reconfigure flows (#127527)
* Prevent `async_create_entry` from reauth/reconfigure flows

* Adjust message

* Don't raise just yet

* Adjust message

* Fix string

* Remove invalid comment

* Add parameter

* Use count parameter

* Remove another branching
2024-10-08 15:19:58 +02:00
epenet 4e15556eeb
Cleanup unused variable in tests (#127930) 2024-10-08 15:14:23 +02:00
Erik Montnemery 0c0ff855b1
Warn when async_update_entry creates a unique_id collision (#127929) 2024-10-08 14:42:41 +02:00
epenet 4478f64002
Remove dead reconfigure code (#127398)
* Remove dead reconfigure code

* Adjust

* Start cleaning up test

* Prevent duplicate flows

* Add missing string

* Adjust two more tests

* Only filter out reauth flows

* Update strings.json

* Update config_entries.py

* Adjust tests

* Remove all checks - but add comment in tests

* Simplify PR
2024-10-08 13:35:04 +02:00
epenet 2c664efb3c
Add new helper for matching reauth/reconfigure config flows (#127565) 2024-10-08 10:07:36 +02:00
epenet 8c0e96e6e6
Extend update_entry_and_reload tests (#127776) 2024-10-07 11:23:48 +02:00
epenet c87a2ca335
Add default reconfigure reason in update_reload_and_abort (#127756)
* Add default reconfigure reason in async_update_reload_and_abort

* Simplify

* Fix test

* Add sample usage

* Remove multi-line ternary
2024-10-07 09:02:58 +02:00
Erik Montnemery 48a07d531c
Remove assumption in ConfigEntryItems about unique unique_id (#127399) 2024-10-03 22:27:15 +02:00
J. Nick Koston 0f29fd3e10
Switch to using fast cached_property implementation in propcache (#127339) 2024-10-03 13:11:02 -05:00
J. Nick Koston e2b1ef053f
Cache serialization of config entry storage (#127435) 2024-10-03 19:51:09 +02:00
epenet 7d3d693fe8
Align config flow reconfigure step test helper with frontend (#127329)
* Align config flow reconfigure step with frontend

* Update common.py

* Update common.py

* Adjust

* Adjust

* Fix test

* Adjust
2024-10-03 10:21:23 +02:00
epenet 21266e1c68
Add config_flow helper to get reauth/reconfigure config entry (#127115)
* Add config_flow helper to get config entry from context

* Simplify

* Apply to aussie_broadband

* Another example

* Rename and adjust docstring

* Simplify

* Add test

* Refactor to hide context

* Raise

* Improve coverage

* Use AttributeError

* Use ValueError

* Raise UnknownEntry
2024-10-02 12:00:07 +02:00
epenet b95dfe2b00
Add test helper for starting reconfiguration flow (#127154) 2024-10-01 12:18:07 +02:00
epenet 4bb768f39c
Add test for start_reauth_flow test helper (#127093)
* Improve docstring in start_reauth_flow

* Add test

* Make private

* Make fully private until actually needed
2024-09-30 14:28:13 +02:00
Erik Montnemery 3c0be47d3c
Add FlowManager.async_has_matching_flow (#126804)
* Add FlowManager.async_flow_has_matching_flow

* Revert changes from the future

* Apply suggested changes to apple_tv config flow

* Rename methods after discussion

* Update homeassistant/data_entry_flow.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Move deduplication functions to config_entries, add tests

* Adjust tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-27 10:51:36 +02:00