Commit Graph

109 Commits (e76503ddc39ab239de6776cf89499df148038cd5)

Author SHA1 Message Date
Franck Nijhof 4e3c12883e
Allow templatable service target to support scripts (#48600) 2021-04-01 13:10:01 -07:00
Franck Nijhof 38d14702fa
Remove HomeAssistantType alias from helpers (#48400) 2021-03-27 12:55:24 +01:00
Marc Mueller 4cb7718192
Update typing 16 (#48087) 2021-03-18 22:58:19 +01:00
J. Nick Koston 08db262972
Add a service to reload config entries that can easily be called though automations (#46762) 2021-03-17 21:27:21 -07:00
Marc Mueller 6fb2e63e49
Update typing 02 (#48014) 2021-03-17 18:34:19 +01:00
Ville Skyttä dc880118a4
Lint suppression cleanups (#47248)
* 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
Franck Nijhof 42fd3be0e8
Add template support to service targets (#46977)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-02-23 22:46:00 -08:00
Bram Kragten afa91e886b
Add description to tts and notify services (#46764)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-02-23 14:29:57 +01:00
Franck Nijhof c8ffac20b9
Add name to services (#46905) 2021-02-22 16:26:46 +01:00
Anders Melchiorsen 9f4874bb81
Explicitly create_task for asyncio.wait (#46325) 2021-02-20 19:57:46 +01:00
Bram Kragten 6986fa4eb6
Add target to services.yaml (#46410)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-02-16 09:35:27 +01:00
Franck Nijhof 9b7c39d20b
Postponed evaluation of annotations in core (#46434)
* Postponed evaluation of annotations in core

* Remove unneeded future
2021-02-12 10:58:20 +01:00
Ville Skyttä a6358430b4
Fix deprecated asyncio.wait use with coroutines (#44981)
https://docs.python.org/3/library/asyncio-task.html#asyncio-example-wait-coroutine
2021-02-10 14:16:58 +01:00
Bram Kragten 4b493c5ab9
Add target to service call API (#45898)
* Add target to service call API

* Fix _async_call_service_step

* CONF_SERVICE_ENTITY_ID overrules target

* Move merging up before processing schema

* Restore services.yaml

* Add test
2021-02-10 12:42:28 +01:00
tkdrob c2302784c2
Use core constants for helpers (#46240) 2021-02-08 22:53:17 +01:00
Ville Skyttä 82607977ef
Various type hint improvements (#46144) 2021-02-08 11:59:46 +01:00
Ville Skyttä 1c8fbc7e6a
Upgrade codespell to 2.0.0 (#44695)
* Upgrade codespell to 2.0.0

* Fix newly found spelling errors
2020-12-31 19:14:07 +01:00
Paulus Schoutsen cf5be049b3
Warn when referencing missing devices/areas (#43787) 2020-12-01 08:01:27 +01:00
Paulus Schoutsen 0de9e8e952
Allow specifying device_id as target (#43767) 2020-11-30 14:27:02 +01:00
Paulus Schoutsen dd513147a5
Add a service target (#43725) 2020-11-28 23:33:32 +01:00
Paulus Schoutsen d34753473d
Use run_job for service helper (#43696) 2020-11-27 16:12:39 +01:00
Erik Montnemery a5e5c5c7e6
Exclude disabled entities from async_entries_for_device (#43665) 2020-11-27 09:03:44 +01:00
Paulus Schoutsen edf70e9f06
Make input_datetime better handle timezones (#43396)
* Make input_datetime better handle timezones

* Improve test coverage

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Revert change to time format

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-11-26 20:20:10 +01:00
J. Nick Koston 94bf55e29b
Limit concurrency of async_get_integration to avoid creating extra threads (#43085)
* Limit concurrency of async_get_integration to avoid creating extra threads

Since async_get_integration is waiting on the disk most of the time
it would end up creating many new threads because the disk could
not deliver the data in time.

* pylint
2020-11-10 21:34:54 -10:00
Robert Svensson e06c8009e1
Add area id to entity registry (#42221)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-10-24 21:25:28 +02:00
J. Nick Koston 4a0d18ccd8
Avoid overloading the executor with service.yaml loads (#42172) 2020-10-21 22:24:50 +02:00
Ville Skyttä 167490b71c
Complete helpers.service type hints (#40193)
* Complete helpers.service type hints

* Update homeassistant/helpers/service.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Handle None entity.supported_features
2020-09-20 12:03:58 +03:00
Franck Nijhof 181709f3d2
Allow templates in data & service parameters (making data_template & service_template obsolete) (#39210) 2020-08-24 16:21:48 +02:00
Ville Skyttä 802c556e82
State and service related type hint improvements (#38956)
* Improve type hint of service_func to register

* Add named type for state values

* Narrow some unnecessarily broad state type hints
2020-08-17 15:02:43 -04:00
Franck Nijhof 53545c984b
Log lines do not end with a full stop (#37527) 2020-07-05 23:04:19 +02:00
Ville Skyttä 0c5ca3084e
Add and fix type hints (#36501)
* Fix exceptions.Unauthorized.permission type

* Use auth.permission consts more

* Auth typing improvements

* Helpers typing improvements

* Calculate self.state only once
2020-06-06 20:34:56 +02:00
Robert Chmielowiec d21cfd869e
Fix service registration supported features check (#35718) 2020-05-23 18:11:51 +02:00
Paulus Schoutsen 87801d8aca
Minor helpers cleanup (#34786) 2020-04-28 14:31:25 -07:00
Paulus Schoutsen 26f78132ae
Fix circular import (#34441) 2020-04-19 14:41:52 -07:00
Ville Skyttä 267d98b5eb
Type hint improvements (#33082) 2020-04-17 11:33:58 -07:00
Phil Bruckner 5f5cb8bea8
Add support for simultaneous runs of Script helper - Part 2 (#32442)
* Add limit parameter to service call methods

* Break out prep part of async_call_from_config for use elsewhere

* Minor cleanup

* Fix improper use of asyncio.wait

* Fix state update

Call change listener immediately if its a callback

* Fix exception handling and logging

* Merge Script helper if_running/run_mode parameters into script_mode

- Remove background/blocking _ScriptRun subclasses which are no longer needed.

* Add queued script mode

* Disable timeout when making fully blocking script call

* Don't call change listener when restarting script

This makes restart mode behavior consistent with parallel & queue modes.

* Changes per review

- Call all script services (except script.turn_off) with no time limit.
- Fix handling of lock in _QueuedScriptRun and add comments to make it
  clearer how this code works.

* Changes per review 2

- Move cancel shielding "up" from _ScriptRun.async_run to Script.async_run
  (and apply to new style scripts only.) This makes sure Script class also
  properly handles cancellation which it wasn't doing before.
- In _ScriptRun._async_call_service_step, instead of using script.turn_off
  service, just cancel service call and let it handle the cancellation
  accordingly.

* Fix bugs

- Add missing call to change listener in Script.async_run
  in cancelled path.
- Cancel service task if ServiceRegistry.async_call cancelled.

* Revert last changes to ServiceRegistry.async_call

* Minor Script helper fixes & test improvements

- Don't log asyncio.CancelledError exceptions.
- Make change_listener a public attribute.
- Test overhaul
  - Parametrize tests.
  - Use common test functions.
  - Mock timeout so tests don't need to wait for real time to elapse.
  - Add common function for waiting for script action step.
2020-03-11 16:34:50 -07:00
Paulus Schoutsen 6a21afa2a8
Improve script validation (#32461) 2020-03-05 11:44:42 -08:00
Paulus Schoutsen 12de3f1e47 Clean up frontend services and events (#31654)
* Clean up frontend services and events

* Fix bug in core instead

* Add test that core works correctly with callback marked async funcs
2020-02-09 19:47:16 -08:00
Paulus Schoutsen e970177eeb
Use entity.async_request_call in service helper (#31454)
* Use entity.async_request_call in service helper

* Clean up semaphore handling

* Address comments

* Simplify call entity service helper

* Fix stupid rflink test
2020-02-04 15:30:15 -08:00
Paulus Schoutsen f41623ca64
Log warning when entities referenced in service call not found (#31427)
* Raise entities not found error

* Make it a warning, not an error

* Add support for MATCH_ENTITY_NONE

* Fix lint

* Fix tests
2020-02-04 14:42:07 -08:00
Paulus Schoutsen 7687ac8b91
Fix service annotations (#31402)
* Fix service annotations

* Filter area_id from service data

* Fix services not accepting entities

* Typo
2020-02-02 15:36:39 -08:00
Paulus Schoutsen d405069406
Guard for callbacks in service helper (#31339) 2020-01-31 09:32:43 +01:00
Paulus Schoutsen 01dad31adc
Fix service helper not handling sync methods (#31254)
* Fix service helper not handling sync methods

* Add legacy support for returning coroutine objects

* Fix tests

* Fix tests

* Convert demo cover to async
2020-01-29 16:27:25 -08:00
Paulus Schoutsen 0c3ffbe282
Add foundation for integration services (#30813)
* Add foundation for integration services

* Fix tests

* Remove async_get_platform

* Migrate Sonos partially to EntityPlatform.async_register_entity_service

* Tweaks

* Move other Sonos services to media player domain

* Move other Sonos services to media player domain

* Address comments

* Remove lock

* Fix typos

* Use make_entity_service_schema

* Add area extraction to async_extract_entities

Co-authored-by: Anders Melchiorsen <amelchio@nogoto.net>
2020-01-19 17:55:18 -08:00
Ville Skyttä fa4fa30461 Various string cleanups (#30435)
* Remove some unnecessary string concatenations

* Replace some simple str.formats with f-strings

* Replace some string concatenations with f-strings
2020-01-03 14:47:06 +01:00
Bas Nijholt 67c56c860d Sort imports according to PEP8 for 'homeassistant' folder (#29789)
Components are already done
2019-12-09 16:42:10 +01:00
Paulus Schoutsen 02d9ed5e36
Do not select all entities when omitting entity ID in service call (#29178)
* 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
Pascal Vizeli c1851a2d94
Cleanup coroutine threadsafe (#27080)
* Cleanup coroutine threadsafe

* fix lint

* Fix typing

* Fix tests

* Fix black
2019-10-01 16:59:06 +02:00
Jeff Irion 7090970436 Add descriptive fields to script config (#26056)
* 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
Ville Skyttä aa508b5106 Complete some incomplete type hints in helpers (#25953) 2019-08-15 08:53:25 -07:00