Commit Graph

2274 Commits (43daf20be3c5e26dc76c5bea3f059b6cf0f798c7)

Author SHA1 Message Date
Erik Montnemery ef5d46c79c
Convert AreaEntry to dataclass (#108648)
* Convert AreaEntry to dataclass

* Correct typing of AreaEntry.id

* Move responsibility for generating area id to AreaRegistry
2024-01-22 14:45:27 +01:00
J. Nick Koston 4a34cd25b2
Reduce lock contention when all translations are already cached (#108634) 2024-01-21 22:29:03 -10:00
J. Nick Koston e9a7870080
Small cleanups to async_get_all_descriptions (#108633) 2024-01-21 18:09:33 -10:00
J. Nick Koston 573de95f21
Speed up run time of admin services by using HassJob (#108623) 2024-01-21 22:41:41 -05:00
Franck Nijhof 01372024f5
Add icon translations support (#103294)
Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
2024-01-19 16:56:56 +01:00
Franck Nijhof cdf3c07488
Add icon to entity registry list for display (#108313) 2024-01-19 15:11:27 +01:00
J. Nick Koston 19258cb3df
Fix benign typo in entity registry (#108270) 2024-01-18 07:45:44 +01:00
J. Nick Koston 60ab360fe7
Avoid bytes to string to bytes conversion in websocket api (#108139) 2024-01-16 21:37:34 +01:00
J. Nick Koston 99b6c7d25f
Refactor async_track_utc_time_change to avoid using nonlocal (#108007) 2024-01-14 10:57:54 +01:00
Marc Mueller ec708811d0
Enable strict typing for trace (#107945) 2024-01-14 09:39:22 +01:00
J. Nick Koston 8d3f693907
Avoid useless time fetch in DataUpdateCoordinator (#107999)
* Avoid useless time fetch in DataUpdateCoordinator

Since we used the async_call_at helper, it would always call dt_util.utcnow()
to feed the _handle_refresh_interval which threw it away. This meant we had
to fetch time twice as much as needed for each update

* tweak

* compat

* adjust comment
2024-01-13 23:40:07 -05:00
J. Nick Koston 659ee51914
Refactor event time trackers to avoid using nonlocal (#107997) 2024-01-13 17:17:55 -10: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
J. Nick Koston d7910841ef
Add an index for devices and config entries to the entity registry (#107516)
* Add an index for devices and config entries to the entity registry

* fixes

* tweak

* use a list for now since the tests check order
2024-01-13 14:49:41 -05:00
J. Nick Koston 4b7a313ece
Use identity checks for CoreState (#107846)
Some of the checks used ==, and some used is. Switch
everything to is as its faster
2024-01-12 10:21:26 +01:00
J. Nick Koston fb0dad66db
Add jinja_pass_arg to reserved template names (#107822) 2024-01-12 09:34:49 +01:00
Lars R bf6b9175a1
Add 'bitwise_xor' filter to jinja templates (#104942)
Co-authored-by: Robert Resch <robert@resch.dev>
2024-01-10 09:40:52 +01: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
J. Nick Koston 49e3c740cc
Small cleanups to temperature helper (#107625) 2024-01-08 21:51:35 -10:00
Michael Hansen 4bb2a3ad92
Specific Assist errors for domain/device class (#107302)
* Specific errors for domain/device class

* Don't log exception

* Check device class first

* Refactor guard clauses

* Test default error
2024-01-08 12:23:06 -06:00
Marc Mueller 3c7a9272fa
Enable strict typing for intent (#107282) 2024-01-08 10:09:48 +01:00
Marc Mueller 78752264b3
Fully type homeassistant integration (#107380) 2024-01-08 10:07:30 +01:00
Marc Mueller fde7a6e9ef
Improve dispatcher typing (#106872) 2024-01-08 09:45:37 +01:00
J. Nick Koston d260ed938a
Reduce overhead to call entity services (#106908) 2024-01-08 09:30:52 +01:00
J. Nick Koston d04e2d56da
Add support for JSON fragments (#107213) 2024-01-07 17:36:31 -10:00
J. Nick Koston 368feec712
Refactor translations to reduce dict lookups (#107425)
* Refactor translations to reduce dict lookups

All of our cache lookups used:

`cache[language][O(component)][category]`

The cache was designed as

`cache[language][component][category][flatted_key]`

The lookups are now

`cache[language][category][O(component)]`

The cache is now stored as

`cache[language][category][component][flatted_key]`

This allows the catch fetch to avoid looking up
the category each loop

* already a set, and we do not mutate
2024-01-07 22:29:27 -05:00
J. Nick Koston 6ff990e2c2
Avoid fetching logger in check_if_deprecated_constant if there is nothing to log (#107341)
getLogger needs a threading lock so its nice to avoid
calling it if we are not going to log anything
2024-01-06 10:20:30 +01:00
Marc Mueller 833cddc8f5
Improve conversation typing (#106905) 2024-01-05 18:40:34 +01:00
Jan-Philipp Benecke e80138dfdf
Remove duplicate assignment of `median` and `statistical_mode` jinja2 filter (#106953) 2024-01-05 17:36:55 +01:00
Erik Montnemery c805ea7b4f
Include deprecated constants in wildcard imports (#107114) 2024-01-05 11:46:45 +01:00
Petru Paler 4a2958baeb
Fix entity property cache creation arguments (#107221) 2024-01-05 09:18:25 +01:00
J. Nick Koston 0695bf8988
Move group helpers into their own module (#106924)
This gets rid of the legacy need to use bind_hass, and
the expand function no longer looses typing.
2024-01-04 17:34:56 +01:00
Erik Montnemery 9eefd95e91
Deduplicate handling of duplicated constants (#107074)
* Deduplicate handling of duplicated constants

* Use DeprecatedConstant + DeprecatedConstantEnum

* Fixup

* Remove test cases with unnamed tuples
2024-01-04 13:25:09 +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
J. Nick Koston 09b65f14b9
Index entities by domain for entity services (#106759) 2024-01-02 15:28:58 +01:00
J. Nick Koston bbdccede85
Refactor restore state saving to avoid a dict lookup of ATTR_RESTORED (#106854) 2024-01-02 12:48:14 +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
Jan-Philipp Benecke 9d36b716e7
Use call_soon_threadsafe in render_will_timeout of template helper (#106514) 2023-12-30 13:55:53 +01:00
Erik Montnemery 461dad3039
Fix changed_variables in automation traces (#106665) 2023-12-30 08:34:21 +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
Marc Mueller 1a6e81767d
Improve trace helper typing (#105964) 2023-12-28 14:00:24 +01:00
Martijn van der Pol a823edf1c2
Jinja filter and function for `median` and `statistical_mode` (#105554)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-12-27 15:14:20 +01: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
Robert Resch ebdf7b9c8c
Deprecate some deprecated const constants (#106230)
* Deprecate some deprecated const constants

* Improve code

* fix typing

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-12-23 20:18:51 +01:00
J. Nick Koston 1c8d961832
Add support for attribute caching to ToggleEntity (#106272) 2023-12-23 11:11:14 +01:00
Bram Kragten 7ba1736637
Filter by supported features for todo services (#106241) 2023-12-22 21:22:16 +01:00
Erik Montnemery 3a744d374b
Add support for caching entity properties (#100601) 2023-12-22 09:02:55 -10:00
Robert Resch e18d2b8873
Deprecate deprecated device_registry helper constants (#106227) 2023-12-22 11:21:45 +01:00