Commit Graph

2342 Commits (c048b840fc70d0b7b069141710e9aa340bd64428)

Author SHA1 Message Date
J. Nick Koston 5b73adba20
Revert "Reduce dict lookups in entity registry indices" (#111055)
Revert "Reduce dict lookups in entity registry indices (#109712)"

This reverts commit 440212ddce.
2024-02-21 07:11:58 +01:00
J. Nick Koston 490c03d248
Add async_schedule_call to the Debouncer (#111051) 2024-02-21 00:09:45 -06:00
J. Nick Koston 1a02330bd9
Avoid creating tasks to remove entities (#110967) 2024-02-20 21:32:36 -06:00
J. Nick Koston 9ce1ec414e
Reduce overhead to load multiple languages in translations (#111028)
* Reduce overhead to load multiple languages in translations

Instead of loading in a task, we now group everything
to be loaded into a single executor job

* fixes

* fixes

* fixes

* fixes

* fixes

* update tests

* add missing coverage (was existing)
2024-02-20 21:52:28 -05: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 dc4008c518
Avoid creating tasks to shutdown entity platforms (#111026)
* Avoid creating tasks to shutdown entity platforms

Nothing needed to be awaited here

* fix mocking

* missed one test
2024-02-20 21:10:25 -05:00
Michael Hansen ec4bd9a421
Add new intents for cover, valve, vacuum, and media player (#110757)
* Add valve to HassTurnOn/Off

* Add set position for valves

* Add set position to covers

* Add HassTurnOn/Off for vacuums

* Add media player intents

* Split out vacuum intents

* Address comments

* Extra test
2024-02-19 22:28:42 -05:00
Franck Nijhof e0a9dcd996
Add label registry (#110821) 2024-02-19 11:59:08 +01:00
J. Nick Koston c74958dd36
Reduce one iteration of pending flows in the discovery flow helper (#110918) 2024-02-19 09:57:39 +01:00
Marc Mueller 72ccc40c43
Add better HassJob typing for IntegrationPlatform process_job (#110896) 2024-02-18 16:46:48 -06:00
Franck Nijhof 67ac60d042
Add hex color validator (#110846) 2024-02-18 16:03:21 +01:00
Franck Nijhof 70d1bbb20d
Improve floor registry event typing (#110844) 2024-02-18 14:57:15 +01:00
J. Nick Koston 16653ff5d0
Group loading of translations for integrations to reduce executor jobs at startup (#110674) 2024-02-17 21:08:55 -06:00
J. Nick Koston 9bc130c131
Ensure translations for other integrations can be loaded if one integration fails (#110748)
* load failure

* merge
2024-02-17 21:01:36 -05:00
J. Nick Koston 0d4c82b54d
Convert Integration platforms processors where nothing is awaited to callbacks (#110825)
Convert Integration platforms processors where nothing is awaited callbacks
2024-02-17 20:49:47 -05:00
J. Nick Koston 165d79b553
Add typing of EVENT_COMPONENT_LOADED to integration_platform helper (#110826) 2024-02-17 20:48:46 -05:00
J. Nick Koston 33ff6b5b6e
Avoid creating tasks for checking integrations platforms (#110795)
* Avoid creating tasks for checking integrations platforms

This is a followup to #110743 to avoid creating a task to check
if the integration platform exists. We created tasks because
we needed to await async_get_integrations but since its always
called from EVENT_COMPONENT_LOADED firing, we can use the
async_get_loaded_integration version which does not need
to be awaited. This eliminates one task for every loaded
component

* there is no more race risk

* reduce

* coro or callback

* reduce

* tweak

* race safe

* fix type

* fixes

* use built-in helper to make it smaller

* use built-in helper to make it smaller

* use built-in helper to make it smaller

* add coverage to ensure exceptions are logged

* improve readability a bit

* platforms
2024-02-18 01:07:18 +01:00
Franck Nijhof 4570eed6f6
Add floor registry (#110741)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-02-17 21:21:15 +01:00
J. Nick Koston 664285b9d4
Small performance improvement in tracking template results (#110622)
- Avoid inner function creation each refresh
- remove extra unneeded checks from ratelimit
2024-02-17 18:08:24 +01:00
J. Nick Koston 42cf081582
Avoid creating tasks to load integration platforms that do not exist (#110743) 2024-02-17 07:02:51 -06:00
J. Nick Koston 2cb0249f0a
Add filter to translation event listeners to avoid creating tasks (#110732) 2024-02-16 12:13:23 -06:00
J. Nick Koston 53062a81cc
Simplify loading of icons (#110687) 2024-02-16 16:51:14 +01:00
G Johansson cb776593cf
Make context in data entry flow possible to modify for subclasses (#110561)
* Make context in data entry flow possible to modify for subclasses

* mypy

* Make get_context

* base view

* Review comments

* Remove context from options flow
2024-02-16 15:51:51 +01:00
J. Nick Koston dd1cf2c593
Remove unneeded list copy in icon helper (#110680) 2024-02-15 16:33:24 -06:00
deosrc e38cb01d81
Add missing log message for error resolving OAuth token (#107606) 2024-02-11 13:07:54 +00:00
chammp a5cc0ae890
Improve package schema validation (#108125)
* Add failing tests for package config validation error wrapping

* Wrap package schema validation errors in HomeAssistantError

* Fix yamllint errors

* Rework package merge validation

Ignore invalid package definitions instead of failing startup.
Output error messages with locations if possible when a package
definition has errors.

* Ruff format

* Fix linter errors

* Move package_definition_schema to module scope

* Move inner function to module level

* Merge exception handlers

Merge exception handlers for config schema validation and package merge
to avoid untested code branches

* Fix long lines and doc strings

* More minor changes to exception handler

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-02-10 20:16:20 +01:00
Piotr Machowski a2f4e99994
Add state_translated function to jinja templates (#96906)
* Add state_translated jinja function

* Add tests for load_state_translations_to_cache and get_cached_translations

* Cleanup state_translated template

* Add tests for state_translated jinja function

* Apply black formatting

* Improve code quality

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Prevent invalid components from loading translations

* Refactor loading translations to cache

* Adjust code issues

* Update homeassistant/helpers/translation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Refactor listeners that trigger translation loading

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Adjust invalid function calls, fix code styling

* Adjust code quality

* Extract async_translate_state function

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Fix tests

* Fix tests

---------

Co-authored-by: Piotr Machowski <PiotrMachowski@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-02-10 10:47:56 +01:00
J. Nick Koston 9689cb448d
Avoid linear search of entity registry in async_extract_referenced_entity_ids (#109667)
* Index area_ids in the entity registry

I missed that these are used in _resolve_area in search.

Eventually we can make async_extract_referenced_entity_ids
a bit faster with this as well

* Avoid linear search of entity registry in async_extract_referenced_entity_ids

needs https://github.com/home-assistant/core/pull/109660
2024-02-09 09:42:30 -05:00
Michael d049928be7
Log error and continue on parsing issues of translated strings (#110046) 2024-02-09 08:35:12 +01:00
Michael Hansen 2681dae60c
Matching duplicate named entities is now an error in Assist (#110050)
* Matching duplicate named entities is now an error

* Update snapshot

* Only use area id
2024-02-08 19:38:03 -06:00
Michael Hansen 1750f54da4
Assist fixes (#109889)
* Don't pass entity ids in hassil slot lists

* Use first completed response

* Add more tests
2024-02-07 15:13:42 -06:00
Joost Lekkerkerker 59e9010b65
Show domain in oauth2 error log (#109708)
* Show token url in oauth2 error log

* Fix tests

* Use domain
2024-02-06 23:03:35 +01:00
J. Nick Koston 09c609459d
Fix entity services targeting entities outside the platform when using areas/devices (#109810) 2024-02-06 12:41:57 -06:00
J. Nick Koston 440212ddce
Reduce dict lookups in entity registry indices (#109712) 2024-02-05 17:23:53 -05:00
J. Nick Koston f73431ac06
Switch utc_to_timestamp to .timestamp() where possible (#109729)
* Switch utc_to_timestamp to .timestamp()

.timestamp() is faster now in newer cpython

```
from homeassistant.util.dt import utc_to_timestamp, utcnow
import timeit
now = utcnow()
print(timeit.timeit('utc_to_timestamp(now)',globals={"now":now,"utc_to_timestamp":utc_to_timestamp}))
print(timeit.timeit('now.timestamp()',globals={"now":now}))
```

utc_to_timestamp = 0.18721245788037777
timestamp = 0.11421508435159922

* compat

* revert

* revert

* revert

* revert

* revert
2024-02-05 23:04:52 +01:00
J. Nick Koston 908cedf981
Avoid linear search of entity registry in async_clear_config_entry (#109724) 2024-02-05 14:12:16 -06:00
J. Nick Koston e9a41e5023
Avoid linear search in entity registry to clear an area (#109735) 2024-02-05 13:53:33 -06:00
J. Nick Koston 6f28d79651
Copy callbacks instead of slice for event dispatch (#109711)
We established copy is faster in
https://github.com/home-assistant/core/pull/108428#discussion_r1466932262
2024-02-05 17:07:21 +01:00
J. Nick Koston 40166ed51e
Avoid linear search of device registry when no areas are referenced in service calls (#109669) 2024-02-05 12:26:08 +01:00
Marc Mueller cd0ee98dba
Use builtin TimeoutError [core + helpers] (#109684) 2024-02-05 12:09:54 +01:00
J. Nick Koston 458e1f3a5e
Index area_ids in the entity registry (#109660) 2024-02-05 09:01:43 +01:00
J. Nick Koston 9fef1938b4
Make get_entries_for_device_id skip disabled devices by default (#109645) 2024-02-04 23:11:56 +01:00
J. Nick Koston b24b4fc237
Use get_entries_for_config_entry_id helper in async_migrate_entries (#109629) 2024-02-04 21:05:48 +01:00
J. Nick Koston 2f724b042b
Avoid looking up services to check if they support responses (#109588)
We already have the Service object as its the value in the
services_map so there is not need to look it up again
2024-02-04 15:15:51 +01:00
J. Nick Koston a74516a80d
Cache path for Store helper (#109587) 2024-02-04 15:13:58 +01:00
Michael Hansen c6ea57458c
Pass slots to error messages instead of IDs [rework] (#109410)
Co-authored-by: tetele <tm.sandu@gmail.com>
2024-02-03 12:14:33 +01:00
Erik Montnemery 09ba46ddb9
Mask sensitive data in google_assistant logs (#109366)
* Mask sensitive data in google_assistant logs

* Move common code to homeassistant/util/redact.py

* Move to helpers

* Add tests

* Tweak

* Redact additional logs

* Fix stale docstring

* Don't reveal the length of masked data

* Update test
2024-02-02 22:10:30 +01:00
J. Nick Koston 582d6968b2
Avoid de/recode of bytes to string to bytes when writing json files (#109348) 2024-02-02 09:02:26 +01:00
J. Nick Koston 1c84997c5c
Reduce lock contention when all icons are already cached (#109352) 2024-02-02 08:58:55 +01:00
J. Nick Koston ed726db974
Fix race in loading service descriptions (#109316) 2024-02-01 12:34:23 -06:00