Commit graph

239 commits

Author SHA1 Message Date
Erik Montnemery
2c02abfdd4
Improve script config tests () 2022-12-22 12:16:23 +01:00
Erik Montnemery
a6217ca9b9
Improve error message when an automation fails to validate () 2022-12-21 23:20:50 +01:00
Joakim Plate
8bd4125390
Test corrections noticed during pytest upgrade ()
* Withing trigger a call to coordinator after init

* Stop discovery task on STOP event

* Stop dsmr connection task on STOP

* Use autospec in modem_serial tests

close on AioSerial is non async, and should not be mocked as a coroutine

* Make sure responder is specced correctly

tests/components/emulated_hue/test_init.py::test_setup_works
  /Users/joakim/src/hass/home-assistant/homeassistant/components/emulated_hue/__init__.py:119: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    protocol.close()

* Don't assume Pymodbus is the only thing logging

* Use gather instead of wait

```
homeassistant/components/homeassistant/__init__.py:208: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
```

* Increase wait time for automation tests

Assuming exit within 1 seconds is unreasonable on a potentially loaded
test machine.

* Avoid changing app state after startup
2022-11-23 20:53:28 +01:00
Erik Montnemery
9bd676aff6
Improve automation reload ()
* Improve automation reload

* Small tweak

* Improve
2022-11-10 14:44:55 +01:00
Erik Montnemery
f7694c0550
Only reload modified scripts ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-10-24 20:47:06 +02:00
Erik Montnemery
31a787558f
Ensure recorder test fixture is setup before hass fixture ()
* Ensure recorder test fixture is setup before hass fixture

* Adjust more tests
2022-10-19 07:58:47 +02:00
Erik Montnemery
284893d942
Fix reload of automation and scripts when blueprint changed () 2022-10-14 16:43:09 +02:00
Erik Montnemery
81f40afd80
Only reload modified automations ()
* Only reload modified automations

* Update tests

* Adjust spelling

* Improve efficiency of matching automations and configurations

* Reload automations without an alias if they have been moved

* Add test

* Add test

* Add test
2022-10-14 15:28:03 +02:00
Paulus Schoutsen
4843d330f3
Allow fetching automation config () 2022-09-28 12:49:00 +02:00
Franck Nijhof
5f0cca9b26
Raise repairs issue if automation calls unknown service () 2022-08-25 20:56:26 -04:00
Erik Montnemery
1c1b23ef69
Correct referenced entities and devices for event triggers () 2022-08-15 17:35:30 -04:00
Erik Montnemery
5f2b4001f3
Separate recorder database schema from other classes ()
* Separate recorder database schema from other classes

* fix logbook imports

* migrate new tests

* few more

* last one

* fix merge

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-07 14:41:43 +02:00
J. Nick Koston
24a0007785
Add additional context data to logbook events () 2022-05-12 17:21:14 -07:00
J. Nick Koston
24d7a464e1
Refactor logbook to reduce overhead and complexity () 2022-05-08 21:47:26 -07:00
Paulus Schoutsen
b1a04302b5
Stringify enums in selectors () 2022-05-06 11:25:01 -07:00
Erik Montnemery
1df99badcf
Allow scripts to turn themselves on () 2022-05-04 15:54:37 +02:00
Franck Nijhof
63679d3d29
Fix missing device & entity references in automations () 2022-05-01 21:49:50 -07:00
Erik Montnemery
28ebab9c5a
Simplify waiting for recorder in tests () 2022-04-25 12:04:47 +02:00
Erik Montnemery
982e314de6
Use recorder_mock in tests ()
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-04-22 19:29:44 -10:00
J. Nick Koston
c3108b3899
Exclude attributes for automation and script domains () 2022-04-18 12:10:18 +02:00
Franck Nijhof
8aff8d89d2
Clean up async_reproduce_state helper usage () 2022-03-24 14:40:54 +01:00
Erik Montnemery
46f27fdefd
Don't prevent automations from triggering themselves () 2022-03-15 18:48:54 +01:00
Chris Browet
e961d92b5e
Allow service data template to return a dict () 2021-10-23 21:10:30 +02:00
Richard T. Schaefer
9e219d9b6e
Add this variable for use by automation and script templates () 2021-07-28 09:09:13 +02:00
Erik Montnemery
b01b33c304
Add trigger condition ()
* Add trigger condition

