Commit Graph
116 Commits
Author SHA1 Message Date
Karlie MeadsandPaulus Schoutsen ed8a0ef0ea Fix disabled condition within an automation action (#87213)
fixes undefined
2023-02-02 16:48:04 -05:00
epenetandGitHub 30bf0634fe Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Erik MontnemeryandGitHub 1e2f00e186 Improve device automation validation (#86143) 2023-01-21 00:44:17 +01:00
Joakim PlateandGitHub c576a68d33 Upgrade pytest-aiohttp (#82475)
* Upgrade pytest-aiohttp

* Make sure executors, tasks and timers are closed

Some test will trigger warnings on garbage collect, these warnings
spills over into next test.

Some test trigger tasks that raise errors on shutdown, these spill
over into next test.

This is to mimic older pytest-aiohttp and it's behaviour on test
cleanup.

Discussions on similar changes for pytest-aiohttp are here:
https://github.com/pytest-dev/pytest-asyncio/pull/309

* Replace loop with event_loop

* Make sure time is frozen for tests

* Make sure the ConditionType is not async

  /home-assistant/homeassistant/helpers/template.py:2082: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    def wrapper(*args, **kwargs):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

* Increase litejet press tests with a factor 10

The times are simulated anyway, and we can't stop the normal
event from occuring.

* Use async handlers for aiohttp

tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
  /Users/joakim/src/hass/home-assistant/venv/lib/python3.9/site-packages/aiohttp/web_urldispatcher.py:189: DeprecationWarning: Bare functions are deprecated, use async ones
    warnings.warn(

* Switch to freezegun in modbus tests

The tests allowed clock to tick in between steps

* Make sure skybell object are fully mocked

Old tests would trigger attempts to post to could services:

```
DEBUG:aioskybell:HTTP post https://cloud.myskybell.com/api/v3/login/ Request with headers: {'content-type': 'application/json', 'accept': '*/*', 'x-skybell-app-id': 'd2b542c7-a7e4-4e1e-b77d-2b76911c7c46', 'x-skybell-client-id': '1f36a3c0-6dee-4997-a6db-4e1c67338e57'}
```

* Fix sorting that broke after rebase
2022-11-29 22:36:36 +01:00
Erik MontnemeryandGitHub eb10654e01 Add test for failing conditions in sub scripts (#71238) 2022-05-03 13:06:13 +02:00
Franck NijhofandGitHub 99360ad7f4 Indicate disabled steps in script trace (#71237) 2022-05-03 13:04:59 +02:00
Erik MontnemeryandGitHub 92f1855bcf Fix script conditions (#71235) 2022-05-03 11:28:08 +02:00
Erik MontnemeryandGitHub 1931600eac Isolate parallel subscripts (#71233) 2022-05-03 10:36:58 +02:00
Erik MontnemeryandGitHub f6c2fb088c Stop script if sub-script stops or aborts (#71195) 2022-05-02 14:59:58 +02:00
Franck NijhofandGitHub 682ac52a20 Support shorthand logical operators in script sequences (#71022) 2022-04-29 18:06:21 +02:00
Franck NijhofandGitHub 35687def02 Merge stop & error script actions (#70109) 2022-04-20 14:22:37 -07:00
Thomas LovénandGitHub b50f369fe4 Add shorthand notation for boolean conditions (#70120) 2022-04-18 22:09:09 +02:00
Franck NijhofandGitHub 1b48d7eda1 Add for each item support to repeat action (#70093) 2022-04-15 19:10:25 +02:00
Franck NijhofandGitHub e04fef3c2d Allow disabling specific triggers/actions/conditions (#70082) 2022-04-15 09:33:09 -07:00
Franck NijhofandGitHub cdabcce83a Add ability to continue scripts/automations on error (#70004) 2022-04-14 13:43:14 -07:00
Franck NijhofandGitHub d704d4f853 Add parallel automation/script actions (#69903) 2022-04-13 13:07:44 -07:00
67b200a532 Add if/else automation/script action (#69811)
Co-authored-by: Erik <[email protected]>
2022-04-12 15:02:17 +02:00
Franck NijhofandGitHub 81d90b1bc7 Add stop/error script/automation action (#67340) 2022-04-11 14:22:22 -07:00
Erik MontnemeryandGitHub 8ea31cea3a Fix deadlock when stopping queued script (#68175) 2022-03-15 08:29:04 -07:00
Erik MontnemeryandGitHub 1a27025793 Prevent spawning script runs when shutting down (#68170) 2022-03-15 12:46:58 +01:00
c2e62e4d9f Re-org device automations (#67064)
Co-authored-by: Franck Nijhof <[email protected]>
2022-02-22 13:15:16 -08:00
efb6fd1569 Fix script / automation repeat with count 0 fails (#65448)
Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Erik Montnemery <[email protected]>
2022-02-03 08:18:58 -08:00
Erik MontnemeryandGitHub e2fca2e305 Support shorthand templates in condition actions (#61177)
* Support shorthand templates in condition actions

* Fix validation message

* Fix tests
2021-12-21 12:19:31 +01:00
Erik MontnemeryandGitHub 17dc609363 Correct validation of conditions in scripts and automations (#60890)
* Correct validation of conditions in scripts and automations

* Fix test
2021-12-03 09:08:28 -08:00
Erik MontnemeryandGitHub 0e3bc21d54 Teach state and numeric_state conditions about entity registry ids (#60841) 2021-12-02 14:55:12 -08:00
Erik MontnemeryandGitHub c85bb27d0d Teach state trigger about entity registry ids (#60271)
* Teach state trigger about entity registry ids

* Tweak

* Add tests

* Tweak tests

* Fix tests

* Resolve entity ids during config validation

* Update device_triggers

* Fix mistake

* Tweak trigger validator to ensure we don't modify the original config

* Add index from entry id to entry

* Update scaffold

* Pre-compile UUID regex

* Address review comment

* Tweak mock_registry

* Tweak

* Apply suggestion from code review
2021-12-02 14:26:45 +01:00
Erik MontnemeryandGitHub ea102f71a6 Correct validation of repeats in scripts and automations (#60318)
* Correct validation of repeats in scripts and automations

* Improve validation test
2021-11-26 14:12:59 +01:00
J. Nick KostonandGitHub 10d6247fee Bump to aiohttp 3.8.0 (#58974) 2021-11-04 10:07:50 -05:00
Erik MontnemeryandGitHub 838f79be3d Update tests searching for areas referenced in automations (#57558) 2021-10-13 13:27:56 -07:00
Erik MontnemeryandGitHub 007af4a7aa Search for areas, devices and entities in script choose actions (#57554) 2021-10-12 08:49:07 -07:00
Raman GuptaandGitHub bef8be9256 Support dynamic schema validation in device conditions and actions (#52007)
* Allow integrations to provide dynamic schema validation in device conditions and actions

* Add tests

* re-add type

* mypy
2021-06-28 09:23:46 +02:00
Ville SkyttäandGitHub 7d03b02192 Spelling fixes (#51642) 2021-06-11 13:35:03 +02:00
Erik MontnemeryandGitHub 1ea0d8ae02 Correct trace of condition actions (#50800) 2021-05-17 16:54:17 -07:00
b35f229674 Include _StopScript.__cause__ in trace (#50441)
Co-authored-by: Paulus Schoutsen <[email protected]>
2021-05-11 22:27:11 -07:00
Erik MontnemeryandGitHub ff5fbea1fb Improve trace of template conditions (#49101)
* Improve trace of template conditions

* Refactor

* Fix wait_template trace

* Update tests
2021-04-12 20:22:28 +02:00
Erik MontnemeryandGitHub 9f481e1642 Include script script_execution in script and automation traces (#48576) 2021-04-01 09:42:23 -07:00
Paulus SchoutsenandGitHub 63e3012380 Fix script default trace (#48390) 2021-03-26 23:56:40 -07:00
Erik MontnemeryandGitHub 272dffc384 Improve script tracing (#48100)
* Improve script tracing

* Fix test
2021-03-22 13:15:45 +01:00
Erik MontnemeryandGitHub f8755a52c2 Warn on undefined variables in templates (#48140)
* Warn on undefined variables in templates

* Add test

* fix tests

* fix tests
2021-03-20 15:16:04 +01:00
Erik MontnemeryandGitHub 7b717bc437 Correct trace for repeat script actions (#48031) 2021-03-18 13:14:06 -07:00
1cde1074c9 Correct trace for choose and repeat script actions (#47973)
* Correct trace for choose and repeat script actions

* only choose-wrap the choices

* Update tests

Co-authored-by: Paulus Schoutsen <[email protected]>
2021-03-16 08:49:16 +01:00
Erik MontnemeryandGitHub 704000c049 Add support for breakpoints in scripts (#47632) 2021-03-09 21:23:11 -08:00
Erik MontnemeryandGitHub 8fe51b8ea7 Store automation traces indexed by run_id (#47509)
* Store traces indexed by run_id

* Format

* Add test

* Add test

* Clarify comment
2021-03-08 18:04:41 +01:00
Erik MontnemeryandGitHub 2f9d03d115 Merge action and condition traces (#47373)
* Merge action and condition traces

* Update __init__.py

* Add typing to AutomationTrace

* Make trace_get prepare a new trace by default

* Correct typing of trace_cv

* Fix tests
2021-03-06 12:57:21 +01:00
Erik MontnemeryandGitHub 17401cbc29 Initial automation tracing (#46755)
* Initial prototype of automation tracing

* Small fixes

* Lint

* Move trace helpers to its own file

* Improve trace for state and numeric_state conditions

* Tweaks + apply suggestions from code review

* Index traces by automation_id, trace while script is running

* Refactor condition tracing

* Improve WS API to get traces for single automation

* Add tests

* Fix imports

* Fix imports

* Address review comments

* Cap logging of loops

* Remove unused ContextVar action_config
2021-03-04 14:16:24 +01:00
2d70806035 Add support for "alias" in script steps device, device_condition, and conditions (#46647)
Co-authored-by: Donnie <[email protected]>
2021-02-20 19:21:09 -08:00
Erik MontnemeryandGitHub 58b4a91a5b Test that variables are passed to wait_for_trigger script action (#46221) 2021-02-09 00:34:18 +01:00
Anders MelchiorsenandGitHub 48002f47f4 Use caplog fixture for log capturing (#46214) 2021-02-08 14:33:57 +01:00
Anders MelchiorsenandGitHub b9b1caf4d7 Raise ConditionError for numeric_state errors (#45923) 2021-02-08 10:47:57 +01:00
J. Nick KostonandGitHub 243014bff1 Fix test_wait_template_with_utcnow (#45356) 2021-01-20 23:56:00 +01:00