Commit graph

162 commits

Author SHA1 Message Date
epenet
9744e72d5a
Add ability to auto-cancel track_time_interval () 2023-04-13 21:31:16 +02:00
rlippmann
3a72054f93
Make dataclasses in HA core slotted () 2023-04-11 07:58:28 -10:00
epenet
c01b1eb013
Adjust async_track_time_interval name argument ()
Adjust async_track_time_interval naming
2023-04-05 10:58:02 -04:00
J. Nick Koston
02ef7d445d
Allow passing an optional name to async_track_time_interval ()
* 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
J. Nick Koston
cefba7c638
Avoid falling back to listening for all states when a template render raises an exception ()
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
J. Nick Koston
aff7345ea0
Improve event filters to reject earlier ()
* Improve event filters to reject earlier

- Avoid running the callbacks for state added/removed from
  a domain if there are no listeners that care about the domain

- Remove some impossible checks in the listeners that will
  never match since they were already rejected by the filter

* leave one guard since there is a race when we return control via await
2023-03-08 10:25:42 -05:00
J. Nick Koston
11681f3f31
Pass a helpful name when creating common asyncio tasks in core () 2023-03-05 12:46:02 +01:00
krahabb
899342d391
Refactor async_call_later to improve performance and reduce conversion loss ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-05 12:04:38 -06:00
Marc Mueller
6f94e47270
Update Union typing (6) [Py310] () 2023-01-23 15:01:07 +01:00
Marc Mueller
45b4b0e990
Import ParamSpec from typing [Py310] ()
* Import ParamSpec from typing [Py310]

* Update additional imports
2023-01-23 07:28:43 +01:00
Franck Nijhof
06a35fb7db
Code styling tweaks to core helpers () 2023-01-08 13:44:09 -10:00
J. Nick Koston
d89c259d7e
Fix double time conversion in async_track_point_in_utc_time () 2023-01-03 20:21:54 +01:00
Franck Nijhof
d4f69a3652
String formatting and max line length - Part 7 ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +01:00
Michaël Arnauts
7142b4ecac
Fixes some grammar mistakes () 2022-12-20 11:10:31 +01:00
J. Nick Koston
d0efdd750f
Fix high latency from thundering heard at 0 microseconds ()
* Fix high latency at 0 microseconds

fixes 

* fix async_track_utc_time_change alignment

* use replace to preserve fold

* naming

* tweak

* make async_fire_time_changed aware of the thundering heard issue
2022-11-17 14:22:06 -05:00
HarvsG
e5dafbc166
Make _TrackTemplateResultInfo not private () 2022-10-09 15:23:08 +02:00
Erik Montnemery
7ead77eea6
Correct typing of async_track_state_change ()
* Correct typing of async_track_state_change

* Update integrations
2022-09-27 16:32:54 +01:00
J. Nick Koston
363f95c954
Remove auto lowercasing from async_track_entity_registry_updated_event () 2022-09-05 12:13:05 +02:00
Marc Mueller
dc47121f2c
Better type hass_job method calls () 2022-08-09 16:12:33 -04:00
Marc Mueller
af7df260a0
Fix small type issues [core] () 2022-07-26 16:28:22 +02:00
J. Nick Koston
9b157f974d
Reduce overhead to refire events from async_track_point_in_utc_time when an asyncio timer fires early ()
* Reduce overhead to refire events

- asyncio timers can fire early for a varity of reasons including
  poor clock resolution and performance. To solve this problem
  we re-arm async_track_point_in_utc_time and try again later
  when this happens.

- On some platforms this means the async_track_point_in_utc_time can
  end up trying many times to prevent firing the timer early since as
  soon as it rearms it fires again and this repeats until we reach
  the appointed time. While there is not much we can do to prevent
  asyncio from firing the timer callback early, we can reduce the
  overhead when this happens by using avoiding creating datetime
  objects

* tweak mocking

* -vvv

* fix time freeze being too broad in litterrobot