* Tweaks, add tests
2021-06-11 15:05:57 +02:00
Erik Montnemery
2c8b7c56f5
Fix race when restarting script () 2021-04-16 09:03:34 +02:00
Paulus Schoutsen
a59460a233
Test that we do not initialize bad configuration ()
* Test that we do not initialize bad configuration

* Simplify test as we are not calling a service
2021-04-08 22:04:39 +02:00
Erik Montnemery
a49989241a
Refactor tracing: Move trace support to its own integration () 2021-03-22 19:19:38 +01:00
Erik Montnemery
272dffc384
Improve script tracing ()
* Improve script tracing

* Fix test
2021-03-22 13:15:45 +01:00
Paulus Schoutsen
f67e8b4369
Populate trigger variable when manually triggering automation ()
* Populate trigger variable when manually triggering automation

* Update tests/components/automation/test_init.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-22 08:22:32 +01:00
Franck Nijhof
8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI () 2021-03-19 13:41:09 +01:00
Paulus Schoutsen
f1c274b3dd
Add run_id to automation logbook event () 2021-03-16 14:37:26 -07:00
Klaas Schoute
0097169dd3
Add aliases to actions in automation blueprints () 2021-03-16 17:14:07 +01:00
Erik Montnemery
9647eeb2e0
Add custom JSONEncoder for automation traces ()
* Add custom JSONEncoder for automation traces

* Add tests

* Update default case to include type

* Tweak

* Refactor

* Tweak

* Lint

* Update websocket_api.py
2021-03-16 14:21:05 +01:00
Erik Montnemery
f82e59c32a
Make it possible to list debug traces for a specific automation () 2021-03-15 16:51:04 -07:00
Paulus Schoutsen
2a22c54fcb
Store the correct context in the trace () 2021-03-12 08:12:26 +01:00
Erik Montnemery
a9a9e1f199
Tweak automation tracing () 2021-03-10 14:42:13 -08:00
Ville Skyttä
dc880118a4
Lint suppression cleanups ()
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01:00
Paulus Schoutsen
7c2545af6e
Use async_capture_events to avoid running in executor () 2021-02-26 13:28:52 -08:00
Anders Melchiorsen
48002f47f4
Use caplog fixture for log capturing () 2021-02-08 14:33:57 +01:00
Erik Montnemery
047f16772f
Support templating MQTT triggers ()
* Add support for limited templates (no HASS access)

* Pass variables to automation triggers

* Support templates in MQTT triggers

* Spelling

* Handle trigger referenced by variables

* Raise on unsupported function in limited templates

* Validate MQTT trigger schema in MQTT device trigger

* Add trigger_variables to automation config schema

* Don't print stacktrace when setting up trigger throws

* Make pylint happy

* Add trigger_variables to variables

* Add debug prints, document limited template

* Add tests

* Validate MQTT trigger topic early when possible

* Improve valid_subscribe_topic_template
2021-02-08 10:50:38 +01:00
Anders Melchiorsen
b9b1caf4d7
Raise ConditionError for numeric_state errors () 2021-02-08 10:47:57 +01:00
Marc Mueller
7673f57248
Add additional error handling for automation script run () 2021-01-28 09:26:41 +01:00
Franck Nijhof
65cf2fcb6f
Drop asynctest () 2021-01-01 22:31:56 +01:00
Paulus Schoutsen
ac2af69d26
Fix extracting entity and device IDs from scripts ()
* Fix extracting entity and device IDs from scripts

* Fix extracting from data_template
2020-12-08 13:06:29 +01:00
Paulus Schoutsen
ff4897a09e
Fix using execute on the notify_leaving_zone () 2020-12-02 16:21:00 +01:00
Paulus Schoutsen
6c9c280bbb
Migrate notify-leaving-zone to use mobile app device action () 2020-12-02 13:07:04 +01:00
Paulus Schoutsen
648f9e100d
Use light turn on service () 2020-12-02 10:53:26 +01:00
Paulus Schoutsen
dd513147a5
Add a service target () 2020-11-28 23:33:32 +01:00
Paulus Schoutsen
b3be708db6
Add default config if not there ()
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2020-11-25 15:10:04 +01:00