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
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
4085c4f6d8
Tweak typing of Entity.platform ( #88321 )
...
* Tweak typing of Entity.platform
* Fix mypy errors
* Fix update test
* Improve comments
2023-06-09 10:56:04 +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
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
Erik Montnemery
a71c097aeb
Revert "Allow setting an entity's name by its device class" ( #93539 )
2023-05-25 17:20:54 +02:00
Erik Montnemery
67c1051305
Allow setting an entity's name by its device class ( #90767 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-05-09 18:55: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
445b823232
Avoid task creation when calling schedule_update_ha_state without force update ( #91352 )
2023-04-13 18:39:03 +02:00
rlippmann
3a72054f93
Make dataclasses in HA core slotted ( #91208 )
2023-04-11 07:58:28 -10:00
J. Nick Koston
3d1556a4a2
Switch back to using call_later for the slow entity update warning ( #91067 )
...
* Switch back to using call_later for the slow entity update warning
I had originally changed this to create a task and wait
in #41184 but that does not make sense anymore with newer
cpython as the profile now shows the original method is cheaper
(or I did it wrong the first time)
* fix missing block till done since there is no longer a task being created which would run the event loop once
2023-04-08 22:22:56 -04:00
J. Nick Koston
5eb0c35a97
Add names to common helper tasks ( #90803 )
2023-04-05 08:41:15 +02:00
Erik Montnemery
149e610bca
Drop __eq__ dunder method from Entity ( #90585 )
2023-03-31 17:03:02 +02:00
J. Nick Koston
30e7ab247d
Small cleanups to writing entity state ( #89890 )
...
* Small cleanups to writing entity state
* reduce one prop access
* small cleanups
* small cleanups
* name conflict
2023-03-17 20:32:24 -04:00
Erik Montnemery
cf7e500a8e
Support translating entity names ( #88242 )
2023-03-12 15:55:04 +01:00
J. Nick Koston
11681f3f31
Pass a helpful name when creating common asyncio tasks in core ( #89171 )
2023-03-05 12:46:02 +01:00
Erik Montnemery
83e5bf7ae8
Use entity_sources to determine integration in recorder platforms ( #88382 )
2023-02-18 07:21:41 -06:00
Erik Montnemery
cc564026fa
Move EntityCategory to homeassistant.const ( #87792 )
...
* Move EntityCategory to homeassistant.const
* Fix more imports
2023-02-09 20:15:37 +01:00
Erik Montnemery
8ccb3b7151
Fix circular import loop in homeassistant/helpers/entity.py ( #87780 )
...
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-09 19:15:53 +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
06a35fb7db
Code styling tweaks to core helpers ( #85441 )
2023-01-08 13:44:09 -10:00
Franck Nijhof
d4f69a3652
String formatting and max line length - Part 7 ( #84532 )
...
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +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
Erik Montnemery
35dbc3151a
Fix docstring for entity helper ( #82704 )
...
Fix some language in entity.py
2022-11-25 18:20:33 +01:00
Marc Mueller
0c8eeaa643
Update mypy to 0.990 ( #81783 )
...
* Update mypy to 0.990
* Remove type ignore - overriding attr with property (13475)
* Remove type ignores - hasattr (13544)
* Adjust type ignore - assignment (13549)
* New error code - type-abstract (13785)
* Disable annotation-unchecked (13851)
2022-11-08 14:41:39 +01:00
Erik Montnemery
6979cd95b0
Add suggested_unit_of_measurement attribute to sensors ( #80638 )
...
* Add suggested_unit_of_measurement attribute to sensors
* Lazy calculation of initial entity options
* Add type alias for entity options
* Small tweak
* Add tests
* Store suggested_unit_of_measurement in its own option key
* Adapt to renaming of IMPERIAL_SYSTEM
* Fix rebase mistakes
* Apply suggestions from code review
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-24 16:08:02 +02:00
Franck Nijhof
a30dfd9f3e
Add class attribute for capability attributes in entity base class ( #76599 )
2022-08-11 10:34:58 +02:00
Franck Nijhof
7adb0f0ef5
Custom component -> Custom integration ( #75404 )
2022-07-18 22:10:22 +02:00
Erik Montnemery
26a85c6644
Add Entity.has_entity_name attribute ( #73217 )
2022-06-28 09:38:05 -07:00
Erik Montnemery
921245a490
Remove deprecated temperature conversion of non sensors ( #73222 )
2022-06-08 20:47:47 +02:00
Erik Montnemery
deedbca46c
Mark unused sync toggle method from ToggleEntity as final ( #72370 )
2022-05-23 17:52:21 +02:00
Erik Montnemery
1aaf78ef99
Remove entity category system in favor of hidden_by ( #68550 )
2022-05-02 09:33:16 -07:00
Marc Mueller
283c04e424
Improve typing [helpers.entity] ( #70890 )
2022-04-28 10:52:42 +02:00
Erik Montnemery
c5d69ab1b2
Handle removed entites in collection.sync_entity_lifecycle ( #70759 )
...
* Handle removed entites in collection.sync_entity_lifecycle
* Add comment
2022-04-27 08:05:00 -07:00
Paulus Schoutsen
5317bf02e6
Fix hidden default ( #70699 )
2022-04-25 10:10:42 -07:00
Franck Nijhof
7b75a16745
Add visible by default property to base Entity ( #70370 )
2022-04-21 22:06:34 -07:00
epenet
4c7e1fe060
Cleanup ENTITY_CATEGORIES_SCHEMA ( #66549 )
...
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-04-01 09:40:43 -07:00
Paulus Schoutsen
130ca2213f
Enforce EntityCategory enum ( #69015 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-03-31 15:04:33 -07:00
Erik Montnemery
69ee4cd978
Deprecate temperature conversion in base entity class ( #68978 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-03-31 14:29:44 -07:00
Erik Montnemery
9471e4d77c
Don't override temperature unit for sensors ( #68910 )
2022-03-30 10:15:00 -07:00
Erik Montnemery
91f6e58e9a
Allow customizing unit for temperature and pressure sensors ( #64366 )
...
* Allow customizing unit for temperature and pressure sensors
* pylint
* Adjust google_wifi tests
* Address review comments and add tests
* Improve rounding when scaling
* Tweak rounding
* Further tweak rounding
* Allow setting entity options with config/entity_registry/update
* Address review comments
* Tweak tests
* Load custom unit when sensor is added
* Override async_internal_added_to_hass
* Adjust tests after rebase
* Apply suggestions from code review
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
* Address review comments
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-03-30 15:43:04 +02:00
J. Nick Koston
aaeaed4117
Compatibility for "device_state_attributes" which was deprecated in 2021.4 has been removed ( #67837 )
...
* Small performance tweaks to _async_write_ha_state
- Only call self.available once per cycle
- Only call self.device_state_attributes once per update cycle
- Do not check for device_state_attributes if extra_state_attributes is not None
* drop backcompat
* remove prop
2022-03-09 21:39:43 +01:00
J. Nick Koston
a75bbc79a2
Prevent polling from recreating an entity after removal ( #67750 )
2022-03-07 20:42:16 -08:00
Marc Mueller
30e2411761
Add type ignore error codes [last ones] ( #66816 )
2022-02-18 18:15:57 +01:00
Marc Mueller
bfb1abd3a2
Add type ignore error codes [helpers] ( #66776 )
2022-02-18 11:31:37 +01:00
epenet
0a7b1dec7d
Adjust type hint in core add_job ( #66503 )
...
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-14 11:13:10 +01:00
Joakim Sørensen
7a40ae13a4
Add guard for invalid EntityCategory value ( #66316 )
2022-02-11 14:57:45 +01:00
Erik Montnemery
911e488d48
Fix ENTITY_CATEGORIES_SCHEMA ( #66108 )
...
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-02-08 14:00:53 -08:00
epenet
f662e8669e
Address late review in entity registry ( #64851 )
...
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-24 22:42:38 +01:00
epenet
32d5c8e8ac
Add type hint to RegistryEntry.entity_category ( #64618 )
...
Co-authored-by: Dave T <17680170+davet2001@users.noreply.github.com>
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-24 12:51:11 +01:00
Franck Nijhof
176f03d4ac
Allow toggles (switches) state to be None ( #64621 )
2022-01-23 11:31:01 +01:00
Marc Mueller
b0f72f59da
Use imports from `core` ( #63458 )
2022-01-05 14:55:38 +01:00