Commit Graph

1164 Commits (0f80d0625afae93228e9e25e686a9d89c52be2e4)

Author SHA1 Message Date
epenet 79ad9a3646
Shutdown coordinator on entry unload (#91748)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-04-21 10:07:31 +02:00
Franck Nijhof 65d7e48815
Update ruff to v0.0.262 (#91767) 2023-04-21 08:15:41 +02:00
epenet ae0cbffdd8
Add ability to shutdown update coordinator (#91456)
* Add ability to shutdown update coordinator

* Adjust nibe_heatpump

* Add tests

* Use async

* Remove duplicate code in update coordinator

* Adjust

* Revert nibe changes - it can now be done in a follow-up PR

* Adjust

* Fix incorrect merge

* async_fire_time_changed
2023-04-18 18:56:43 +02:00
epenet 81f018b7e5
Make Debouncer shutdown async (#91542)
* Make shutdown async in Debouncer

* Adjust test
2023-04-17 23:31:30 +02:00
Erik Montnemery 8f8a398631
Support marking an assist pipeline as preferred (#91418)
* Support marking an assist pipeline as preferred

* Adjust

* Revert unneeded change

* Send preferred pipeline id in pipeline list

* Don't use property functions for the preferred pipeline
2023-04-15 10:05:46 -04:00
J. Nick Koston 56cc6633f5
Use fast path for track_time_change that fires every second (#91432)
We were missing a check for `*` and were only checking
`None`. Automations use `*`, python code uses `None`.
2023-04-14 21:02:54 -04:00
epenet 19a6530c3c
Add ability to shutdown a Debouncer (#91439)
* Add ability to shutdown a Debouncer

* Use async_create_task
2023-04-14 21:01:21 -04: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
David Poll ea12d7a86f
Add pretty printing, key sorting, and better performance to to_json in Jinja (#91253)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-04-13 00:32:13 +02:00
epenet 9705607db4
Fix lingering timer in cloud (#90822)
* Fix lingering timer in cloud

* Rename variable

* Improve

* Improve again

* Adjust

* Adjust

* Add property to HassJob instead

* Adjust

* Rename

* Adjust

* Adjust

* Make it read-only

* Add specific test
2023-04-07 11:38:17 +02:00
Erik Montnemery 59a02cd08c
Allow storing other items than untyped `dict` in `StorageCollection` (#90932)
Allow storing other items than untyped dict in StorageCollection
2023-04-06 10:57:00 -04:00
Erik Montnemery fa308d8e10
Drop unused logger argument for StorageCollection() (#90913) 2023-04-06 13:28:34 +02:00
epenet c01b1eb013
Adjust async_track_time_interval name argument (#90838)
Adjust async_track_time_interval naming
2023-04-05 10:58:02 -04:00
J. Nick Koston edd93e989e
Add render count to templates repr (#90753) 2023-04-03 19:38:15 -10:00
J. Nick Koston 17719663f0
Fix memory churn in state templates (#90685)
* Fix memory churn in state templates

The LRU for state templates was limited to 512 states. As soon
as it was exaused, system performance would tank as each template
that iterated all states would have to create and GC any state
> 512

* does it scale?

* avoid copy on all

* comment

* preen

* cover

* cover

* comments

* comments

* comments

* preen

* preen
2023-04-02 20:51:25 -04:00
J. Nick Koston 44b35fea47
Speed up entity filter when there are many glob matchers (#90615)
* Speed up entity filter when there are many glob matchers

Since we do no care about which glob matches we can
combine all the translated globs into a single regex
which reduces the overhead

* delete unused code

* preen
2023-03-31 21:18:29 -04:00
J. Nick Koston f4c341253b
Avoid sorting domain/all states in templates (#90608) 2023-03-31 11:27:55 -10:00
Petro31 642984a042
Fix for is_hidden_entity when using it in select, selectattr, reject, and rejectattr (#90512)
fix
2023-03-30 09:14:58 -04:00
Erik Montnemery 5bc9545b81
Rename custom_jinja to custom_templates (#90473)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-03-29 21:58:25 +02:00
Erik Montnemery e22618a555
Write protect entity options (#90185) 2023-03-28 22:56:51 +02:00
ehendrix23 e45eab600f
Add has_value function/test to Jinja2 template (#79550) 2023-03-28 17:04:29 +02:00
Petro31 2123600039
Add minutely updates to relative_time and today_at template functions (#86815)
* add minutely update

* fix mypy
2023-03-28 15:10:28 +02:00
J. Nick Koston 02ef7d445d
Allow passing an optional name to async_track_time_interval (#90244)
* Allow passing an optional name to async_track_time_interval

This is the same idea as passing a name to asyncio.create_task which
makes it easier to track down bugs

* more

* short

* still cannot find it

* add a few more

* test
2023-03-25 10:11:14 -04:00
Erik Montnemery 3931e11fd9
Try to load integration before starting option flow (#90111)
* Try to load integration before starting option flow

* Adjust tests
2023-03-22 20:10:10 +01:00
epenet 0e7bd401f2
Fix lingering timer in config entry flow tests (#89853) 2023-03-19 08:56:24 +01:00
epenet ab6e929443
Fix EntityComponent lingering timer in helper tests (#89801)
* Fix lingering timer in entity platform tests

* Tweak

* Fix entity and entity_component also

* Remove async_shutdown

* Adjust

* Adjust
2023-03-17 10:26:05 +01:00
epenet ab4a726e6c
Add tmpdir to known fixtures in pylint (#89844) 2023-03-17 10:22:02 +01:00
epenet 79c9447770
Fix lingering timer in event helper tests (#89819)
Fix lingering timer in event tests
2023-03-16 23:01:23 -04:00
Franck Nijhof f9919bb7cf
Add pre-defined entity name translations (#89792) 2023-03-16 21:10:20 +01:00
epenet 69aa3a75c5
Fix lingering timer in event sun tests (#89808) 2023-03-16 18:32:34 +01:00
epenet 1a7e316b51
Fix lingering timer in condition tests (#89807) 2023-03-16 18:19:29 +01:00
Erik Montnemery 9384ec18f8
Add filters to climate and light service descriptions (#86162)
* Add filters to climate and light service descriptions

* Allow specifying enums directly

* Update service descriptions

* Adjust test

* Cache entity features

* Lint

* Improve error handling, add list of known base components

* Don't allow specifying an entity feature as int
2023-03-16 15:59:51 +01:00
Erik Montnemery 886c2635ad
Add support for constant selector (#89573)
* Add support for constant selector

* Adapt to frontend PR changes
2023-03-16 09:02:26 -04:00
epenet c6568ffb62
Fix lingering timer in collection helper tests (#89793)
* Fix lingering timer in collection helper tests

* One more
2023-03-16 08:38:22 -04:00
Franck Nijhof f32b7859b8
Restructure translations for entity components (#89702) 2023-03-16 12:16:08 +01:00
epenet 46a5aa71ec
Add type hints to helper tests (#89784) 2023-03-16 11:10:56 +01:00
epenet 913156b0e0
Avoid lingering timer on script shutdown (#89753) 2023-03-16 08:00:21 +01:00
epenet 3aa5629665
Improve type hints in condition helper tests (#89754) 2023-03-15 19:42:23 +01:00
epenet 54ad8b8ee9
Avoid lingering timers in update coordinator tests (#89749) 2023-03-15 18:50:32 +01:00
epenet 35c02ddc81
Add type hints to update coordinator tests (#89748) 2023-03-15 18:07:43 +01:00
Penny Wood 858fc30fcd
Fix infinite loop in sun.sun (#89723) 2023-03-14 16:27:29 -10:00
David Poll 0457bb2717
Add is_hidden_entity test for Jinja templates (#89011) 2023-03-13 18:20:33 +01:00
David Poll 7284af6a3e
Add an in-memory-preloading loader for Jinja imports (#88850)
* Adds a loader to enable jinja imports.

* Switch to in-memory

* Move loading custom_jinja off of the event loop

* Raise TemplateNotFound if template doesn't exist

* Fix docstring

* Adds a service to reload custom jinja

* Remove IO from test setup

* Improve coverage and small refactor

* Incorporate feedback and use .jinja extension

* Check the loaded sources in test.

* Incorporate PR feedback.

* Update homeassistant/helpers/template.py

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

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-03-13 11:00:05 +01:00
epenet a0f725dfcb
Add type hints to tests (#89497) 2023-03-10 12:06:50 +01:00
Lucas Mindêllo de Andrade eed16dc185
Add list areas function to template (#88441) 2023-03-09 22:32:30 +01:00
epenet 48fca3bb27
Fix missing debouncer cancel in update coordinator (#89383)
* Fix missing debouncer cancel in update coordinator

* Improve

* Adjust with comment

* Adjust again

* Simplify PR

* Adjust tests to avoid lingering timer

* Improve
2023-03-09 15:16:52 -05:00
J. Nick Koston e1d62b554a
Migrate integration_platform helper to use async_get_integrations (#89303)
* Migrate integration_platform helper to use async_get_integrations

We were fetching integrations inside the gather one
at a time. This is inefficent.

* cleanup

* cleanup

* add task name

* small tweaks

* gather only if we have tasks
2023-03-08 16:01:47 -05:00
J. Nick Koston cefba7c638
Avoid falling back to listening for all states when a template render raises an exception (#89392)
When a template render raised an exception we would start listening for
all states until the template did not raise an exception anymore. This
was not needed since the entity that is causing the exception was
already in the tracker.

Re-rendering on all state changes can be extremely expensive and can
bring an instance into a sluggish or unresponsive state when updating
from a much older version that did not raise ValueError when a default
was missing.
2023-03-08 15:50:34 -05:00