1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-14 20:41:24 +01:00
Commit Graph

155 Commits

Author SHA1 Message Date
Jan Bouwhuis 34d6938171 Fix subentry ID is not updated when renaming the entity ID (#157498) 2025-12-01 07:55:13 +01:00
Erik Montnemery dd399ef59f Refactor EntityPlatform (#147927) 2025-07-22 14:35:57 +02:00
Erik Montnemery 8ce30d9559 Add tests of legacy entity without platform writing state (#148109) 2025-07-04 16:21:48 +02:00
Erik Montnemery 943fb9948b Adjust logic related to entity platform state (#147882)
* Adjust logic related to entity platform state

* Break up hard to read if-statement

* Add and improve tests
2025-07-02 14:57:53 +02:00
G Johansson db3090078b Remove deprecated support feature values in camera (#146988) 2025-06-22 09:31:16 +02:00
Erik Montnemery e39edcc234 Remove unused attribute EntityInfo.custom_component (#146550) 2025-06-11 17:27:17 +02:00
Erik Montnemery d860b35f41 Fix flaky test test_async_parallel_updates_with_zero_on_sync_update (#143810) 2025-04-28 09:27:26 +02:00
J. Nick Koston 34d17ca458 Move state length validation to StateMachine APIs (#143681)
* Move state length validation to StateMachine async_set method

We call validate_state to make sure we do not allow any states
into the state machine that have a length>255 so we do not break
the recorder. Since async_set_internal already requires callers
to pre-validate the state, we can move the check to async_set
instead of at State object creation time to avoid needing to
check it twice in the hot path (entity write state)

* move check in async_set_internal so it only happens on state change

* no need to check if same_state
2025-04-25 21:15:15 -04:00
Erik Montnemery dc8e1773f1 Remove unused defaults from entity_registry.RegistryEntry (#143655) 2025-04-25 12:41:58 +02:00
J. Nick Koston cb0523660d Improve error logging when state is too long (#143636) 2025-04-24 18:37:32 -10:00
Erik Montnemery 428cc1a951 Update signature of platforms' async_setup_entry in tests (#138271) 2025-02-11 13:17:39 +01:00
Ville Skyttä 40eb8b91cc Adjust to recommended propcache.api import paths (#136150) 2025-01-21 10:58:22 +01:00
Franck Nijhof 00c052bb22 Revert "Remove deprecated supported features warning in ..." (multiple) (#134933) 2025-01-07 00:08:02 +01:00
epenet f2500e5a32 Remove deprecated supported features warning in MediaPlayer (#132365) 2024-12-09 23:03:55 +01:00
Erik Montnemery 0d447c9d50 Improve entity cached attributes (#128876) 2024-10-21 10:29:01 +02:00
J. Nick Koston 0f29fd3e10 Switch to using fast cached_property implementation in propcache (#127339) 2024-10-03 13:11:02 -05:00
epenet 56b4a7f291 Add missing hass type in tests/helpers (#124039) 2024-08-16 17:09:12 +02:00
Marc Mueller a6068dcdf2 Update import locations in tests (#122216) 2024-07-20 11:16:04 +02:00
epenet 648ef94888 Improve type hints in core helper tests (#120096) 2024-06-21 15:43:27 +02:00
epenet 9f41133bbc Add missing argument type to core tests (#119667) 2024-06-14 08:42:01 +02:00
epenet 38a6e666a7 Add missing return type to some test functions (#119665) 2024-06-14 08:26:45 +02:00
epenet 7d631c28a6 Ignore attribute-defined-outside-init pylint warnings in tests (#119470) 2024-06-12 12:22:31 +02:00
J. Nick Koston 62b1bde0e8 Only entity verify state writable once after success unless hass is missing (#118896) 2024-06-06 11:46:44 -05:00
J. Nick Koston 475c20d529 Always do thread safety check when writing state (#118886)
* Always do thread safety check when writing state

Refactor the 3 most common places where the thread safety check
for the event loop to be inline to make the check fast enough
that we can keep it long term. While code review catches most
of the thread safety issues in core, some of them still make
it through, and new ones keep getting added. Its not possible
to catch them all with manual code review, so its worth the
tiny overhead to check each time.

Previously the check was limited to custom components
because they were the most common source of thread
safety issues.

* Always do thread safety check when writing state

Refactor the 3 most common places where the thread safety check
for the event loop to be inline to make the check fast enough
that we can keep it long term. While code review catches most
of the thread safety issues in core, some of them still make
it through, and new ones keep getting added. Its not possible
to catch them all with manual code review, so its worth the
tiny overhead to check each time.

Previously the check was limited to custom components
because they were the most common source of thread
safety issues.

* async_fire is more common than expected with ccs

* fix mock

* fix hass mocking
2024-06-05 23:41:55 -04:00
J. Nick Koston 79b4889812 Always do thread safety checks when writing state for custom components (#116044) 2024-04-24 10:05:52 +02:00
J. Nick Koston 53a179088f Add debug mode to catch unsafe thread operations using core helpers (#115390)
* adjust

* adjust

* fixes

* one more

* test

* debug

* move to config

* cover

* Update homeassistant/core.py

* set debug from RuntimeConfig

* reduce

* fix message

* raise

* Update homeassistant/core.py

* Update homeassistant/core.py

* no flood check for raise

* cover
2024-04-24 03:36:05 +02:00
Sid 895f73d8e4 Enable Ruff A001 (#115654) 2024-04-21 23:25:27 +02:00
Alberto Montes c94b0a82ca Make release channel a hardcoded enum rather than a free form string (#115595)
* Make release channel a hardcoded enum rather than a free form string

* Update enum comparison to remove equality and us identity comparison

* Fix comparison condition to match the previous implementation

* Update tests to use Enum instead of string
2024-04-20 20:01:49 +02:00
Marc Mueller 816ce116bf Remove unnecessary functools.cached_property backport (#114239) 2024-04-04 11:24:26 +02: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
Joost Lekkerkerker 05172d8e4d Improve loops and lists (#113269)
* Enable PERF

* Enable PERF rule

* Enable PERF rule

* Don't enable flag yet
2024-03-14 10:22:20 +01:00
J. Nick Koston b7d9f26cee Cache the job type for entity service calls (#112793) 2024-03-08 22:49:08 -10:00
Marc Mueller a6b842f818 Add empty line after module docstring (2) [other] (#112738) 2024-03-08 19:16:38 +01: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 9c145b5faa Fix race in removing entities from the registry (#110978) 2024-02-20 20:48:31 -06:00
J. Nick Koston 454c62b5b4 Avoid total_seconds conversion every state write when context is set (#107617) 2024-01-13 21:04:32 -05:00
Erik Montnemery 9859306718 Prevent overriding cached attribute as property (#107657)
* Prevent overriding cached attribute as property

* Remove debug
2024-01-09 19:16:45 +01:00
Michael eb01998395 Add support for placeholders in entity name translations (#104453)
* add placeholder support to entity name translation

* add negativ tests

* make property also available via description

* fix doc string in translation_placeholders()

* fix detection of placeholder

* validate placeholders for localized strings

* add test

* Cache translation_placeholders property

* Make translation_placeholders uncondotionally return dict

* Fall back to unsubstituted name in case of mismatch

* Only replace failing translations with English

* Update snapshots

* Blow up on non stable releases

* Fix test

* Update entity.py

---------

Co-authored-by: Erik <erik@montnemery.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-01-03 17:34:47 +01:00
Erik Montnemery 599271fdc0 Don't use entity_id in __repr__ of not added entity (#106861) 2024-01-02 11:35:16 +01:00
Erik Montnemery c1f1b5c50b Ensure it's safe to call Entity.__repr__ on non added entity (#106032) 2023-12-31 18:54:34 +01:00
Erik Montnemery 56a58f9285 Improve tests of inheriting entity descriptions (#106647) 2023-12-29 13:22:52 +01:00
J. Nick Koston a46fe94216 Add helper to report deprecated entity supported features magic numbers (#106602) 2023-12-28 12:24:36 -10:00
Erik Montnemery 3a744d374b Add support for caching entity properties (#100601) 2023-12-22 09:02:55 -10:00
Erik Montnemery 0534b0dee4 Improve entity tests (#106175) 2023-12-21 15:32:25 +01:00
Erik Montnemery 9020dbb093 Remove context_recent_time property from entity base class (#105652) 2023-12-14 08:33:31 +01:00
Erik Montnemery dd5a48996a Keep capabilities up to date in the entity registry (#101748)
* Keep capabilities up to date in the entity registry

* Warn if entities update their capabilities very often

* Fix updating of device class

* Stop tracking capability updates once flooding is logged

* Only sync registry if state changed

* Improve test

* Revert "Only sync registry if state changed"

This reverts commit 1c52571596c06444df234d4b088242b494b630f2.

* Avoid calculating device class twice

* Address review comments

* Revert using dataclass

* Fix unintended revert

* Add helper method
2023-12-13 17:27:26 +01:00
Erik Montnemery 22c3847c0e Allow inheriting FrozenOrThawed with custom init (#105624) 2023-12-13 10:13:34 +01:00
Erik Montnemery 5bd0833f49 Improve FrozenOrThawed (#105541) 2023-12-12 21:19:41 +01:00
Erik Montnemery dd338799d4 Make it possible to inherit EntityDescription in frozen and mutable dataclasses (#105211) 2023-12-11 20:00:55 +01:00