Commit Graph

134 Commits (7cd4f787678b76bd0bc6c360321ed45a655dd2b5)

Author SHA1 Message Date
Erik Montnemery 114e254aa6
Don't raise when registering entity service with invalid schema (#125057)
* Don't raise when registering entity service with invalid schema

* Update homeassistant/helpers/service.py

Co-authored-by: Robert Resch <robert@resch.dev>

---------

Co-authored-by: Robert Resch <robert@resch.dev>
2024-09-02 14:20:50 +02:00
Erik Montnemery 55c42fde88
Improve validation of entity service schemas (#124102)
* Improve validation of entity service schemas

* Update tests/helpers/test_entity_platform.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-08-27 19:05:49 +02:00
epenet 56b4a7f291
Add missing hass type in tests/helpers (#124039) 2024-08-16 17:09:12 +02:00
Erik Montnemery 14a3217d7e
Improve entity platform tests (#124051) 2024-08-16 15:08:37 +02:00
Erik Montnemery f9ade788eb
Do sanity check EntityPlatform.async_register_entity_service schema (#123058)
* Do a sanity check of schema passed to EntityPlatform.async_register_entity_service

* Only attempt to check schema of Schema

* Handle All/Any wrapped in schema

* Clarify comment

* Apply suggestions from code review

Co-authored-by: Robert Resch <robert@resch.dev>

---------

Co-authored-by: Robert Resch <robert@resch.dev>
2024-08-16 10:01:12 +02:00
Erik Montnemery 7063541733
Support None schema in EntityPlatform.async_register_entity_service (#123064) 2024-08-14 10:46:29 +02:00
Robert Resch 0d765a27c9
Add created_at/modified_at to entity registry (#122444) 2024-07-23 13:12:29 +02:00
Marc Mueller a6068dcdf2
Update import locations in tests (#122216) 2024-07-20 11:16:04 +02:00
Erik Montnemery 9bbeb5d608
Add primary_config_entry attribute to device registry entries (#119959)
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Robert Resch <robert@resch.dev>
2024-06-26 12:26:24 +02:00
epenet dc6c1f4e87
Add MockPlatform type hints in tests (#120012)
* Add MockPlatform type hints in tests

* Remove useless code

* Improve

* Revert "Improve"

This reverts commit 9ad04f9255.
2024-06-21 11:04:15 +02:00
Paulus Schoutsen eb89ce47ea
Inline primary integration (#119860) 2024-06-18 08:08:08 +02:00
Paulus Schoutsen 836abe68c7
Track primary integration (#119741)
* Track primary integration

* Update snapshots

* More snapshots updated

* Uno mas

* Update snapshot
2024-06-16 13:26:06 -04:00
epenet abb8c58b87
Fix consider-using-tuple pylint warnings in core tests (#119463) 2024-06-12 12:35:01 +02:00
epenet 7d631c28a6
Ignore attribute-defined-outside-init pylint warnings in tests (#119470) 2024-06-12 12:22:31 +02:00
Sid 721b2c2ca8
Enable Ruff PT012 (#113957) 2024-06-08 17:59:08 +02:00
J. Nick Koston d7aa24fa50
Only load translations for an integration once per test session (#117118) 2024-05-11 12:00:02 +09:00
J. Nick Koston b41b1bb998
Refactor entity_platform polling to avoid double time fetch (#116877)
* Refactor entity_platform polling to avoid double time fetch

Replace async_track_time_interval with loop.call_later
to avoid the useless time fetch every time the listener
fired since we always throw it away

* fix test
2024-05-05 16:28:01 -04:00
J. Nick Koston 6bd6adc4f5
Avoid calling valid_entity_id when adding entities if they are already registered (#115388) 2024-04-10 15:18:47 -10:00
J. Nick Koston 89a2c89fe2
Avoid checking for polling if an entity fails to add (#115159)
* Avoid checking for polling if an entity fails to add

* no need to do protected access

* no need to do protected access

* no need to do protected access

* no need to do protected access

* coverage

* fix test

* fix

* broken one must be first
2024-04-07 21:25:55 -04:00
Jan-Philipp Benecke 5c97049f2e
Do not override state property in `MockEntity` (#114231)
Do not override state in `MockEntity`
2024-03-27 11:36:00 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Sid 00ec7f11f0
Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
J. Nick Koston 65358c129a
Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
Marc Mueller a6b842f818
Add empty line after module docstring (2) [other] (#112738) 2024-03-08 19:16:38 +01:00
J. Nick Koston a6b17dbe68
Schedule polling as periodic tasks (#112640)
* Schedule periodic coordinator updates as background tasks.

Currently, the coordinator's periodic refreshes delay startup because they are not scheduled as background tasks. We will wait if the startup takes long enough for the first planned refresh. Another coordinator's scheduled refresh will be fired on busy systems, further delaying the startup. This chain of events results in the startup taking a long time and hitting the safety timeout because too many coordinators are refreshing.

This case can also happen with scheduled entity refreshes, but it's less common. A future PR will address that case.

* periodic_tasks

* periodic_tasks

* periodic_tasks

* merge

* merge

* merge

* merge

* merge

* fix test that call the sync api from async

* one more place

* cannot chain

* async_run_periodic_hass_job

* sun and pattern time changes from automations also block startup

* Revert "sun and pattern time changes from automations also block startup"

This reverts commit 6de2defa05.

* make sure polling is cancelled when config entry is unloaded

* Revert "Revert "sun and pattern time changes from automations also block startup""

This reverts commit e8f12aad55.

* remove DisabledError from homewizard test as it relies on a race

* fix race

* direct coverage
2024-03-07 23:32:26 -05:00
J. Nick Koston d9addc45f9
Avoid scheduling a task to add each entity when not using update_before_add (#110951)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-02-23 10:49:26 -10:00
J. Nick Koston dc4008c518
Avoid creating tasks to shutdown entity platforms (#111026)
* Avoid creating tasks to shutdown entity platforms

Nothing needed to be awaited here

* fix mocking

* missed one test
2024-02-20 21:10:25 -05:00
J. Nick Koston 09c609459d
Fix entity services targeting entities outside the platform when using areas/devices (#109810) 2024-02-06 12:41:57 -06:00
J. Nick Koston c399cab427
Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Erik Montnemery 84e74e4c74
Reverse component path (#104087)
* Reverse component path

* Update translations helper

* Fix

* Revert incorrect change of PLATFORM_FORMAT

* Fix use of PLATFORM_FORMAT in tts

* Fix ios
2023-12-05 08:43:58 +01:00
Erik Montnemery 4536fb3541
Remove mock_entity_platform test helper (#104073) 2023-11-16 16:55:08 +01:00
Franck Nijhof 70ad5ab3e4
Update helper tests to use device & entity registry fixtures (#103710) 2023-11-10 09:32:19 +01:00
Erik Montnemery 0ea0a1ed06
Prevent accidentally reusing an entity object (#102911)
* Prevent accidentally reusing an entity object

* Fix group reload service

* Revert "Fix group reload service"

* Improve test

* Add tests aserting entity can't be reused
2023-11-03 21:01:38 +01:00
Kevin Stillhammer 06c9719cd6
Support multiple responses for service calls (#96370)
* add supports_response to platform entity services

* support multiple entities in entity_service_call

* support legacy response format for service calls

* revert changes to script/shell_command

* add back test for multiple responses for legacy service

* remove SupportsResponse.ONLY_LEGACY

* Apply suggestion

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* test for entity_id remove None

* revert Apply suggestion

* return EntityServiceResponse from _handle_entity_call

* Use asyncio.gather

* EntityServiceResponse not Optional

* styling

---------

Co-authored-by: Allen Porter <allen.porter@gmail.com>
2023-11-02 18:37:35 -07:00
Erik Montnemery 97f3199d6d
Do not add entities with invalid device info (#98150) 2023-08-11 13:14:47 +02:00
Erik Montnemery c7b4d4f361
Adjust helpers tests which create devices (#98214) 2023-08-10 19:28:16 +02:00
Franck Nijhof 737ac8c600
Fix DeviceInfo configuration_url validation (#97319) 2023-07-27 18:57:01 +02:00
Erik Montnemery 614f3c6a15
Move device info validation to device registry (#96465)
* Move device info validation to device registry

* Don't move DeviceInfo

* Fix type annotation

* Don't block adding device for unknown config entry

* Fix test

* Remove use of locals()

* Improve error message
2023-07-14 08:55:17 -04:00
Erik Montnemery 7539cf25be
Don't require passing identifiers to DeviceRegistry.async_get_device (#96479)
* Require keyword arguments to DeviceRegistry.async_get_device

* Update tests

* Update tests

* Don't enforce keyword arguments
2023-07-13 13:39:25 -04:00
Paulus Schoutsen eee8566694
Differentiate between device info types (#95641)
* Differentiate between device info types

* Update allowed fields

* Update homeassistant/helpers/entity_platform.py

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

* Split up message in 2 lines

* Use dict for device info types

* Extract device info function and test error checking

* Simplify parsing device info

* move checks around

* Simplify more

* Move error checking around

* Fix order

* fallback config entry title to domain

* Remove fallback for name to config entry domain

* Ensure mocked configuration URLs are strings

* one more test case

* Apply suggestions from code review

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-07-10 09:56:06 -04:00
Erik Montnemery 86a397720f
Move platform_integration_no_support issue to the homeassistant integration (#95927)
* Move platform_integration_no_support issue to the homeassistant integration

* Update test

* Improve repair text

* Update test
2023-07-07 13:31:54 +02:00
Paulus Schoutsen 9280dc69ae
Default device name to config entry title (#95547)
* Default device name to config entry title

* Only apply name default if device info provided

* Fix logic detecting type of device info
2023-06-30 13:54:20 -04:00
Erik Montnemery 071d3a474f
Base entity ids on English for languages not using Latin script (#91357) 2023-06-27 14:37:50 +02:00
G Johansson c6feb30c31
Raise issue "does not support platform setup" (#93585)
* Raise issue on platform missing

* Modify issue

* Remove deprecation

* Fix strings

* Strings

* Last strings

* strings to common
2023-05-28 21:53:32 +02:00
J. Nick Koston 083cf7a38b
Fix refactoring error with updating polling entities in sequence (#93693)
* Fix refactoring error with updating in sequence

see #93649

* coverage

* make sure entities are being updated in parallel

* make sure entities are being updated in sequence
2023-05-28 16:20:48 +02:00
J. Nick Koston 3a1389c3b4
Switch some frequently called call_laters to call_at (#93659)
* Switch some frequently called call_laters to call_at

call_at is a bit faster than call_later since call_later
is a wrapper around call_at.

We call at lot of these at startup so it helps a bit when
we are resource constrained

* update test

* update test
2023-05-27 19:45:35 -04:00
epenet ab6e929443
Fix EntityComponent lingering timer in helper tests (#89801)
* Fix lingering timer in entity platform tests

* Tweak

* Fix entity and entity_component also

* Remove async_shutdown

* Adjust

* Adjust
2023-03-17 10:26:05 +01:00
epenet 46a5aa71ec
Add type hints to helper tests (#89784) 2023-03-16 11:10:56 +01:00
epenet 6febe00516
Fix lingering task in entity_platform test (#88957)
* Fix lingering task in entity_platform test

* Speed up the test
2023-03-01 10:49:13 +01:00
epenet 5f25b71df7
Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00