Commit graph

30 commits

Author SHA1 Message Date
Phil Bruckner
9e12e3f96c
Allow automation to be turned off without stopping actions () 2020-08-01 21:31:47 -05:00
Bram Kragten
7d77fa92c2
Add mode info attributes to script and automation ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-07-14 10:47:59 -07:00
Phil Bruckner
63e55bff52
Remove legacy script mode and simplify remaining modes () 2020-07-10 17:00:57 -07:00
Phil Bruckner
91271f388c
Add new repeat loop for scripts and automations () 2020-07-10 13:37:19 -05:00
Franck Nijhof
53545c984b
Log lines do not end with a full stop () 2020-07-05 23:04:19 +02:00
Phil Bruckner
f7c4900d5c
Enhance automation integration to use new features in script helper () 2020-07-05 09:25:15 -05:00
Phil Bruckner
38210ebbc6
Enhance script integration to use new features in script helper () 2020-06-30 10:22:26 -07:00
Paulus Schoutsen
5bc6ed4cef
Add logbook platforms ()
* Add logbook platforms

* Fix logbook describe test
2020-06-24 18:14:50 -07:00
Franck Nijhof
238430136e
Migrate script to use describe_event for logbook () 2020-06-12 16:44:29 -07:00
Paulus Schoutsen
aef06a3544
Directly call write state 2 ()
* Directly call async_write_ha_state pt2

* Directly call async_write_ha_state pt2

* Fix mock

* Address comments
2020-04-03 09:34:50 +02:00
Phil Bruckner
b2d7bc40dc
Add support for simultaneous runs of Script helper ()
* Add tests for legacy Script helper behavior

* Add Script helper if_running and run_mode options

- if_running controls what happens if Script run while previous run
  has not completed. Can be:
  - error: Raise an exception
  - ignore: Return without doing anything (previous run continues as-is)
  - parallel: Start run in new task
  - restart: Stop previous run before starting new run
- run_mode controls when call to async_run will return. Can be:
  - background: Returns immediately
  - legacy: Implements previous behavior, which is to return when done,
            or when suspended by delay or wait_template
  - blocking: Returns when run has completed
- If neither is specified, default is run_mode=legacy (and if_running
  is not used.) Otherwise, defaults are if_running=parallel and
  run_mode=background. If run_mode is set to legacy then if_running must
  be None.
- Caller may supply a logger which will be used throughout instead of
  default module logger.
- Move Script running state into new helper classes, comprised of an
  abstract base class and two concrete clases, one for legacy behavior
  and one for new behavior.
- Remove some non-async methods, as well as call_from_config which has
  only been used in tests.
- Adjust tests accordingly.

* Change per review

- Change run_mode default from background to blocking.
- Make sure change listener is called, even when there's an unexpected
  exception.
- Make _ScriptRun.async_stop more graceful by using an asyncio.Event for
  signaling instead of simply cancelling Task.
- Subclass _ScriptRun for background & blocking behavior.

Also:

- Fix timeouts in _ScriptRun by converting timedeltas to float seconds.
- General cleanup.

* Change per review 2

- Don't propagate exceptions if call from user has already returned
  (i.e., for background runs or legacy runs that have suspended.)
- Allow user to specify if exceptions should be logged. They will still
  be logged regardless if exception is not propagated.
- Rename _start_script_delay and _start_wait_template_delay for
  clarity.
- Remove return value from Script.async_run.
- Fix missing await.
- Change call to self.is_running in Script.async_run to direct test of
  self._runs.

* Change per review 3 and add tests

- Remove Script.set_logger().
- Enhance existing tests to check all run modes.
- Add tests for new features.
- Fix a few minor bugs found by tests.
2020-02-24 14:56:00 -08:00
Paulus Schoutsen
1b7dd6c603
Add icons to scripts () 2020-02-17 08:44:36 -08:00
Paulus Schoutsen
424e15c7a7
Find related items scripts/automations ()
* Find related items scripts/automations

* Update manifest
2020-01-29 16:19:13 -08:00
Paulus Schoutsen
9aa02e35a7
Entity Component to no longer generate automatic groups () 2020-01-07 17:30:53 +01:00
Ville Skyttä
5216477353
Be consistent with Home Assistant and Hass.io spelling ()
* Be consistent with Home Assistant spelling

* Be consistent with Hass.io spelling
2020-01-05 14:09:17 +02:00
Bas Nijholt
23b92b2a56 Sort imports according to PEP8 for components starting with "S" () 2019-12-09 14:38:01 +01:00
Paulus Schoutsen
02d9ed5e36
Do not select all entities when omitting entity ID in service call ()
* Do not select all entities when omitting entity ID

* Address comments Matthew

* Require either area_id or entity_id

* Fix tests

* Fix test
2019-12-02 16:23:12 -08:00
Ville Skyttä
99c7608fb4 Lint config cleanups ()
* Remove bunch of unneeded lint exclusions

* Use symbolic names instead of identifiers in pylint disables

* Tighten scope of some pylint disables
2019-11-25 22:40:08 -08:00
Franck Nijhof
decf13b948 Use literal string interpolation in core (f-strings) () 2019-08-23 09:53:33 -07:00
Jeff Irion
7090970436 Add descriptive fields to script config ()
* Add descriptive fields to script config

* Add script descriptions to hass.data["service_description_cache"]

* Import SERVICE_DESCRIPTION_CACHE

* Register script descriptions via async_set_service_schema

* Add scripts test for loading and reloading service descriptions

* Minor cleanup

* Clean up script schema
2019-08-21 14:08:46 -07:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00
Aaron Bach
80051b7fc2
Add area support to script service schemas () 2019-07-23 13:37:47 -06:00
Paulus Schoutsen
4e5b1ccde6
Fix calling empty script turn off () 2019-06-28 08:49:33 -07:00
Paulus Schoutsen
f995ab9d54
Don't pass in loop ()
* Don't pass in loop

* Revert some changes

* Lint + Axis revert

* reinstate loop

* Fix a test

* Set loop

* Update camera.py

* Lint
2019-05-22 21:09:59 -07:00
Paulus Schoutsen
de1fd5a7fa
WS: Improve service calling errors ()
* WS: Improve service calling errors

* Docstyle

* Types

* Update text
2019-05-14 07:09:11 +02:00
cgtobi
2c07bfb9e0 Remove dependencies and requirements ()
* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit fe7171b4cd.

* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit 391355ee2c.

* Remove dependencies and requirements

* Fix flake8 complaints

* Fix more flake8 complaints

* Revert non-component removals
2019-04-12 10:13:30 -07:00
Paulus Schoutsen
8213016eaf
Allow targeting areas in service calls ()
* Allow targeting areas in service calls

* Lint + Type

* Address comments
2019-03-04 09:51:12 -08:00
Fabian Affolter
127c55e0c1
Update file header ()
* Update file header

* Update file header

* Update file header

* Update file header

* Update file header

* Fix lint issues
2019-02-13 21:21:14 +01:00
Paulus Schoutsen
e59240fa00
Add default_config component ()
* Add default config component

* Add default_config to default config

* Fix comments
2019-02-07 20:07:15 -08:00
Paulus Schoutsen
b8cc547fa3
Move components to folders ()
* Move all components into folders

* Move component tests into folders

* Fix init moving

* Move tests

* Lint

* Update coverage

* Fix service descriptions

* Update CODEOWNERS
2019-02-05 19:31:15 -08:00
Renamed from homeassistant/components/script.py (Browse further)