Commit graph

116 commits

Author SHA1 Message Date
Erik Montnemery
5b84e50dc0
Prevent overriding cached attribute as property (#107657)
* Prevent overriding cached attribute as property

* Remove debug
2024-01-12 15:58:46 +01:00
Erik Montnemery
056b06de13
Don't use entity_id in __repr__ of not added entity (#106861) 2024-01-02 12:59:11 +01:00
Erik Montnemery
f9150b78b3
Ensure it's safe to call Entity.__repr__ on non added entity (#106032) 2023-12-31 18:56:04 +01:00
J. Nick Koston
16192cd7f2
Add helper to report deprecated entity supported features magic numbers (#106602) 2023-12-29 11:27:32 +01: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
Erik Montnemery
01b3e0c49e
Remove useless code from entity helper tests (#103854) 2023-11-12 18:55:34 +01:00
Erik Montnemery
d913508607
Allow removing an entity more than once (#102904) 2023-11-08 12:50:40 +01:00
Jan-Philipp Benecke
ae1117bc74
Fix failing entity reuse test (#103342)
* 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 (#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
J. Nick Koston
e5ebdf7ad4
Remove implict name check from Entity base class (#101905) 2023-10-15 23:40:43 +02:00
Nicolas van de Walle
1b11062b27
Improved debugging for "Failed to set state" (#101657) 2023-10-08 19:40:42 +02:00
Erik Montnemery
20188181f7
Fix spelling in sensor test (#101520) 2023-10-06 11:51:08 +02:00
Erik Montnemery
17779c5f0c
Add loader.async_suggest_report_issue and loader.async_get_issue_tracker (#101336)
* 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" (#100422)
Revert "Cache entity properties that are never expected to change in the base class (#95315)"

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 (#95315) 2023-09-14 17:48:48 -05:00
Erik Montnemery
bbcbb2e322
Improve Entity._suggest_report_issue (#100204) 2023-09-12 21:07:32 +02:00
Erik Montnemery
51576b7214
Improve typing of entity.entity_sources (#99407)
* 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 (#99452)
* 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 (#98214) 2023-08-10 19:28:16 +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
Jan Bouwhuis
b9c7e7c15e
Fix not including device_name in friendly name if it is None (#95485)
* 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 (#95180) 2023-06-25 08:50:48 -05:00
Franck Nijhof
e2f5a707ce
Fix use_device_name in case device device class translations are used (#95010)
Co-authored-by: Erik <erik@montnemery.com>
2023-06-22 11:30:19 +02:00
Erik Montnemery
334dacc322
Change Entity.name default to UNDEFINED (#94574)
* 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 (#94487) 2023-06-12 21:48:12 +02:00
Erik Montnemery
59f5b8f2d6
Remove unneeded checks for Entity.platform (#94321)
* 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 (#93601)
* 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 (#92681)
* 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 (#91387) 2023-04-13 22:39:03 +02:00
Franck Nijhof
22a1a6846d
Warn for unneeded use of async_update_ha_state (#91372) 2023-04-13 13:49:56 -04:00
Franck Nijhof
d320c73fb7
Use async_write_ha_state in tests (#91333) 2023-04-13 12:36:36 +02:00
epenet
46a5aa71ec
Add type hints to helper tests (#89784) 2023-03-16 11:10:56 +01:00
epenet
5f25b71df7
Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
Franck Nijhof
ed79265843
Enable Ruff PT006 (#88165)
* 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 (#87734) 2023-02-08 20:15:29 -05:00
epenet
c98b4e3204
Add typing to tests with single hass argument (2) (#87675)
* 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 (#87613)
* 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 (#87612) 2023-02-07 10:26:56 +01:00
Paulus Schoutsen
a090652560
Use correct state in Entity repr and output similar value to State class (#87519)
* 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 (#87188) 2023-02-02 18:35:24 +01:00
epenet
30bf0634fe
Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Paulus Schoutsen
9ed629d838
Fix some pytest warning for helpers (#85283) 2023-01-06 09:21:46 +01:00
Erik Montnemery
8e617bbc1d
Add translation_key property to entites (#82701)
* Add translation_key attribute to entity state

* Update accuweather test

* Index entity translation keys by platform

* Store translation key in entity registry
2022-12-01 09:34:09 +01:00
Franck Nijhof
7adb0f0ef5
Custom component -> Custom integration (#75404) 2022-07-18 22:10:22 +02:00