Commit graph

118 commits

Author SHA1 Message Date
Erik Montnemery
9859306718
Prevent overriding cached attribute as property ()
* 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 ()
* 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 () 2024-01-02 11:35:16 +01:00
Erik Montnemery
c1f1b5c50b
Ensure it's safe to call Entity.__repr__ on non added entity () 2023-12-31 18:54:34 +01:00
Erik Montnemery
56a58f9285
Improve tests of inheriting entity descriptions () 2023-12-29 13:22:52 +01:00
J. Nick Koston
a46fe94216
Add helper to report deprecated entity supported features magic numbers () 2023-12-28 12:24:36 -10:00
Erik Montnemery
3a744d374b
Add support for caching entity properties () 2023-12-22 09:02:55 -10:00
Erik Montnemery
0534b0dee4
Improve entity tests () 2023-12-21 15:32:25 +01:00
Erik Montnemery
9020dbb093
Remove context_recent_time property from entity base class () 2023-12-14 08:33:31 +01:00
Erik Montnemery
dd5a48996a
Keep capabilities up to date in the entity registry ()
* 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 () 2023-12-13 10:13:34 +01:00
Erik Montnemery
5bd0833f49
Improve FrozenOrThawed () 2023-12-12 21:19:41 +01:00
Erik Montnemery
dd338799d4
Make it possible to inherit EntityDescription in frozen and mutable dataclasses () 2023-12-11 20:00:55 +01:00
Erik Montnemery
01b3e0c49e
Remove useless code from entity helper tests () 2023-11-12 18:55:34 +01:00
Erik Montnemery
d913508607
Allow removing an entity more than once () 2023-11-08 12:50:40 +01:00
Jan-Philipp Benecke
ae1117bc74
Fix failing entity reuse test ()
* Fix failing entity reuse test

* One more test
2023-11-03 23:19:37 +01:00
Erik Montnemery
0ea0a1ed06
Prevent accidentally reusing an entity object ()
* 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
J. Nick Koston
e5ebdf7ad4
Remove implict name check from Entity base class () 2023-10-15 23:40:43 +02:00
Nicolas van de Walle
1b11062b27
Improved debugging for "Failed to set state" () 2023-10-08 19:40:42 +02:00
Erik Montnemery
20188181f7
Fix spelling in sensor test () 2023-10-06 11:51:08 +02:00
Erik Montnemery
17779c5f0c
Add loader.async_suggest_report_issue and loader.async_get_issue_tracker ()
* Add loader.async_suggest_report_issue and loader.async_get_issue_tracker

* Update tests

* Add tests

* Address review comments

* Address review comments
2023-10-04 13:40:33 +02:00
Erik Montnemery
d1afcd773f
Revert "Cache entity properties that are never expected to change in the base class" ()
Revert "Cache entity properties that are never expected to change in the base class ()"

This reverts commit 042776ebb8.
2023-09-15 11:25:24 +02:00
J. Nick Koston
042776ebb8
Cache entity properties that are never expected to change in the base class () 2023-09-14 17:48:48 -05:00
Erik Montnemery
bbcbb2e322
Improve Entity._suggest_report_issue () 2023-09-12 21:07:32 +02:00
Erik Montnemery
51576b7214
Improve typing of entity.entity_sources ()
* Improve typing of entity.entity_sources

* Calculate entity info source when generating WS response

* Adjust typing

* Update tests
2023-09-12 20:41:26 +02:00
Erik Montnemery
709ce7e0af
Set state of entity with invalid state to unknown ()
* Set state of entity with invalid state to unknown

* Add test

* Apply suggestions from code review

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

* Update test_entity.py

---------

Co-authored-by: Robert Resch <robert@resch.dev>
2023-09-04 14:09:51 +02:00
Erik Montnemery
c7b4d4f361
Adjust helpers tests which create devices () 2023-08-10 19:28:16 +02:00
Erik Montnemery
614f3c6a15
Move device info validation to device registry ()
* 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
Jan Bouwhuis
b9c7e7c15e
Fix not including device_name in friendly name if it is None ()
* Omit device_name in friendly name if it is None

* Fix test
2023-07-06 11:14:09 -04:00
J. Nick Koston
9051750add
Cache entity translation lookups and keys () 2023-06-25 08:50:48 -05:00
Franck Nijhof
e2f5a707ce
Fix use_device_name in case device device class translations are used ()
Co-authored-by: Erik <erik@montnemery.com>
2023-06-22 11:30:19 +02:00
Erik Montnemery
334dacc322
Change Entity.name default to UNDEFINED ()
* Change Entity.name default to UNDEFINED

* Update typing

* Update Pylint plugin

* Update TTS test
2023-06-15 11:09:53 +02:00
Erik Montnemery
d51982f12f
Add missing assert to test_async_remove_ignores_in_flight_polling () 2023-06-12 21:48:12 +02:00
Erik Montnemery
59f5b8f2d6
Remove unneeded checks for Entity.platform ()
* Remove unneeded checks for Entity.platform

* Update tests

* Prevent breaking integrations without an EntityComponent

* Warn when entity has no platform
2023-06-09 15:17:41 +02:00
Erik Montnemery
59c6220b7c
Subscribe to device registry changes from entities ()
* Subscribe to device registry changes from entities

* Use async_track_device_registry_updated_event

* Fix unsubscribe

* Fix logic, add tests
2023-05-31 11:01:55 +02:00
J. Nick Koston
4c3e98b77c
Fix parallel_updates being acquired too late for entity executor jobs ()
* Fix parallel_updates being acquired too late for entity executor jobs

* tweak
2023-05-06 16:46:00 +02:00
Franck Nijhof
32344a8488
Fix incorrect warn of async_update_ha_state use () 2023-04-13 22:39:03 +02:00
Franck Nijhof
22a1a6846d
Warn for unneeded use of async_update_ha_state () 2023-04-13 13:49:56 -04:00
Franck Nijhof
d320c73fb7
Use async_write_ha_state in tests () 2023-04-13 12:36:36 +02:00
epenet
46a5aa71ec
Add type hints to helper tests () 2023-03-16 11:10:56 +01:00
epenet
5f25b71df7
Add type hints to core tests () 2023-02-20 11:42:56 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 ()
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
Franck Nijhof
80bf632e2d
Clean up unnecessary registry mocks from helpers () 2023-02-08 20:15:29 -05:00
epenet
c98b4e3204
Add typing to tests with single hass argument (2) ()
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
epenet
4142f0d15d
Add return type to tests without arguments ()
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
epenet
aa00114c2f
Add return type to async tests without arguments () 2023-02-07 10:26:56 +01:00
Paulus Schoutsen
a090652560
Use correct state in Entity repr and output similar value to State class ()
* Use correct state in Entity repr

* Test Entity.__repr__

* Align with State class
2023-02-06 13:35:36 -05:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 () 2023-02-02 18:35:24 +01:00
epenet
30bf0634fe
Add per-file-ignore to pylint () 2023-01-22 17:26:24 +01:00
Paulus Schoutsen
9ed629d838
Fix some pytest warning for helpers () 2023-01-06 09:21:46 +01:00