J. Nick Koston and GitHub
0f29fd3e10
Switch to using fast cached_property implementation in propcache ( #127339 )
2024-10-03 13:11:02 -05:00
b3377fe5fb
Add condition to trigger template entities ( #119689 )
...
* Add conditions to trigger template entities
* Add tests
* Fix ruff error
* Ruff
* Apply suggestions from code review
* Deduplicate
* Tweak name used in debug message
* Add and improve type annotations of modified code
* Adjust typing
* Adjust typing
* Add typing and remove unused parameter
* Adjust typing
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
* Adjust return type
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com >
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
2024-09-11 09:36:49 +02:00
Erik Montnemery and GitHub
992de497f2
Remove unnecessary assignment of Template.hass from script helper ( #123780 )
2024-08-13 11:55:37 +02:00
Erik Montnemery and GitHub
efb7bede40
Enable strict typing on script helper ( #122075 )
2024-07-17 13:51:59 +02:00
Erik Montnemery and GitHub
385f5be7e8
Remove dead code from script helper ( #122074 )
2024-07-17 13:16:57 +02:00
Marc Mueller and GitHub
ca55986057
Import Generator from collections.abc (1) ( #120914 )
2024-07-01 11:51:51 +02:00
J. Nick Koston and GitHub
ad7097399e
Ensure multiple executions of a restart automation in the same event loop iteration are allowed ( #119100 )
...
* Add test for restarting automation
related issue #119097
* fix
* add a delay since restart is an infinite loop
* tests
2024-06-08 17:07:39 -04:00
Marc Mueller and GitHub
fe21e2b8ba
Import Generator from typing_extensions (1) ( #118986 )
2024-06-06 17:02:13 +02:00
J. Nick Koston and GitHub
7bbb33b415
Improve script disallowed recursion logging ( #118151 )
2024-05-26 12:58:34 +02:00
Marc Mueller and GitHub
0e03e591e7
Improve callable annotations ( #118024 )
2024-05-24 10:24:09 +02:00
9224997411
Add sequence action for automations & scripts ( #117690 )
...
Co-authored-by: Robert Resch <robert@resch.dev >
2024-05-24 09:34:49 +02:00
Marc Mueller and GitHub
900b6211ef
Use PEP 695 for function annotations (2) ( #117659 )
2024-05-18 11:44:39 +02:00
Marc Mueller and GitHub
87bb7ced79
Use PEP 695 for simple type aliases ( #117633 )
2024-05-17 14:42:21 +02:00
Matthias Alphart and GitHub
ec4c8ae228
Allow templates for enabling actions ( #117049 )
...
* Allow templates for enabling automation actions
* Use `cv.template` instead of `cv.template_complex`
* Rename test function
2024-05-15 21:03:52 +02:00
ac54cdcdb4
Enable Ruff RUF010 ( #115371 )
...
Co-authored-by: J. Nick Koston <nick@koston.org >
2024-05-08 23:54:49 +02:00
Marc Mueller and GitHub
8f614fb06d
Use HassKey for helpers (2) ( #117013 )
2024-05-07 11:24:13 -05:00
Sid and GitHub
2cc916db6d
Replace pylint broad-except with Ruff BLE001 ( #116250 )
2024-05-07 14:00:27 +02:00
Sid and GitHub
b456d97e65
Replace pylint protected-access with Ruff SLF001 ( #115735 )
2024-05-06 20:33:26 +02:00
J. Nick Koston and GitHub
91fa8b50cc
Turn on thread safety checks in async_dispatcher_send ( #116867 )
...
* Turn on thread safety checks in async_dispatcher_send
We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash
* Turn on thread safety checks in async_dispatcher_send
We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash
* adjust
2024-05-05 16:29:43 -04:00
J. Nick Koston and GitHub
164403de20
Add thread safety checks to async_create_task ( #116339 )
...
* Add thread safety checks to async_create_task
Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here
* Add thread safety checks to async_create_task
Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here
* missed one
* Update homeassistant/core.py
* fix mocks
* one more internal
* more places where internal can be used
* more places where internal can be used
* more places where internal can be used
* internal one more place since this is high volume and was already eager_start
2024-04-28 18:29:00 -04:00
J. Nick Koston and GitHub
7715bee6b0
Fix script in restart mode that is fired from the same trigger ( #116247 )
2024-04-27 07:08:29 -05:00
J. Nick Koston and GitHub
a22c221722
Rename bus._async_fire to bus.async_fire_internal ( #116027 )
2024-04-23 22:28:31 +02:00
J. Nick Koston and GitHub
4529268544
Ensure scripts with timeouts of zero timeout immediately ( #115830 )
2024-04-19 18:24:54 +02:00
J. Nick Koston and GitHub
f80894d56f
Stop scripts with eager tasks ( #115340 )
2024-04-10 08:41:13 -04:00
J. Nick Koston and GitHub
569f54d8e3
Terminate scripts with until and while conditions that execute more than 10000 times ( #115110 )
2024-04-07 11:02:53 -10:00
0d66d298ec
Enable Ruff RET504 ( #114528 )
...
* Enable Ruff RET504
* fix test
* Use noqa instead of cast
* fix sonos RET504
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
2024-04-06 11:07:37 +02:00
Marc Mueller and GitHub
816ce116bf
Remove unnecessary functools.cached_property backport ( #114239 )
2024-04-04 11:24:26 +02:00
Sid and GitHub
f7b7f74d10
Enable Ruff TRY201 ( #114269 )
...
* Enable Ruff TRY201
* remove redundant rules
2024-03-28 10:18:07 +01:00
J. Nick Koston and GitHub
f4922edb4b
Fix empty delays in script helper ( #114346 )
...
fixes
```
Logger: homeassistant.components.automation.kamermaster_knop_4_acties_licht
Bron: components/automation/__init__.py:726
integratie: Automatisering (documentatie, problemen)
Eerst voorgekomen: 22:17:29 (5 gebeurtenissen)
Laatst gelogd: 22:59:24
While executing automation automation.kamermaster_knop_4_acties_licht
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 726, in async_trigger
return await self.action_script.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1645, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 506, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 536, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 504, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 626, in _async_delay_step
if timeout_future.done():
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'done'
```
2024-03-28 00:29:43 -04:00
Marc Mueller and GitHub
911a31f860
Use SignalType to improve typing [core] ( #114298 )
2024-03-27 14:25:02 +01:00
Franck Nijhof and GitHub
670bd97777
Find referenced labels in automations & scripts ( #113812 )
2024-03-19 16:28:37 +01:00
Franck Nijhof and GitHub
38d0854b70
Find referenced floors in automations & scripts ( #113802 )
2024-03-19 14:18:53 +01:00
Sid and GitHub
ccd2e989c3
Enable ruff RUF005 and fix occurrences ( #113589 )
2024-03-16 07:37:20 -10:00
J. Nick Koston and GitHub
bdede0e0da
Start script runs eagerly ( #113190 )
2024-03-14 16:53:26 -10:00
J. Nick Koston and GitHub
09934d44c4
Reduce script overhead by avoiding creation of many tasks ( #113183 )
...
* Reduce script overhead by avoiding creation of many tasks
* no eager stop
* reduce
* make sure wait being cancelled is handled
* make sure wait being cancelled is handled
* make sure wait being cancelled is handled
* preen
* preen
* result already raises cancelled error, remove redundant code
* no need to raise it into the future
* will never set an exception
* Simplify long action script implementation
* comment
* preen
* dry
* dry
* preen
* dry
* preen
* no need to access protected
* no need to access protected
* dry
* name
* dry
* dry
* dry
* dry
* reduce name changes
* drop one more task
* stale comment
* stale comment
2024-03-14 20:28:27 -04:00
J. Nick Koston and GitHub
427de00524
Remove unnecessary use of async_run_job in script helper ( #113118 )
...
The function being passed to `async_run` was always a callback
2024-03-11 21:36:18 -04:00
J. Nick Koston and GitHub
324266a4e6
Fix race in script stop that could cause async_stop to hang forever ( #113089 )
2024-03-11 10:48:11 -10:00
Marc Mueller and GitHub
19ab3d6daf
Add empty line after module docstring [helpers + other] ( #112707 )
2024-03-08 10:36:11 -05:00
J. Nick Koston and GitHub
3877a56d23
Avoid creating tasks for automation and script validation ( #111181 )
...
These functions created tasks to run small validators, and the cost of
creating all the tasks was more expensive than running the validators
themselves. Since the code is unlikely to suspend its more efficient to
await them in series.
2024-02-23 13:41:36 -05:00
Marc Mueller and GitHub
cd0ee98dba
Use builtin TimeoutError [core + helpers] ( #109684 )
2024-02-05 12:09:54 +01:00
Erik Montnemery and GitHub
3ce4e53b32
Sort script actions ( #108247 )
2024-01-31 20:41:53 +01:00
J. Nick Koston and GitHub
f96f4d31f7
Convert referenced registry functions to use cached_property ( #108895 )
...
* Convert referenced registry functions to use cached_property
These already implemented caching, but now that we can use cached_property
because the lock problem is solved, we can make the code simplier and faster
* missed one
* make them the same
2024-01-26 23:02:42 -05:00
Erik Montnemery and GitHub
909e58066d
Fix changed_variables in automation and script traces ( #108788 )
2024-01-24 19:12:45 +01:00
9bff039d17
Add set_conversation_response script action ( #108233 )
...
* Add set_conversation_response script action
* Update homeassistant/components/conversation/trigger.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
* Revert accidental change
* Add test
* Ignore mypy
* Remove incorrect callback decorator
* Update homeassistant/helpers/script.py
* Add test with templated set_conversation_response
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com >
Co-authored-by: Paulus Schoutsen <balloob@gmail.com >
2024-01-23 09:13:42 -05:00
Marc Mueller and GitHub
ec708811d0
Enable strict typing for trace ( #107945 )
2024-01-14 09:39:22 +01:00
Erik Montnemery and GitHub
461dad3039
Fix changed_variables in automation traces ( #106665 )
2023-12-30 08:34:21 +01:00
Erik Montnemery and GitHub
09ad1a9a36
Remove unnecessary block use of pylint disable in components p-z ( #100192 )
2023-09-12 20:47:48 +02:00
7b1c0c2df2
Extend template entities with a script section ( #96175 )
...
* Extend template entities with a script section
This allows making a trigger entity that triggers a few times a day,
and allows collecting data from a service resopnse which can be
fed into a template entity.
The current alternatives are to publish and subscribe to events or to
store data in input entities.
* Make variables set in actions accessible to templates
* Format code
---------
Co-authored-by: Erik <erik@montnemery.com >
2023-09-02 16:19:45 -07:00
Marc Mueller and GitHub
a9ade1f84d
Use asyncio.timeout [core] ( #98447 )
2023-08-15 08:36:05 -05:00
Franck Nijhof and GitHub
3e85a29b86
Move overlapping pylint rules to ruff, disable mypy overlap ( #94359 )
2023-06-27 17:42:46 +02:00