* adjust
2022-06-14 07:46:00 -10:00
Marc Mueller
b417ae72e5
Add generic parameters to HassJob () 2022-05-30 09:22:37 +02:00
J. Nick Koston
30fdfc454f
Avoid lowercasing entities after template ratelimit recovery () 2022-05-09 12:48:38 +02:00
Marc Mueller
93cbb331e5
Update Mypy to 0.950 ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-04-27 20:49:54 -05:00
Marc Mueller
7dfe8591c4
Improve typing [helpers.event] () 2022-04-27 17:19:06 +02:00
Franck Nijhof
fb92fc6a8e
Trigger on not matching to/from states () 2022-04-12 14:18:23 -07:00
J. Nick Koston
fe6a4bfb1d
Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-09 09:05:54 -10:00
Marc Mueller
30e2411761
Add type ignore error codes [last ones] () 2022-02-18 18:15:57 +01:00
Erik Montnemery
037621b796
Update _TrackStateChangeFiltered entity listener with new entities () 2022-01-25 18:19:12 +01:00
Marc Mueller
12757a8cd2
Update typing - collections.abc (1) ()
* Update typing - collections.abc (1)

* Additional typing updates
2022-01-12 07:56:35 +01:00
Marc Mueller
d3b7bd25ef
Update typing (1) () 2022-01-11 21:26:03 +01:00
Marc Mueller
eb2238a9e1
Add types for HassJob [helpers.event] () 2022-01-08 14:26:22 +01:00
Marc Mueller
250af90acb
Improve callable typing [helpers.event] () 2022-01-06 21:01:27 -10:00
Marc Mueller
198ade5e2b
Fix typing TrackTemplateResultListener [helpers.event] () 2022-01-06 13:43:54 -10:00
Ruslan Sayfutdinov
55f4962c06
Fix pylint plugin which checks relative imports () 2021-12-23 11:14:47 -08:00
Erik Montnemery
39d6aba3bc
Improve startup of unavailable template entities () 2021-11-22 09:20:38 -08:00
Erik Montnemery
acf58111c6
Correct initial update of async_track_template_result () 2021-11-15 13:00:46 +01:00
Erik Montnemery
34e5596375
Use async_track_utc_time_change to schedule short term statistics () 2021-11-01 10:49:54 -07:00
Erik Montnemery
bed4096430
Allow specifying a super template for async_track_template_result () 2021-10-27 16:07:17 +02:00
Marc Mueller
7af67d34cf
Use assignment expressions 01 () 2021-09-18 13:31:35 -10:00
Ville Skyttä
59809503d1
Various type hint related improvements ()
* Avoid some implicit generic Anys

* Fix hassio discovery view type hints

* Fix http view result type in assert message
2021-08-21 13:58:49 +02:00
Daniel Hjelseth Høyer
fbad453c89
Pylint 2.9.3 ()
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2021-07-14 21:44:57 -07:00
Erik Montnemery
1cc8280959
Enable basic type checking for the homeassistant component ()
* Enable basic type checking for the homeassistant component

* Tweak
2021-07-05 11:26:31 +02:00
Eduard van Valkenburg
779ef3c8e1
Add timedelta option for async_call_later () 2021-06-12 13:14:35 +02:00
Ruslan Sayfutdinov
391b2f8ccd
Add missing return type in Core constructors () 2021-05-20 18:53:29 +03:00
Martin Hjelmare
7c4893cbb1
Fix event action return value typing ()
Co-authored-by: Ruslan Sayfutdinov <ruslan@sayfutdinov.com>
2021-05-11 16:23:59 +02:00
Marc Mueller
c07646db5d
Update typing syntax ()
* Update typing syntax

* Replace typing imports with ones from collections where possible

* Changes after review
2021-04-20 17:40:41 +02:00
J. Nick Koston
6048e88c8b
Improve debuggability by providing job as an arg to loop.call_later ()
Before
`<TimerHandle when=1523538.181864923 async_track_point_in_utc_time.<locals>.run_action() at /usr/src/homeassistant/homeassistant/helpers/event.py:1177>`

After
`<TimerHandle when=1524977.1818648616 async_track_point_in_utc_time.<locals>.run_action(<Job HassJobType.Coroutinefunction <bound method DataUpdateCoordinator._handle_refresh_interval of <homeassistant.components.roku.RokuDataUpdateCoordinator object at 0x7fcc978a51c0>>>) at /usr/src/homeassistant/homeassistant/helpers/event.py:1175>`
2021-04-19 11:02:17 +02:00
Ville Skyttä
970cbcbe15
Type hint improvements () 2021-04-17 08:35:21 +02:00
Erik Montnemery
16196e2e16
Don't log template errors from developer tool () 2021-04-09 12:10:02 -07:00