Commit Graph

1164 Commits (0f80d0625afae93228e9e25e686a9d89c52be2e4)

Author SHA1 Message Date
Paulus Schoutsen 689504af86
Raise if trying to store mocks in storage (#63622) 2022-01-09 21:20:21 -08:00
Erik Montnemery fc2025509e
Teach call service script action about entity registry ids (#61172) 2022-01-07 08:42:47 -08:00
Erik Montnemery 6d57dbde68
Support passing callbacks to start.async_at_start (#63473)
* Support passing callbacks to start.async_at_start

* Update homeassistant/helpers/start.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

* Fix imports

Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-01-05 18:04:09 +01:00
avee87 04606f05a4
Use built-in Jinja min and max filters in templates (#60327)
* Use built-in Jinja min and max filters in templates

* use built-in filter for global

* lint

* less generic name

* more tests

* even more tests
2022-01-04 10:07:23 +01:00
Franck Nijhof 07e034c1c6
Add iif (immediate if) template function/filter (#61428) 2021-12-21 17:25:07 +01:00
Erik Montnemery cbcd6d458e
Assert current state of script condition validation in tests (#62486) 2021-12-21 14:10:05 +01:00
Erik Montnemery 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
Brynley McDonald 26dc526234
Add slugify as a template filter (#58724) 2021-12-21 11:35:54 +01:00
J. Nick Koston a40549c1b9
Fix hw_version not updating from an entity device_info (#62254) 2021-12-18 21:53:49 -08:00
Robert Hillis 626a3f35f5
Use enums in helpers tests (#62141) 2021-12-17 11:09:24 +01:00
J. Nick Koston 04153c0075
Add hardware version to the device registry (#61650) 2021-12-16 05:16:19 -06:00
Ville Skyttä 5bf67cac66
Use RegistryEntryDisabler (#60436) 2021-12-15 23:25:40 +02:00
Ville Skyttä 7db3246de4
Make config entry disabled_by an enum (#60445)
* Make config entry disabled_by an enum

* Update homeassistant/config_entries.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-12-15 20:53:21 +01:00
epenet c05eca1c82
Remove log flooding prevention logic from discovery info (#61243)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-08 10:28:26 -10:00
epenet 9f15e7dcf4
Fix flaky tests around frame helper (#61179)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-08 10:50:56 +01:00
epenet b8b4855b8e
Prevent log flooding in frame helper (#61085)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-06 15:26:31 -08:00
Paulus Schoutsen a59ec9ca5e
Handle invalid device registry entry type (#60966)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-12-04 09:20:12 +01:00
Erik Montnemery 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
Jan Bouwhuis 3188a364e2
Add template filters pack and unpack (#60836)
* add pack and unpack template filters

* Add unpack test with offset

* use unpack_from

* Simplify unpack_from statement
2021-12-03 08:58:15 +01:00
Erik Montnemery 9f4a99fe81
Revert "Add bytes support for bitwise template operations" (#60854) 2021-12-03 08:50:29 +01:00
Erik Montnemery 0e3bc21d54
Teach state and numeric_state conditions about entity registry ids (#60841) 2021-12-02 14:55:12 -08:00
Erik Montnemery a07f75c6b0
Revert "Allow template int filter to render from a bytes based integer" (#60855) 2021-12-02 14:37:19 -08:00
Ville Skyttä 4107063a5a
Make entity registry disabled_by an enum (#60424) 2021-12-02 18:02:29 +01:00
Erik Montnemery 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
Joakim Plate c54ca7941f
Make sure entity inherit disabled device (#60469) 2021-12-01 13:59:57 -08:00
Franck Nijhof c28b45cd83
Migrate entity categories to StrEnum (#60720) 2021-12-01 13:54:36 +01:00
Jan Bouwhuis f07e676c82
Allow template int filter to render from a bytes based integer (#60452)
* Allow template int to render bytes

* re-triggering tests

* Add warning when base !=10 and rendering bytes

* re-trigger tests

* Re-trigger tests

* remove period

* Update homeassistant/helpers/template.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix logger syntax

* remove parentheses

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-30 15:01:43 +01:00
epenet ec1c52d945
Use dataclass for SsdpServiceInfo (#59931)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-29 06:10:07 -10:00
Erik Montnemery caf5ee2fab
Remove optional validation when creating conditions (#60481) 2021-11-28 14:54:07 +01:00
Erik Montnemery 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
epenet 75057949d1
Adjust async_step_discovery methods for BaseServiceInfo (#60285)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-24 19:30:02 -06:00
Ville Skyttä 9f4de8df18
Make device entry disabled by an enum (#60239) 2021-11-24 22:32:16 +01:00
Erik Montnemery 7b57033265
Correct today_at template function / filter (#60291)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-11-24 15:51:43 +01:00
Jan Bouwhuis d33457b7bc
Add bytes support for bitwise template operations (#60211)
* Add bytes support for bitwise template operations

* spelling

* Update bitwise tests

* remove try block for bytes conversion

* do not accept empty `bytes` object
2021-11-24 15:15:27 +01:00
Jan Bouwhuis d41d223033
Add UNIX timestamp detection to `as_datetime` template filter (#60126) 2021-11-24 09:51:56 +01:00
Jan Bouwhuis fa0d3a6c48
Change output template filters `timestamp_local` and `timestamp_utc` to isoformat (#60269) 2021-11-24 09:49:03 +01:00
Erik Montnemery c0d2a66609
Add stable ID to entity registry entries (#60218)
* Add UUID to entity registry entries

* Fix test
2021-11-24 09:01:35 +01:00
Erik Montnemery 24779dea3b
Bump device registry version to 1.2 (#60199) 2021-11-23 22:22:15 +01:00
Ville Skyttä 39691faccc
Use DeviceEntryType in non-typechecked code too (#58646) 2021-11-23 10:04:33 +01:00
Erik Montnemery ca20fc857f
Remove via_device links when a device is removed (#60153)
* Remove via_device links when a device is removed

* Update test
2021-11-23 09:36:03 +01:00
Erik Montnemery 39d6aba3bc
Improve startup of unavailable template entities (#59827) 2021-11-22 09:20:38 -08:00
Ville Skyttä 053c456199
Change device entry type to an StrEnum (#59940)
Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-11-22 18:14:15 +01:00
Erik Montnemery 49a27e12ad
Add support to entity registry for overriding device_class (#59985) 2021-11-22 08:38:06 -08:00
Erik Montnemery 0df2904b89
Improve some entity registry tests (#59902) 2021-11-22 10:24:37 +01:00
Marcel van der Veldt 902da4daf8
Add integration_entities template helper (#59841) 2021-11-20 14:43:31 -08:00
Erik Montnemery c557da028a
Bump entity_registry store version to 1.2 (#59912)
* Bump entity_registry store version to 1.2

* Migrate also when importing yaml

* Adjust tests

* Satisfy pylint

* Fix typing
2021-11-19 14:25:34 +01:00
rianadon ecf00a1eae
Add accumulated precipitation to unit system (#59657)
* Add accumulated precipitation to unit system

* Fix template test

* Fix typo of testing pressure instead of precipitation

* Add extra arguments so unit system test passes
2021-11-19 09:18:44 +01:00
Paulus Schoutsen 442597928e
Store: copy pending data (#59934) 2021-11-18 15:56:22 -08:00
Erik Montnemery d18c250acf
Add minor version support to storage.Store (#59882) 2021-11-18 17:15:40 +01:00
rianadon 7cc7bbb76d
Add speed to units system (#58437)
* Use speed units in unit system

* Use more obvious conversion factor for unit system speed test

* Use wind_speed instead of speed, use m/s
2021-11-18 16:08:42 +01:00
Erik Montnemery acf58111c6
Correct initial update of async_track_template_result (#59705) 2021-11-15 13:00:46 +01:00
Joakim Sørensen f596cb19fd
Handle KeyError in getuser (#59667) 2021-11-14 10:53:19 +01:00
Erik Montnemery ff837c736e
Return False from state conditions on missing attributes (#59405) 2021-11-09 11:34:18 +01:00
Chris Browet 4224cb043b
Allow overriding ensure_ascii in the "to_json" template filter (#54527)
* FIX: "ensureascii" to to_json

* fixup: parameter name
2021-11-08 15:49:10 +01:00
Erik Montnemery 470b01e4ce
Move async_migration_in_progress (#59087) 2021-11-05 10:40:56 +01:00
Erik Montnemery a62bc6b3b9
Minor tweak of cv.deprecated + cv.removed (#59095)
* Minor tweak of cv.deprecated + cv.removed

* Satisfy pylint
2021-11-04 19:12:21 +01:00
Jan Bouwhuis c3fc19915e
Mqtt fan fail deprecated options for classic speeds (#58992)
* Fail deprecated options

* new removed validator

* correct module_name - add tests

* Add test cant find module cv.removed

* module name from stack+1

* Remove error from log. Just throw.

* assert on thrown exception text

* cleanup formatting remove KeyStyleAdapter

* format the replacement_key and update test

* deprecated vs removed - add raise_if_present opt

* doc string update

* is deprecated
2021-11-04 17:54:27 +01:00
J. Nick Koston 10d6247fee
Bump to aiohttp 3.8.0 (#58974) 2021-11-04 10:07:50 -05:00
Erik Montnemery 30f7bc0f18
Use freezegun in DST tests (#58939) 2021-11-02 18:11:39 +01:00
Paulus Schoutsen 31153ac155
Move fixtures part 1 (#58902) 2021-11-01 20:47:05 -07:00
J. Nick Koston 1cd9be7538
Fix recursive limit in find_next_time_expression_time (#58914)
* Fix recursive limit in find_next_time_expression_time

* Add test case

* Update test_event.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-02 00:11:17 +01:00
Otto Winter a9c0f89c09
Fix find_next_time_expression_time (#58894)
* Better tests

* Fix find_next_time_expression_time

* Add tests for Nov 7th 2021, Chicago transtion

* Update event tests

* Update test_event.py

* small performance improvement

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-01 17:45:13 +01:00
Jesse Hills ea028e38d5
Allow configuration_url to be removed/nullified from device registry (#58564)
* Allow configuration_url to be removed from device registry

* Add test

* Check for None before stringifying and url parsing

* Add type to dict to remove mypy error on assigning None
2021-10-28 12:11:54 +02:00
Erik Montnemery abb84d9756
Serialize dates and times to isoformat (#58157) 2021-10-27 10:51:38 -07:00
Erik Montnemery bed4096430
Allow specifying a super template for async_track_template_result (#58477) 2021-10-27 16:07:17 +02:00
Franck Nijhof bf693e85b1
Revert "Add warning when entity used in template doesn't exist" (#58527) 2021-10-27 13:53:26 +02:00
Petro31 11034a93c3
Add average template function and filter (#57727) 2021-10-26 22:43:45 +02:00
Joakim Sørensen d16304a201
Allow homeassistant prefix for device info configuration url (#58414)
* Allow panel prefix for device info configuration url

* Add to add-ons

* Use homeassistant as the prefix

* Update homeassistant/components/hassio/__init__.py

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-10-26 10:34:02 +02:00
avee87 d9b87ee5c5
Add warning when entity used in template doesn't exist (#57316) 2021-10-22 20:09:54 +02:00
Raman Gupta e5255cf21f
Add area_entities and area_devices template functions/filters (#55228) 2021-10-22 19:59:01 +02:00
Petro31 806dc51125
Add datetime_today template method (#57435) 2021-10-22 19:51:22 +02:00
Erik Montnemery df1154395e
Revert "Swap order of int template helper kwargs (#57729)" (#58015)
This reverts commit f8dbcb953c.
2021-10-21 15:03:33 +02:00
Erik Montnemery 7c1ba8be3d
Don't expose config or diagnostic entities to Amazon Alexa by default (#57770) 2021-10-15 09:09:24 -07:00
Erik Montnemery 2b37943355
Don't add indirectly referenced config entities to service calls (#57671) 2021-10-15 08:46:43 -07:00
Petro31 f8dbcb953c
Swap order of int template helper kwargs (#57729)
* swap order of int kwargs

* Add binary and kwargless base tests
2021-10-15 13:04:26 +02:00
Erik Montnemery e27e4c3561
Add support for device configuration URL (#57539)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-10-14 11:16:56 -07:00
Erik Montnemery 4b3d423767
Add config and diagnostic entities (#57528)
* Add config entity concept

* Rename is_config_entity to entity_category

* Add test

* Add 'diagnostic' entity category
2021-10-14 10:04:26 +02:00
Erik Montnemery 838f79be3d
Update tests searching for areas referenced in automations (#57558) 2021-10-13 13:27:56 -07:00
J. Nick Koston b86e19143d
Prevent event loop delay / instability from discovery (#57463) 2021-10-13 08:37:14 -07:00
Erik Montnemery 007af4a7aa
Search for areas, devices and entities in script choose actions (#57554) 2021-10-12 08:49:07 -07:00
Erik Montnemery 7acb1b6eb9
Override the jinja2 int filter (#57470) 2021-10-12 00:12:42 +02:00
Franck Nijhof 13db867c1d
Move attribution attribute to Entity base class (#57492) 2021-10-11 23:15:32 +02:00
Paulus Schoutsen a4d9019ffc
Refactor persistent notification to no longer route all data via a service (#57157)
* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 12:58:00 +02:00
Erik Montnemery 6954614e62
Warn if total_increasing sensor has negative states (#56564) 2021-09-30 07:49:16 -07:00
Erik Montnemery ef13e473cf
Warn if template functions fail and no default is specified (#56453)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-09-29 20:16:02 +02:00
Erik Montnemery 14a1bb423c
Add is_number template filter and function (#56705) 2021-09-27 10:47:57 +02:00
J. Nick Koston eb98ac9415
Allow IntegrationNotFound when checking config in safe mode (#56283)
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
2021-09-17 22:25:50 -07:00
Paulus Schoutsen 8a611eb640
Fix singleton not working with falsey values (#56072) 2021-09-11 12:02:01 -07:00
Chris Browet 5a2bcd2763
ADD: generalize regex_findall (#54584) 2021-09-05 12:41:39 +02:00
Erik Montnemery bfd799dc04
Use hass_client_no_auth test fixture in integrations s-x (#55585) 2021-09-02 14:50:10 +02:00
Raman Gupta 4d98a7e156
Allow device_id template function to use device name as input (#55474) 2021-08-31 14:56:47 +02:00
Raman Gupta 1d1b5ab345
Fix area_id and area_name template functions (#55470) 2021-08-30 13:09:41 -07:00
Raman Gupta 2f7a7b0309
Add template functions to get area_id and area_name (#54248)
* Add template function to get area_id

* fix int bug

* Prefer area name lookup

* remove unnecessary checks

* fix import

* Add area_name function

* change behavior to fail in ambiguous scenarios

* Revert lotto winning exception checking

* review comments

* try except else
2021-08-25 15:16:51 -04:00
Børge Nordli 0d654fa6b3
Extract attribute names out of vol.Optional when validating entity service schema (#55157) 2021-08-25 13:00:11 +02:00
Raman Gupta 036e99e91e
Allow integrations to define trigger platforms with a subtype (#54861) 2021-08-19 21:43:04 -07:00
Richard T. Schaefer 3184f0697f
Add Save Persistent States service (#53881) 2021-08-10 00:38:56 +02:00
Paulus Schoutsen 952d11cb03
Ensure internal/external URL have no path (#54304)
* Ensure internal/external URL have no path

* Fix comment typo

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-08-09 09:38:09 +02:00
Joakim Sørensen 3f2e18fe17
Add user to homeassistant system health (#53902) 2021-08-03 11:58:27 +02:00
Robert Svensson c6213b36ad
Only disable a device if all associated config entries are disabled (#53681) 2021-07-29 12:08:53 -07:00
Franck Nijhof 1968b95829
Add currency core configuration (#53541)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-07-28 08:55:58 +02:00
Raman Gupta 73bc0267e9
Add DeviceRegistry template functions (#53131) 2021-07-27 18:55:55 -04:00
Raman Gupta 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
Eduard van Valkenburg 779ef3c8e1
Add timedelta option for async_call_later (#50164) 2021-06-12 13:14:35 +02:00
Erik Montnemery b01b33c304
Add trigger condition (#51710)
* Add trigger condition

* Tweaks, add tests
2021-06-11 15:05:57 +02:00
Ville Skyttä 7d03b02192
Spelling fixes (#51642) 2021-06-11 13:35:03 +02:00
Franck Nijhof 4c51299dcc
Add easy converting string timestamps/dates to datetime objects in templates (#51576) 2021-06-07 15:02:15 +02:00
Franck Nijhof f35929ba63
Allow referencing sensor entities for before/after in time conditions (#51444)
* Allow referencing sensor entities for before/after in time conditions

* Fix typo in variable naming

* Improve test coverage
2021-06-07 14:50:31 +02:00
Franck Nijhof 05241a7a68
Allow number/sensor entities in numeric state conditions/triggers (#51439) 2021-06-04 18:14:48 +02:00
Paulus Schoutsen ede7932a57
Protect our user agent (#51486)
* Protect our user agent

* Fix expected error
2021-06-04 09:14:18 -07:00
Paulus Schoutsen ee2c950716
Merge system options into pref properties (#51347)
* Make system options future proof

* Update tests

* Add types
2021-06-01 22:34:31 +02:00
Franck Nijhof c5dc99c052
Fix time condition microsecond offset when using input helpers (#51337) 2021-06-01 17:57:23 +02:00
Paulus Schoutsen 45e1473f83
Improve config validation for key_value_schemas (#49429) 2021-06-01 11:23:59 +02:00
Paulus Schoutsen f472219c68
Set up cloud semi-dependencies at start (#51313) 2021-06-01 01:35:31 +02:00
Paulus Schoutsen 4821484d2c
Add system option to disable polling (#51299) 2021-05-31 15:36:40 -07:00
Raman Gupta 58e37435b3
Make more max lengths constants and add additional MaxLengthExceeded checks (#50337)
* Add more MaxLengthExceeded checks

* remove some validations to reduce performance impact

* check length of generated entity ID

* dont check entity ID twice and use single context id length constant

* fix test

* add missing test
2021-05-25 19:58:01 +02:00
Franck Nijhof c5383219f1
Remove stale debug statements from tests (#51059) 2021-05-25 11:52:20 +02:00
Erik Montnemery 1ea0d8ae02
Correct trace of condition actions (#50800) 2021-05-17 16:54:17 -07:00
Joakim Sørensen 2f10f59717
Block custom integrations with missing or invalid version (#49916) 2021-05-17 15:48:41 +02:00
Erik Montnemery b35f229674
Include _StopScript.__cause__ in trace (#50441)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-11 22:27:11 -07:00
J. Nick Koston bf2d40adfe
Migrate from pytz to python-dateutil (#49643)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-07 22:46:26 -07:00
Ville Skyttä 77d5244577
Use device registry CONNECTION_* constants (#49923) 2021-04-30 23:58:50 +02:00
Franck Nijhof c68b259bd3
Cleanup of unused connection_class logic (#49865)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
2021-04-29 23:12:58 +02:00
Erik Montnemery d2fd504442
Limit precision when stringifying float states (#48822)
* Limit precision when stringifying float states

* Add test

* Fix typing

* Move StateType

* Update

* Move conversion to entity helper

* Address review comments

* Tweak precision

* Tweak

* Make _stringify_state an instance method
2021-04-27 21:48:24 +02:00
Ville Skyttä 153d6e891e
Use config_entries.SOURCE_* constants (#49631) 2021-04-25 11:27:40 +02:00
Ville Skyttä a396619251
Use disabled_by constants (#49584)
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-04-23 09:56:42 +02:00
Erik Montnemery d28b959a09
Improve sun condition trace (#49551) 2021-04-22 16:46:27 -07:00
J. Nick Koston f96a6e878f
Ensure restore state is not written after the stop event (#49329)
If everything lined up, the states could be written
while Home Assistant is shutting down after the stop
event because the interval tracker was not canceled on
the stop event.
2021-04-17 09:03:18 +02:00
Mike Degatano 236d274351
Add `search` and `match` as Jinja tests (#49229) 2021-04-15 20:13:27 +02:00
J. Nick Koston 8bee25c938
Fix stop listener memory leak in DataUpdateCoordinator on retry (#49186)
* Fix stop listener leak in DataUpdateCoordinator

When an integration retries setup it will add a new stop listener

* Skip scheduled refreshes when hass is stopping

* Update homeassistant/helpers/update_coordinator.py

* ensure manual refresh after stop
2021-04-14 12:16:59 -10:00
Tobias Sauerwein 9d4ad1821e
Fix logic of entity id extraction (#49164)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-04-14 14:12:26 +02:00
J. Nick Koston 44beff31c2
Cancel config entry retry, platform retry, and polling at the stop event (#49138) 2021-04-13 16:16:26 -10:00
Raman Gupta 769923e8dd
Raise exception for invalid call to DeviceRegistry.async_get_or_create (#49038)
* Raise exception instead of returning None for DeviceRegistry.async_get_or_create

* fix entity_platform logic
2021-04-13 14:18:51 +02:00
J. Nick Koston 53853f035d
Prevent calling stop or restart services during db upgrade (#49098) 2021-04-12 17:18:38 -07:00
Erik Montnemery 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
Franck Nijhof a610076001 Support min()/max() as template function (#48996) 2021-04-12 10:02:04 +02:00
Erik Montnemery 7e4be921a8
Add helper to get an entity's supported features (#48825)
* Add helper to check entity's supported features

* Move get_supported_features to helpers/entity.py, add tests

* Fix error handling and improve tests
2021-04-10 08:19:16 +02:00
Jason 7cc857a298
Add custom JSONEncoder for subscribe_trigger WS endpoint (#48664) 2021-04-09 20:47:10 -07:00
Erik Montnemery 16196e2e16
Don't log template errors from developer tool (#48933) 2021-04-09 12:10:02 -07:00
Marc Mueller 8e2b5b36b5
Bump pyupgrade to 2.12.0 (#48943) 2021-04-09 09:58:27 -07:00
Erik Montnemery 9f5db2ce3f
Improve warnings on undefined template errors (#48713) 2021-04-06 12:11:42 -07:00
J. Nick Koston b5c679f3d0
Apply ConfigEntryNotReady improvements to PlatformNotReady (#48665)
* Apply ConfigEntryNotReady improvements to PlatformNotReady

- Limit log spam #47201
- Log exception reason #48449
- Prevent startup blockage #48660

* coverage
2021-04-04 12:31:58 +02:00
FMKaiba 09eb74fd9d
Upgrade Astral to 2.2 (#48573) 2021-04-02 00:29:08 +02:00
Franck Nijhof 4e3c12883e
Allow templatable service target to support scripts (#48600) 2021-04-01 13:10:01 -07:00
Erik Montnemery 9f481e1642
Include script script_execution in script and automation traces (#48576) 2021-04-01 09:42:23 -07:00
J. Nick Koston a851bff95a
Create async_config_entry_first_refresh to reduce coordinator boilerplate (#48451) 2021-03-29 12:51:39 -10:00
Erik Montnemery 0c6a1c29ec
Fix broken trace tests (#48458) 2021-03-29 10:06:22 +02:00
Franck Nijhof ad13a9295e
Merge multiple context managers in tests (#48146) 2021-03-27 09:17:15 +01:00
J. Nick Koston 79af18a8ab
Bump httpx to 0.17.1 (#48388)
* Bump httpx to 0.17.1

* git add

* typing

* add test

* tweak
2021-03-27 09:02:01 +01:00
Paulus Schoutsen 63e3012380
Fix script default trace (#48390) 2021-03-26 23:56:40 -07:00
Franck Nijhof f0e5e616a7
Fix device discovery of OAuth2 config flows (#48326) 2021-03-25 10:35:01 -07:00
Erik Montnemery 272dffc384
Improve script tracing (#48100)
* Improve script tracing

* Fix test
2021-03-22 13:15:45 +01:00
Erik Montnemery 73e546e2b8
Improve condition trace tests (#48152) 2021-03-21 22:09:59 -07:00
Franck Nijhof 08870690a6
Fix a collection of tests with missing asserts (#48127)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-03-20 17:23:55 +01:00
Erik Montnemery 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
Franck Nijhof 5a2b5fe7c5
Yoda assertion style removed is (#48142) 2021-03-20 13:55:10 +01:00
Franck Nijhof 8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI (#48111) 2021-03-19 13:41:09 +01:00
Erik Montnemery 7b717bc437
Correct trace for repeat script actions (#48031) 2021-03-18 13:14:06 -07: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
Alan Tse f86e7535e0
Add location details to deprecation warning (#47155) 2021-03-16 21:16:07 +01:00
Erik Montnemery 389891d13d
Improve JSONEncoder test coverage (#47935) 2021-03-16 17:12:51 +01:00
Erik Montnemery 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 <balloob@gmail.com>
2021-03-16 08:49:16 +01:00
Paulus Schoutsen ff94e920e4
Do not use AsyncTrackStates (#47255) 2021-03-11 23:18:09 -08:00
Erik Montnemery 704000c049
Add support for breakpoints in scripts (#47632) 2021-03-09 21:23:11 -08:00
Erik Montnemery b3fecb1c95
Update tests t-z to use async_get() instead of async_get_registry() (#47655) 2021-03-09 14:25:03 +01:00
Paulus Schoutsen 67effbc8c4
Config flow to allow marking itself as confirm only (#47607) 2021-03-08 10:54:51 -08:00
Erik Montnemery 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 Montnemery 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
Franck Nijhof 7a8b7224c8
Don't raise on known non-matching states in numeric state condition (#47378) 2021-03-04 13:09:08 -08:00
Erik Montnemery 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
Erik Montnemery 504e5b77ca
Improve behaviour when disabling or enabling config entries (#47301) 2021-03-03 10:12:37 -08:00
Paulus Schoutsen 557ec374f1
Convert discovery helper to use dispatcher (#47008) 2021-02-24 13:37:31 -08:00
Joakim Sørensen 11a89bc3ac
Add addon selector (#46789) 2021-02-24 17:02:48 +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
Anders Melchiorsen d61d39de08
Handle ConditionError with multiple entity_id for state/numeric_state (#46855) 2021-02-22 08:11:59 +01:00
Anders Melchiorsen d33a1a5ff8
Refine printing of ConditionError (#46838)
* Refine printing of ConditionError

* Improve coverage

* name -> type
2021-02-21 14:54:36 +01:00
Erik Montnemery 5e26bda52d
Add support for disabling config entries (#46779) 2021-02-20 19:21:39 -08:00
Erik Montnemery 2d70806035
Add support for "alias" in script steps device, device_condition, and conditions (#46647)
Co-authored-by: Donnie <donniekarnsinsb@hotmail.com>
2021-02-20 19:21:09 -08:00
Erik Montnemery 54cf954353
Add device_entities template function/filter (#46406) 2021-02-19 21:50:59 -08:00
J. Nick Koston bb7e4d7daa
Implement suggested_area in the device registry (#45940)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-02-19 19:34:33 -10:00
Anders Melchiorsen bfea7d0baa
Raise ConditionError for and/or/not errors (#46767) 2021-02-19 13:15:30 +01:00
Anders Melchiorsen e7e3e09063
Raise ConditionError for zone errors (#46253)
* Raise ConditionError for zone errors

* Do not test missing state

* Handle multiple entities/zones
2021-02-19 13:14:47 +01:00
Erik Montnemery f1714dd541
Make some Area and EntityRegistry member functions callbacks (#46433) 2021-02-12 17:00:35 +01:00
Erik Montnemery ed31cc363b
Wait for registries to load at startup (#46265)
* Wait for registries to load at startup

* Don't decorate new functions with @bind_hass

* Fix typing errors in zwave_js

* Load registries in async_test_home_assistant

* Tweak

* Typo

* Tweak

* Explicitly silence mypy errors

* Fix tests

* Fix more tests

* Fix test

* Improve docstring

* Wait for registries to load
2021-02-11 17:36:19 +01:00
Anders Melchiorsen 888c9e120d
Raise ConditionError for time errors (#46250) 2021-02-11 17:29:17 +01:00
Anders Melchiorsen 1f5fb8f28a
Raise ConditionError for template errors (#46245) 2021-02-11 10:30:09 +01:00
Paulus Schoutsen 538df17a28
Restore Google/Alexa extra significant change checks (#46335) 2021-02-10 16:30:29 +01:00
Franck Nijhof 22389043eb
Remove base_url fallback (#46316) 2021-02-10 14:31:11 +01:00
Erik Montnemery bfd5a62bad
Fix typo (#46321) 2021-02-10 11:31:51 +01:00
Erik Montnemery 78b7fbf7b1
Fix race in EntityRegistry.async_device_modified (#46319) 2021-02-10 10:50:44 +01:00
Anders Melchiorsen f27066e773
Raise ConditionError for state errors (#46244) 2021-02-09 09:46:36 +01:00
Erik Montnemery 58b4a91a5b
Test that variables are passed to wait_for_trigger script action (#46221) 2021-02-09 00:34:18 +01:00
Anders Melchiorsen 48002f47f4
Use caplog fixture for log capturing (#46214) 2021-02-08 14:33:57 +01:00
Matteo Agnoletto eaa2d371a7
Add select selector for blueprints (#45803)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-02-08 14:03:26 +01:00
Anders Melchiorsen b9b1caf4d7
Raise ConditionError for numeric_state errors (#45923) 2021-02-08 10:47:57 +01:00
Paulus Schoutsen 9e07910ab0
Mark entities as unavailable when they are removed but are still registered (#45528)
* Mark entities as unavailable when they are removed but are still registered

* Add sync_entity_lifecycle to collection helper

* Remove debug print

* Lint

* Fix tests

* Fix tests

* Update zha

* Update zone

* Fix tests

* Update hyperion

* Update rfxtrx

* Fix tests

* Pass force_remove=True from integrations

Co-authored-by: Erik <erik@montnemery.com>
2021-02-08 10:45:46 +01:00
J. Nick Koston a1662b3bb9
Restore the device id after deleting and re-adding an integration (#45348) 2021-01-27 17:10:57 +01:00
CtrlZvi 1433cdaa12
Prefer shorter keys for intent matching (#43672)
When using fuzzy matching to match entity names for intents, whichever
entity is first is preferred in the case of equal matches. This leads
to situations where entities with similar names (such as entities named
for their area and then specific area location) may be used when the
whole area is wanted.

I ran into this with the my Phillips Hue lights. I have each individual
light named such that its room is the first part of the name, and its
location within the room after. So my living room has:
Living Room West
Living Room Northwest
Living Room North
Living Room Northeast

I then have a group for the whole room:
Living Room

Because the group is the last of the entities, trying to adjust the
whole room only activates one light, because all of the lights match
equally well.

By preferring the shortest of equal matches, we prefer keys that have
the least amount of extra information, causing "Living Room" to match
the group instead of an individual light.
2021-01-27 12:16:19 +01:00
Thomas Lovén 06ade6129c
Add selectors for text and arbitrary objects (#45112)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-01-27 09:20:19 +01:00
Joakim Sørensen b1c2cde40b
Changes to filename and path validation (#45529)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-01-26 15:53:21 +01:00
Paulus Schoutsen d082be787f
Add "significant change" base (#45555) 2021-01-26 14:13:27 +01:00
Shay Levy f117ddc6fa
Stop update_coordinator schedule refresh when HA is stopping (#45338)
* Stop update_coordinator schedule refresh when HA is stopping

* Add unittests

* Fix event type
2021-01-22 00:23:50 +01:00
J. Nick Koston 243014bff1
Fix test_wait_template_with_utcnow (#45356) 2021-01-20 23:56:00 +01:00
J. Nick Koston a7741be9bb
Wait for all triggers when one fails to attach (#45361) 2021-01-20 22:13:21 +01:00
J. Nick Koston da677f7d5a
Add support for discovery via DHCP (#45087)
* Add support for discovery via DHCP

* additional tesla ouis

* merge tests

* dhcp test

* merge requirements test

* dhcp test

* dhcp discovery

* dhcp discovery

* pylint

* pylint

* pylint

* fix

* Add matching tests

* 100% cover

* cleanup

* fix codespell

* Update exception handling

* remove unneeded comment

* fix options handling exception

* fix options handling exception
2021-01-14 09:09:08 +01:00
Paulus Schoutsen e83ced6737
Add name to ignored entries (#45051)
* Add name to ignored entries

* Fix test
2021-01-12 09:26:20 +01:00
J. Nick Koston 7c93a11aba
Fix wait_template incorrectly matching falsey values (#44938) 2021-01-08 13:07:50 +01:00
Ville Skyttä 2fb3be50ab
Make DeviceRegistry.async_get_device connections arg optional (#44897)
* Make async_get_device connections Optional, default None

* Remove unnecessary async_get_device connections arg usages

Some of these were using an incorrect collection type, which didn't
cause issues mostly just due to luck.
2021-01-07 13:49:45 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
J. Nick Koston 2ef25e7414
Fix script wait templates with now/utcnow (#44717) 2021-01-01 13:03:34 +01:00
Allen Porter eb07282e9b
Add debug logging for failed OAuth token refreshes to help users diagnose (#44637) 2020-12-30 10:03:27 +01:00
Paulus Schoutsen 594e905742
Remove invalidation_version from deprecated (#44156)
* Remove invalidation_version from deprecated. We don't follow up and just hurts releases

* Revert change to ZHA
2020-12-12 22:24:16 +01:00
J. Nick Koston dd0afc3b66
Create httpx helper to wrap a shared httpx.AsyncClient (#43877)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-12-09 17:18:57 +01:00
Paulus Schoutsen ac2af69d26
Fix extracting entity and device IDs from scripts (#44048)
* Fix extracting entity and device IDs from scripts

* Fix extracting from data_template
2020-12-08 13:06:29 +01:00
Erik Montnemery 30baf333c3
Improve handling of disabled devices (#43864) 2020-12-02 21:20:14 +01:00
Chris Talkington 891edec73b
Add test for is_internal_request (#43841) 2020-12-02 10:12:48 +01:00
Bram Kragten d93687b5ac
Update area and target selectors add sequence selector (#43831)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-12-02 09:30:49 +01:00
Paulus Schoutsen 1c9c99571e
Use !input instead of !placeholder (#43820)
* Use !input instead of !placeholder

* Update input name

* Lint

* Move tests around
2020-12-01 18:21:36 +01:00
Franck Nijhof b1c11eaaf8
Fix config validation tests for upcoming beta (#43811) 2020-12-01 17:07:28 +01:00
Paulus Schoutsen 69710cb664
Base area IDs on initial name (#43804) 2020-12-01 12:45:56 +01:00
Paulus Schoutsen cf5be049b3
Warn when referencing missing devices/areas (#43787) 2020-12-01 08:01:27 +01:00
Paulus Schoutsen a5c79a1f84
Add support for device class in target selector (#43768) 2020-11-30 23:35:24 +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
Erik Montnemery a5e5c5c7e6
Exclude disabled entities from async_entries_for_device (#43665) 2020-11-27 09:03:44 +01:00
Paulus Schoutsen f9fa24950b
OAuth2 to use current request header (#43668) 2020-11-27 08:55:34 +01:00
Paulus Schoutsen e1de36fda8
Fix check config (#43663) 2020-11-26 22:25:21 +01:00
Erik Montnemery dc8364fd3a
Support disabling devices (#43293) 2020-11-26 16:45:02 +01:00
Bram Kragten 4aa181416c
Add area selector, remove date selector (#43658)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-11-26 15:44:25 +01:00
Bram Kragten 3767af14f3
Add more selectors (#43639) 2020-11-25 20:03:56 +01:00
Paulus Schoutsen 1de2554f70
Tweak template digit detection (#43621) 2020-11-25 16:10:33 +01:00
Paulus Schoutsen b3be708db6
Add default config if not there (#43321)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2020-11-25 15:10:04 +01:00
Paulus Schoutsen 390668e192
Check config to use config platforms (#43407) 2020-11-19 22:05:36 +01:00
Bram Kragten 5dcbb634f6
Fix selector to return the selector type (#43395) 2020-11-19 16:48:43 +01:00
Paulus Schoutsen bae026a6fe
Add support for selectors in services.yaml (#43162)
* Add support for selectors in services.yaml

* Add base schema validation
2020-11-13 22:53:55 +01:00
Paulus Schoutsen 0a717f313e
Improve entity domain validator (#43164) 2020-11-13 13:31:43 +01:00
Paulus Schoutsen 8dbd54bed1
Disable parsing scientific/complex number notation in template type (#43170) 2020-11-13 13:22:29 +01:00
Erik Montnemery 8a7febcfbe
Improve restore of deleted devices (#42703)
* Improve restore of deleted devices

* Simplify
2020-11-10 22:14:39 +01:00
J. Nick Koston c7f35b20fb
Make all translations cacheable (#42892) 2020-11-09 22:36:45 +01:00
Paulus Schoutsen aec191b558
Support datetime sensor in time trigger (#42899) 2020-11-09 14:50:54 +01:00
Anders Melchiorsen 650c57db5b
Fix async_track_utc_time_change firing too early (#42176) 2020-11-05 16:34:56 +01:00
Paulus Schoutsen 0fb587727c
Add initial blueprint support (#42469)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2020-11-02 15:00:13 +01:00
Paulus Schoutsen 1844e30858
Add support for manual updating a data coordinator (#42746) 2020-11-02 09:54:08 +01:00
J. Nick Koston 2bbd2a6e70
Reduce complexity of storage writes (#42576)
* Reduce complexity of storage writes

* add test

* stop hass

* workaround bad test
2020-10-29 22:35:51 -05:00
J. Nick Koston 7f1683c731
Remove legacy template extract_entities (#42601) 2020-10-30 00:06:08 +01:00
J. Nick Koston 8eb89cdb46
Fix flapping event template test (#42614) 2020-10-30 00:05:55 +01:00
J. Nick Koston c8f00a7b38
Gather all collection listeners and changes at the same time (#42497) 2020-10-29 10:06:55 +01:00
J. Nick Koston 94219c2266
Ensure the oauth2 token is refreshed before it is expired (#42487)
The current implementation assumed clocks were in sync and did
not account for the time it took to refresh the token.  A 20
second buffer has been added to ensure that the token is refreshed
before it expires as OAuth2Session.valid_token would assume the
token was still good even though the remote would reject it
and would not refresh because it was not time yet.
2020-10-28 07:47:54 -05:00
Paulus Schoutsen e21e28e49f
Fix string representation of template result wrappers (#42494) 2020-10-28 09:11:08 +01:00
Paulus Schoutsen d4efa938dd
Improve mqtt test (#42490) 2020-10-27 23:22:59 +01:00
Paulus Schoutsen 711b7d4605
Make result wrappers more robust (#42488) 2020-10-27 22:51:58 +01:00
J. Nick Koston 5ca4b4cd0f
Set the translations cache under the lock (#42470) 2020-10-27 22:02:38 +01:00
Franck Nijhof 45aba9bdf2
Allow skip parsing template result (#42401) 2020-10-26 16:01:09 +01:00
Paulus Schoutsen bba770b411
Fix CI (#42397) 2020-10-26 13:36:03 +01:00
Paulus Schoutsen e552c9ba96
Store original result on template results (#42391)
* Store original result on template results

* Fix shell command test
2020-10-26 11:30:58 +01:00
J. Nick Koston ce2c388c09
Ensure config entry platforms are excluded from reload (#42367) 2020-10-25 23:53:31 +01: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
Anders Melchiorsen cb0c937b3e
Refresh now() templates on second=0 (#42225) 2020-10-23 00:11:02 +02:00
J. Nick Koston df2ede6522
Fix state overwrite race condition where two platforms request the same entity_id (#42151)
* Fix state overwrite race condition where two platforms request the same entity id

* fix test

* create reservations instead

* revert

* cannot use __slots__ because we patch async_all
2020-10-21 17:01:51 +02:00
Paulus Schoutsen 8d4675713a
Fix event test (#42078) 2020-10-19 16:50:46 +02:00
J. Nick Koston 31c21126a8
Implement time tracking in templates (#41147)
Co-authored-by: Anders Melchiorsen <amelchio@nogoto.net>
2020-10-19 11:02:43 +02:00
J. Nick Koston 77b95ae8a1
Reduce domain states rate limit to 1 per second (#42004) 2020-10-19 10:18:25 +02:00
J. Nick Koston 3a9b2392f8
Suppress domain and all listeners during template rate limit (#42005) 2020-10-19 10:17:51 +02:00
Paulus Schoutsen 6ab9b7355f
Add tests for singleton decorator (#42055) 2020-10-18 22:41:22 +02:00
Philip Allgaier dde6305549
Cleanup unused loggers (components N-Z + tests) (#41982) 2020-10-16 21:24:08 -05:00
J. Nick Koston 53a1d92f2b
Permit event trackers to accept an empty list of entities or domains (#41857) 2020-10-15 09:26:51 +02:00
J. Nick Koston b897ca7260
Ensure all template errors are caught and the websocket api reports them (#41719) 2020-10-12 16:38:24 +02:00
Raman Gupta d3734aae9d
Allow custom_serializer to recognize cv.string and cv.boolean to make config schema more reusable (#41532) 2020-10-09 09:36:54 +02:00
J. Nick Koston 5ebf5996f1
Predetermine listener type for script change listeners (#41510) 2020-10-09 08:41:12 +02:00
J. Nick Koston 0b3bea0282
Use async_add_hass_job for debouncer (#41449) 2020-10-09 08:40:36 +02:00
Erik Montnemery 343e5d64b8
Add MQTT integration discovery (#41332)
* Add MQTT integration discovery

* Add script/hassfest/mqtt.py

* Unsubscribe if config entry exists

* Add homeassistant/generated/mqtt.py

* Fix bad loop

* Improve tests

* Improve tests

* Apply suggestions from code review

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>

* Prevent initiating multiple config flows

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
2020-10-07 18:30:51 +02:00
Franck Nijhof ee914366a8
Add native Python types support to templates (#41227)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-10-07 00:05:52 +02:00
J. Nick Koston 2fabd4edb8
Prevent collecting states already referenced by domain or all (#41308)
The template engine would collect all the states in
a domain or all states while iterating even though
they were already included in all or the domain

This lead to the rate limit not being applied to
templates that iterated all states that also
accessed a collectable property because the engine
incorrectly believed they were specifically
referenced.
2020-10-06 07:25:05 +02:00
J. Nick Koston f50976a0b3
Switch to asyncio.wait for slow update warning implementation (#41184) 2020-10-05 15:28:15 +02:00
Paulus Schoutsen 8ae3f575dd
Add extended validation for script repeat/choose (#41265) 2020-10-05 14:03:48 +02:00
Paulus Schoutsen fe2c16dc29
Allow any value when triggering on state attribute (#41261) 2020-10-05 12:53:12 +02:00
J. Nick Koston 51da605b9f
Remove manual rate_limit control directive from templates (#41225)
Increase default rate limit for all states and entire
domain states to one minute

Ensure specifically referenced entities are excluded from
the rate limit
2020-10-04 22:40:04 +02:00
Franck Nijhof 38d132addd
Fix referenced entity extraction when service call entity contains a template (#41107) 2020-10-03 20:55:59 +02:00
springstan a2c3c33b22
Use core GitHub URL in all files (#41089) 2020-10-03 00:04:11 +02:00
J. Nick Koston b45215f1d2
Implement template rate_limit directive (#40667) 2020-10-01 21:39:44 +02:00
springstan c7ebfdb403
Use single_instance_allowed for webhook config flows (#40965) 2020-10-01 20:44:13 +02:00
J. Nick Koston 7285c7806f
Seperate state change tracking from async_track_template_result into async_track_state_change_filtered (#40803) 2020-10-01 10:19:20 +02:00
J. Nick Koston 9ccebdb8d5
Refactor group to extend domains that can be grouped (#40607)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-30 09:13:53 -05:00
J. Nick Koston e564af0b5b
Improve performance of accessing template state (#40323)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-28 10:35:12 -05:00
J. Nick Koston e08ee282ab
Abort execution of template renders that overwhelm the system (#40647) 2020-09-28 14:43:22 +02:00
J. Nick Koston 57b7559832
Ensure all jinja2 errors are trapped and displayed in the developer tools (#40624)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-09-26 17:03:32 -05:00
J. Nick Koston 3261a904da
Reduce the number of template re-renders when we are only counting states (#40272) 2020-09-26 16:29:49 -05:00
J. Nick Koston 35533407fe
Improve performance of counting and iterating states in templates (#40250)
Co-authored-by: Anders Melchiorsen <amelchio@nogoto.net>
2020-09-26 11:36:47 -05:00
Franck Nijhof c64eec3238
Add bare hostname as valid known hostname in get_url helper (#40510) 2020-09-26 09:36:03 +02:00
Ville Skyttä 5e90a4d000
Use more state attribute name constants (#40428) 2020-09-21 23:03:39 +02:00
J. Nick Koston e9abb357e4
Log template listeners when debug logging is on (#40180) 2020-09-17 14:45:30 -05:00
Franck Nijhof cd26384634
Fix entity extraction from Template conditions (#40034) 2020-09-13 22:05:45 +02:00
Jakob Schlyter 9b49ca3820
Add template filter timedelta_seconds to create a timedelta from seconds (#39608) 2020-09-11 15:07:31 -05:00
J. Nick Koston 741487a1fc
Return the listeners with the template result for the websocket api (#39925) 2020-09-11 13:18:40 -05:00
Thomas Lovén f59e727f16
Set variable values in scripts (#39915)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-09-11 13:16:25 +02:00
J. Nick Koston e208aac834
Add async_track_state_removed_domain to allow tracking when a state is removed from a domain (#39859)
when a state is removed from a domain
2020-09-11 13:03:31 +02:00
Franck Nijhof 101b5b3b35
Accept known hosts for get_url for OAuth (#39936) 2020-09-11 13:00:00 +02:00
Paulus Schoutsen 5117a16841
Extract variable rendering (#39934) 2020-09-11 12:24:16 +02:00
J. Nick Koston fb31b04c08
Increase template test coverage. (#39908) 2020-09-10 20:43:45 +02:00
Joakim Sørensen 0cce35b23e
Add exception for NoURLAvailableError in OAuth2FlowHandler (#39845)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-09-10 14:52:49 +02:00
Aidan Timson 6f43285a28
Force token expires_in to float (#39489) 2020-09-07 21:26:58 +02:00
J. Nick Koston 5e83feeabf
Increase test coverage for template sandbox (#39750) 2020-09-07 17:33:22 +02:00
J. Nick Koston 90d574e521
Ensure static templates are still called back on first refresh (#39753) 2020-09-07 17:19:39 +02:00
Erik Montnemery 863b63d75e
Fix handling of device registry defaults (#39688) 2020-09-06 21:08:50 -05:00
Franck Nijhof 1ec3446c56
State condition can also accept an input_* Entity ID as state value (#39691) 2020-09-07 00:36:01 +02:00
Franck Nijhof 878347243d
Numeric state condition can also accept input_number entity ID (#39680) 2020-09-06 20:04:07 +02:00
Franck Nijhof a3c45a6f89
Add shorthand notation for Template conditions (#39705) 2020-09-06 16:55:06 +02:00
Franck Nijhof da9b077c11
Time condition can also accept an input_datetime Entity ID (#39676) 2020-09-06 16:06:09 +02:00
springstan d2b1918e9c
Drop UNIT_ prefix for percentage constant (#39383) 2020-09-05 21:09:14 +02:00
J. Nick Koston a096c20930
Fix missing assert in template test (#39648) 2020-09-04 16:28:56 +02:00
J. Nick Koston 35e84d0427
Add as_local convenience function to jinja templates (#39618) 2020-09-03 14:35:16 -05:00
J. Nick Koston a778690b64
Support reloading the group notify platform (#39511) 2020-09-03 00:12:07 +02:00
Phil Bruckner 4486251382
Add max_exceeded log level option to automations & scripts (#39448) 2020-09-02 11:05:14 +02:00
J. Nick Koston e55a014e94
Undecorate RenderInfo result property (#39108) 2020-09-02 10:35:15 +02:00
J. Nick Koston a77e09b2c2
Make async_track_template_result track multiple templates (#39371)
* Make async_track_template_result track multiple templates

Combine template entity updates to only write ha
state once per template group update

* Make async_track_template_result use dataclasses for input/output

* black versions

* naming
2020-08-31 19:07:40 -05:00
Paulus Schoutsen 190611a079
Detect comments in jinja templates (#39496) 2020-08-31 10:51:30 +02:00
J. Nick Koston 8b893173fd
Prevent CoordinatorEntity from requesting updates on disabled entities (#39452) 2020-08-30 12:10:22 -05:00
J. Nick Koston f8712b0e00
Create a CoordinatorEntity class to avoid repating code in integrations (#39388) 2020-08-30 12:02:37 +02:00
Phil Bruckner b315df2118
Reduce automation state changes by using script helper's last_triggered attribute (#39323) 2020-08-28 14:51:15 -05:00
J. Nick Koston 414a59ae9f
Add the ability to reload homekit from yaml (#39326) 2020-08-28 16:46:45 +02:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
J. Nick Koston 810df38f0d
Add the ability to reload light/cover groups from yaml (#39250)
* Add the ability to reload light/cover groups from yaml

Update previous usage to reduce code duplication.

* Fix conflict from rebase
2020-08-25 18:13:43 -05:00
J. Nick Koston c87e03ee6f
Ensure template tracking can recover after the template generates an exception (#39256) 2020-08-26 00:33:08 +02:00
J. Nick Koston 90842fcb84
Support reloading the universal platform (#39248) 2020-08-26 00:25:15 +02:00
J. Nick Koston 20398cc0a6
Subscribe to state change events only if the template has entities (#39188) 2020-08-26 00:20:04 +02: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
J. Nick Koston c3ad493bb7
Report usage of extract_entities by custom components (#39185)
Block core usage usage of extract_entities

Suggest event.async_track_template_result instead.
2020-08-23 19:38:45 +02:00
Bas Nijholt a9ffc149f8
Allow templating keys in data_template (#39008)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-08-21 22:42:05 +02:00
Paulus Schoutsen 05d54a60b0
Deprecate optional script context (#39034)
Co-authored-by: Phil Bruckner <pnbruckner@gmail.com>
2020-08-21 14:17:47 +02:00
Phil Bruckner 76ead858cf
Add wait_for_trigger script action (#38075)
* Add wait_for_trigger script action

* Add tests

* Change script integration to use config validator
2020-08-21 11:38:25 +02:00
J. Nick Koston 1381b279f0
Update template sensor to use async_track_template_result (#38940)
* Add template entity

* Update template tracking to work for template sensors

* add test for whitespace

* Update homeassistant/helpers/config_validation.py

* revert

* fix

* reduce

* fix _refresh missing decorator

* defer until start

* do not throw errors during startup

* defer tracking until start event

Co-authored-by: Swamp-Ig <github@ninjateaparty.com>
2020-08-20 08:06:41 -05:00
Franck Nijhof bdc5af8dd2
Add support for attributes in (numeric) state conditions (#39050) 2020-08-19 20:01:27 +02:00
Paulus Schoutsen 3dc79aa60a
Track entity sources (#37258)
Co-authored-by: David Mulcahey <david.mulcahey@me.com>
2020-08-19 14:57:38 +02:00
Phil Bruckner ca9dd0c833
Reorganize trigger code (#38655) 2020-08-17 11:54:56 -05:00
J. Nick Koston 472b12bef5
Update TrackTemplateResultInfo to remove side effects from init (#38934)
* Verify and case

* Review comments

* Update homeassistant/helpers/event.py

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

* Update homeassistant/helpers/event.py

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-08-16 11:16:28 -05:00
J. Nick Koston 7d0e356560
Add track_template_result method to events (#38802)
* Merge original changes from #23590

* guard

* adjust

* adjust

* adjust

* Update async_render_to_info for recent codebase changes

* no more protected access

* do not fire right away per review comments

* update test to not fire right away

* closer

* rework tests for non firing first

* augment coverage

* remove cruft

* test for complex listen add/remove

* update docs to match review feedback to not fire right away

* preserve existing behavior

* fix test

* Ensure listeners are cleaned up

* de-dupe and comment

* de-dupe and comment

* coverage

* test to login again if we go from exception to ok to exception

* Update homeassistant/core.py

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

* Update homeassistant/helpers/event.py

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

* rename _boolean_coerce to result_as_boolean and move it out of event

* additional coverage

* Add more tests (may still be able to trim this down)

Co-authored-by: Swamp-Ig <github@ninjateaparty.com>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-08-15 19:53:03 -05:00
Franck Nijhof 755761867d
Use current request context in OAuth redirect (#38692) 2020-08-15 15:26:54 +02:00
Paulus Schoutsen b3571602bb
Add default_* to device registry (#38829) 2020-08-13 10:38:56 +02:00
Joakim Plate 15db2225da
async_get_instance was not reentrant during await (#38263) 2020-08-12 22:35:24 +02:00
Phil Bruckner 580e229cf2
Create variable with result of wait_template and accept template for timeout option (#38634) 2020-08-12 13:42:06 -05:00
J. Nick Koston 45526f4e8a
Add async_track_state_added_domain for tracking when states are added to a domain (#38776)
* Fire event_state_added when a state is added after start

* async_track_state_added_domain

* test

* naming

* coverage
2020-08-12 13:30:40 -05:00
Phil Bruckner 716fa63e73
Update script helper constructor parameters (#38763)
Add domain and make it and name required.

Add optional running_description.
2020-08-12 11:39:05 -05:00
J. Nick Koston 444df4a7d2
Use the shared zeroconf instance when attempting to create another Zeroconf instance (#38744) 2020-08-12 16:08:33 +02:00
Franck Nijhof 20710d8605
Add current request context to get_url helper (#38602) 2020-08-09 14:07:31 +02:00
J. Nick Koston ef8e74786f
Support extracting entities by domain from templates (#38647) 2020-08-09 13:44:09 +02:00
Pascal Vizeli 72a6251042
V2 timeout for async_add_entities (#38601)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-08-07 08:36:38 +02:00
Pascal Vizeli 896bdbff8f
Revert "Add a timeout for async_add_entities (#38474)" (#38584)
This reverts commit 7590af3930.
2020-08-06 09:32:42 +02:00
J. Nick Koston 7590af3930
Add a timeout for async_add_entities (#38474) 2020-08-05 18:06:21 +02:00
Pascal Vizeli c291d4aa7d
Intelligent timeout handler for setup/bootstrap (#38329)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-08-05 14:58:19 +02:00
J. Nick Koston 62c664fbbd
Reduce time to reload yaml and check configuration (#38469)
* Reduce time to reload yaml and check configuration

We spend a significant amount of time compiling templates
that we have already compiled.

Use an LRU cache to avoid re-compiling templates that
we frequently use.

* pylint

* switch to WeakValueDictionary

* preen
2020-08-04 03:00:44 +02:00
Phil Bruckner c3a820c4a3
Fix queued script not updating current attribute when queuing (#38432) 2020-08-01 15:51:48 +02:00