Commit Graph

309 Commits (f984cca49b135dcb51991afcb85bc35e06352410)

Author SHA1 Message Date
J. Nick Koston 1a02330bd9
Avoid creating tasks to remove entities (#110967) 2024-02-20 21:32:36 -06: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
Petru Paler 4a2958baeb
Fix entity property cache creation arguments (#107221) 2024-01-05 09:18:25 +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
J. Nick Koston a46fe94216
Add helper to report deprecated entity supported features magic numbers (#106602) 2023-12-28 12:24:36 -10:00
J. Nick Koston eb3fde7261
Avoid clearing the attr cache in setter when nothing has changed (#106384) 2023-12-25 09:13:48 -10:00
J. Nick Koston b757984031
Optimize use_device_name check in base entity class (#106209) 2023-12-24 00:30:33 +01:00
J. Nick Koston 1c8d961832
Add support for attribute caching to ToggleEntity (#106272) 2023-12-23 11:11:14 +01:00
Erik Montnemery 3a744d374b
Add support for caching entity properties (#100601) 2023-12-22 09:02:55 -10:00
Erik Montnemery 104bcc64b7
Allow inheriting base component entity descriptions in frozen dataclasses (#105512)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-15 23:33:50 -10:00
Erik Montnemery 0ec3a222e3
Remove device_state_attributes property from entity base class (#105650) 2023-12-14 08:33:56 +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 d4cf049016
Remove unneeded class _EntityDescriptionBase (#105518) 2023-12-11 23:10:11 +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 d913508607
Allow removing an entity more than once (#102904) 2023-11-08 12:50:40 +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
Erik Montnemery a63c420890
Quote entity ids in entity excpetions (#103286) 2023-11-03 06:04:07 +01:00
J. Nick Koston e5ebdf7ad4
Remove implict name check from Entity base class (#101905) 2023-10-15 23:40:43 +02:00
Marc Mueller 0b2b486754
Update mypy to 1.6.0 (#101780) 2023-10-11 13:25:11 +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 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 fbcc5318c5
Move attributes to be excluded from recording to entity classes (#100239)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-20 18:09:12 +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
J. Nick Koston 034fabe188
Use loop time to set context (#99701)
* Use loop time to set context

loop time is faster than utcnow, and since its only used internally it can
be switched without a breaking change

* fix mocking
2023-09-06 11:04:49 +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 b885dfa5a8
Add preview to sensor group config and option flows (#83638) 2023-08-22 10:29:16 +02:00
Erik Montnemery 045c327928
Move DeviceInfo from entity to device registry (#98149)
* Move DeviceInfo from entity to device registry

* Update integrations
2023-08-10 22:04:26 -04:00
Franck Nijhof 737ac8c600
Fix DeviceInfo configuration_url validation (#97319) 2023-07-27 18:57:01 +02:00
Marc Mueller c0da6b822e
Fix ruff (#97131) 2023-07-24 10:34:16 +02:00
Marc Mueller 3371c41bda
Improve `async_track_device_registry_updated_event` callback typing (#97125) 2023-07-24 09:42:01 +02:00
Marc Mueller 0624345322
Improve `async_track_entity_registry_updated_event` callback typing (#97124) 2023-07-24 09:14:10 +02:00
J. Nick Koston 039a3bb6e9
Only load the device entry when it changes in the base entity (#95801) 2023-07-10 15:17:35 +02: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
Erik Montnemery 071d3a474f
Base entity ids on English for languages not using Latin script (#91357) 2023-06-27 14:37:50 +02:00
J. Nick Koston c4288e7b1f
Use cached_property in entity.py instead of manual cache (#95307) 2023-06-26 19:18:46 -05:00
J. Nick Koston 9051750add
Cache entity translation lookups and keys (#95180) 2023-06-25 08:50:48 -05:00
J. Nick Koston 9354df975c
Reduce overhead to set up and write entity state (#95162) 2023-06-24 14:16:28 -05:00
Allen Porter b9b5fe6be8
Add service response data for listing calendar events (#94759)
* Add service response data for listing calendar events

Add the capability of response data for for the entity component.

* Rename input arguments and add service description

* Improve list events to be more user friendly

Allow the end date to be determined based on a relative time duration. Make the start time optional and set to "now". Add additional test coverage. Update demo calendar to actually perform date range checks.

* Wrap docstrings properly.

* Increase test coverage

* Update to use new API calls

* Readability improvements

* Wrap docstrings

* Require at least one of end or duration

* Check for multiple entity matches earlier in the request

* Update documentation strings
2023-06-23 23:34:34 -04: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 950b25bf42
Remove unnecessary assert from Entity (#94711) 2023-06-16 14:07:25 +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 2406b235b4
Name unnamed binary sensors by their device class (#92940)
* Name unnamed binary sensors by their device class

* Update type annotations

* Fix loading of entity component translations

* Add test

* Update integrations

* Set abode and rfxtrx binary_sensor name to None

* Revert changes in homekit_controller
2023-06-13 19:48:54 +02:00