Commit Graph
108 Commits
Author SHA1 Message Date
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 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 f4c341253b Avoid sorting domain/all states in templates (#90608) 2023-03-31 11:27:55 -10: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
epenet 79c9447770 Fix lingering timer in event helper tests (#89819)
Fix lingering timer in event tests
2023-03-16 23:01:23 -04:00
epenet 69aa3a75c5 Fix lingering timer in event sun tests (#89808) 2023-03-16 18:32:34 +01:00
epenet 46a5aa71ec Add type hints to helper tests (#89784) 2023-03-16 11:10:56 +01: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
epenet 5f25b71df7 Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
epenet c98b4e3204 Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
krahabbandJ. Nick Koston 899342d391 Refactor async_call_later to improve performance and reduce conversion loss (#87117)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-05 12:04:38 -06:00
epenet 30bf0634fe Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Franck Nijhof dd266b7119 Remove elevation warning from sun (#80239) 2022-10-14 15:23:44 +02:00
Franck Nijhof 8f4caf4141 Clean up accessing event helpers via hass (#72011) 2022-05-17 19:36:29 +02:00
Erik Montnemery 4885331509 Fail template functions when no default specified (#71687) 2022-05-13 09:46:49 -07:00
J. Nick Koston 30fdfc454f Avoid lowercasing entities after template ratelimit recovery (#71415) 2022-05-09 12:48:38 +02:00
J. Nick KostonandMartin Hjelmare fe6a4bfb1d Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC (#69643)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-09 09:05:54 -10:00
Erik MontnemeryandMartin Hjelmare cf4033b1bc Simplify time zone setting in tests (#68330)
* Simplify timezone setting in tests

* Fix typo

* Adjust caldav tests

* Adjust input_datetime tests

* Adjust time_date tests

* Adjust tod tests

* Adjust helper tests

* Adjust recorder tests

* Adjust risco tests

* Adjust aemet tests

* Adjust flux tests

* Adjust forecast_solar tests

* Revert unnecessary change in forecast_solar test

* Adjust climacell tests

* Adjust google tests

* Adjust sensor tests

* Adjust sonarr tests

* Adjust template tests

* Adjust zodiac tests

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-03-20 10:25:15 +01:00
Tobias Sauerwein 8b38fa58aa Bump pytest to 7.0.0 (#65981) 2022-02-08 10:03:27 +01:00
Erik Montnemery 39d6aba3bc Improve startup of unavailable template entities (#59827) 2021-11-22 09:20:38 -08:00
Erik Montnemery acf58111c6 Correct initial update of async_track_template_result (#59705) 2021-11-15 13:00:46 +01:00
Erik Montnemery 30f7bc0f18 Use freezegun in DST tests (#58939) 2021-11-02 18:11:39 +01:00
J. Nick KostonandErik Montnemery 1cd9be7538 Fix recursive limit in find_next_time_expression_time (#58914)
* Fix recursive limit in find_next_time_expression_time

* Add test case

* Update test_event.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-02 00:11:17 +01:00
a9c0f89c09 Fix find_next_time_expression_time (#58894)
* Better tests

* Fix find_next_time_expression_time

* Add tests for Nov 7th 2021, Chicago transtion

* Update event tests

* Update test_event.py

* small performance improvement

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-01 17:45:13 +01:00
Erik Montnemery bed4096430 Allow specifying a super template for async_track_template_result (#58477) 2021-10-27 16:07:17 +02:00
Eduard van Valkenburg 779ef3c8e1 Add timedelta option for async_call_later (#50164) 2021-06-12 13:14:35 +02:00
J. Nick KostonandPaulus Schoutsen bf2d40adfe Migrate from pytz to python-dateutil (#49643)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
FMKaiba 09eb74fd9d Upgrade Astral to 2.2 (#48573) 2021-04-02 00:29:08 +02:00
Franck Nijhof 65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
J. Nick Koston 2ef25e7414 Fix script wait templates with now/utcnow (#44717) 2021-01-01 13:03:34 +01:00
Anders Melchiorsen 650c57db5b Fix async_track_utc_time_change firing too early (#42176) 2020-11-05 16:34:56 +01:00
J. Nick Koston 8eb89cdb46 Fix flapping event template test (#42614) 2020-10-30 00:05:55 +01:00
Paulus Schoutsen bba770b411 Fix CI (#42397) 2020-10-26 13:36:03 +01:00
Anders Melchiorsen cb0c937b3e Refresh now() templates on second=0 (#42225) 2020-10-23 00:11:02 +02:00
Paulus Schoutsen 8d4675713a Fix event test (#42078) 2020-10-19 16:50:46 +02:00
J. Nick KostonandAnders Melchiorsen 31c21126a8 Implement time tracking in templates (#41147)
Co-authored-by: Anders Melchiorsen <amelchio@nogoto.net>
2020-10-19 11:02:43 +02:00
J. Nick Koston 3a9b2392f8 Suppress domain and all listeners during template rate limit (#42005) 2020-10-19 10:17:51 +02:00
J. Nick Koston 53a1d92f2b Permit event trackers to accept an empty list of entities or domains (#41857) 2020-10-15 09:26:51 +02:00
Franck NijhofandPaulus Schoutsen ee914366a8 Add native Python types support to templates (#41227)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-10-07 00:05:52 +02:00
J. Nick Koston 2fabd4edb8 Prevent collecting states already referenced by domain or all (#41308)
The template engine would collect all the states in
a domain or all states while iterating even though
they were already included in all or the domain

This lead to the rate limit not being applied to
templates that iterated all states that also
accessed a collectable property because the engine
incorrectly believed they were specifically
referenced.
2020-10-06 07:25:05 +02:00
J. Nick Koston 51da605b9f Remove manual rate_limit control directive from templates (#41225)
Increase default rate limit for all states and entire
domain states to one minute

Ensure specifically referenced entities are excluded from
the rate limit
2020-10-04 22:40:04 +02:00
J. Nick Koston b45215f1d2 Implement template rate_limit directive (#40667) 2020-10-01 21:39:44 +02:00
J. Nick Koston 7285c7806f Seperate state change tracking from async_track_template_result into async_track_state_change_filtered (#40803) 2020-10-01 10:19:20 +02:00
J. Nick KostonandPaulus Schoutsen 57b7559832 Ensure all jinja2 errors are trapped and displayed in the developer tools (#40624)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-26 17:03:32 -05:00
J. Nick Koston e9abb357e4 Log template listeners when debug logging is on (#40180) 2020-09-17 14:45:30 -05:00
J. Nick Koston 741487a1fc Return the listeners with the template result for the websocket api (#39925) 2020-09-11 13:18:40 -05:00
J. Nick Koston e208aac834 Add async_track_state_removed_domain to allow tracking when a state is removed from a domain (#39859)
when a state is removed from a domain
2020-09-11 13:03:31 +02:00
J. Nick Koston 90d574e521 Ensure static templates are still called back on first refresh (#39753) 2020-09-07 17:19:39 +02:00
J. Nick Koston a77e09b2c2 Make async_track_template_result track multiple templates (#39371)
* Make async_track_template_result track multiple templates

Combine template entity updates to only write ha
state once per template group update

* Make async_track_template_result use dataclasses for input/output

* black versions

* naming
2020-08-31 19:07:40 -05:00
J. Nick Koston c87e03ee6f Ensure template tracking can recover after the template generates an exception (#39256) 2020-08-26 00:33:08 +02:00