Commit graph

291 commits

Author SHA1 Message Date
Paulus Schoutsen 265fdea83b
Allow config entries to store a reason (#49581) 2021-04-23 09:23:43 +02:00
Alan Tse 125161df6b
Only raise integrationnotfound for dependencies (#48241)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-04-01 11:30:52 -07:00
Franck Nijhof 52475c108f
Make integration setup optional (#48381) 2021-03-29 13:53:47 -07:00
J. Nick Koston 3f2ca16ad7
Index config entries by id (#48199) 2021-03-21 21:44:29 -07:00
Franck Nijhof 8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI (#48111) 2021-03-19 13:41:09 +01:00
Marc Mueller 4cb7718192
Update typing 16 (#48087) 2021-03-18 22:58:19 +01:00
Marc Mueller 54d1e9985f
Update typing 15 (#48079) 2021-03-18 15:13:22 +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
Paulus Schoutsen 557ec374f1
Convert discovery helper to use dispatcher (#47008) 2021-02-24 13:37:31 -08:00
Erik Montnemery 5e26bda52d
Add support for disabling config entries (#46779) 2021-02-20 19:21:39 -08: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
Erik Montnemery 58b4a91a5b
Test that variables are passed to wait_for_trigger script action (#46221) 2021-02-09 00:34:18 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Christopher Gramberg c5fdde2a94
Convert filter tests to use pytest style (#41743) 2020-12-17 22:08:35 +01:00
Paulus Schoutsen ea55051161
Stub finding custom integrations in tests (#43692) 2020-11-27 12:53:16 +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 819dd27925
Automatically clean up executor as part of closing loop (#43284) 2020-11-16 15:43:48 +01:00
Paulus Schoutsen 9f4480a634
Add system health streaming updates (#42831) 2020-11-10 22:45:59 +01:00
Franck Nijhof 6e9b65405a
Disable legacy templates by default (#42967) 2020-11-08 16:11:38 +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 21e9e7c5c2
Default legacy templates to true (#42511)
* Default legacy templates to true

* Disable legacy_templates in tests

Co-authored-by: Franck Nijhof <git@frenck.dev>
2020-10-28 16:58:16 +01:00
Paulus Schoutsen 440570244d
Don't swallow all errors when checking for config validator platform (#42058) 2020-10-19 17:09:57 +02:00
Franck Nijhof f83f3c927a
Fix local media browser source conflicting with local www folder (#40151) 2020-09-16 21:38:40 +02:00
Franck Nijhof ff0562ad1e
Add media dirs core configuration (#40071)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-09-16 15:28:25 +02:00
Paulus Schoutsen 51a63c1fc4
Drop last bits of asyncio.coroutine (#39280) 2020-08-26 16:57:52 +02:00
Joakim Plate 15db2225da
async_get_instance was not reentrant during await (#38263) 2020-08-12 22:35:24 +02:00
Phil Bruckner 4c8c8a8c99
Fix async_fire_time_changed in tests/common.py (#38705) 2020-08-09 22:26:35 -05:00
J. Nick Koston 60009ec2f9
Use event loop scheduling for tracking time patterns (#38021)
* Use event loop scheduling for tracking time patterns

* make patching of time targetable

* patch time tests since time can tick to match during the test

* fix more tests

* time can only move forward

* time can only move forward

* back to 100% coverage

* simplify since the event loop time cannot move backwards

* simplify some more

* revert simplify

* Revert "revert simplify"

This reverts commit bd42f232f6.

* Revert "simplify some more"

This reverts commit 2a6c57d514.

* Revert "simplify since the event loop time cannot move backwards"

This reverts commit 3b13714ef4.

* Attempt another simplify

* time does not move backwards in the last two

* remove next_time <= now check

* fix previous merge error
2020-07-20 20:18:31 -10:00
J. Nick Koston 6ea5c8aed9
Index the device registry (#37990) 2020-07-19 23:32:05 -07:00
J. Nick Koston 890562e3ae
Index the entity registry (#37994) 2020-07-19 22:52:41 -07:00
Paulus Schoutsen f49ce5d1b4
Protect loop set default executor (#37438)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-07-06 15:58:53 -07:00
J. Nick Koston 89a9634d35
Use eventloop for scheduling (#37184)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-06-29 09:39:24 -07:00
Erik Montnemery 4e77969f5e
Drop use of mock_mqtt_component (#37013)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-06-23 10:17:22 -07:00
Erik Montnemery a2e2c35011
Use pytest for more MQTT tests (#36859)
* Use pytest for more MQTT tests

* Address review comments

* Break out PAHO client mock in separate fixture.

* tweak.
2020-06-22 22:02:29 +02:00
Paulus Schoutsen 5642027ffb
Improve after_dependencies handling (#36898) 2020-06-19 17:24:33 -07:00
Erik Montnemery 7722e417ad
Stable device id when a deleted device is restored (#36309)
* Stable device id when a deleted device is restored.

* Tweak

* Store only basic data for deleted devices

* Simplify code

* Simplify code

* Address review comments.

* Improve test

* Fix missing save
2020-06-02 21:22:08 +02:00
Paulus Schoutsen 76f392476b
Use a future for mock coro (#34989) 2020-04-30 16:31:00 -07:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
Paulus Schoutsen 454c5d824a
Attempt to fix CI (#34800) 2020-04-28 10:31:22 -07:00
David F. Mulcahey 8b0a0ee521
Don't write storage to disk while stopping (#33456)
* Don't write storage to disk while stopping

* rework change

* lint

* remove delay save and schedule final write at stop

* update tests

* fix test component using private methods

* cleanup

* always listen

* use stop in restore state again

* whitelist JSON exceptions for later

* review comment

* make zwave tests use mock storage
2020-04-02 10:25:28 -07:00
Paulus Schoutsen b10319f69e
Convert TTS tests to async (#33517)
* Convert TTS tests to async

* Address comments
2020-04-02 18:55:34 +02:00
Paulus Schoutsen deda2f86e7
Allow managing Lovelace storage dashboards (#32241)
* Allow managing Lovelace storage dashboards

* Make sure we do not allow duplicate url paths

* Allow setting sidebar to None

* Fix tests

* Delete storage file on delete

* List all dashboards
2020-02-28 12:43:17 -08:00
Erik Montnemery 7e387f93d6
Add MQTT WS command to remove device (#31989)
* Add MQTT WS command to remove device

* Review comments, fix test

* Fix tests
2020-02-24 20:46:02 -08:00
Jc2k de26108b23 Restore unit_of_measurement from entity registry (#30780)
* Restore unit_of_measurement from entity registry

* Lint fix
2020-01-15 08:09:05 -08:00
Paulus Schoutsen 9aa02e35a7
Entity Component to no longer generate automatic groups (#23789) 2020-01-07 17:30:53 +01: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
Paulus Schoutsen bb14a083f0
Store capabilities and supported features in entity registry, restore registered entities on startup (#30094)
* Store capabilities and supported features in entity registry

* Restore states at startup

* Restore non-disabled entities on HA start

* Fix test

* Pass device class from entity platform

* Clean up restored entities from state machine

* Fix Z-Wave test?
2019-12-31 14:29:43 +01:00
Paulus Schoutsen d851cb6f9e
Add unique ID to config entries (#29806)
* Add unique ID to config entries

* Unload existing entries with same unique ID if flow with unique ID is
finished

* Remove unused exception

* Fix typing

* silence pylint

* Fix tests

* Add unique ID to Hue

* Address typing comment

* Tweaks to comments

* lint
2019-12-16 12:27:43 +01:00
Bas Nijholt f60125b5c9 Sort imports according to PEP8 for 'tests' (#29791) 2019-12-09 16:52:24 +01:00
Ville Skyttä d88ca0f5cb Lint exclusions (#28655)
* Remove malformed pylint disable markers

* Remove some unused imports

* Remove some unneeded lint exclusions

* Remove more unneeded lint exclusions

* Add specific codes to all noqa's
2019-11-16 10:22:07 +01:00
Paulus Schoutsen b6c26cb363
Introduce new OAuth2 config flow helper (#27727)
* Refactor the Somfy auth implementation

* Typing

* Migrate Somfy to OAuth2 flow helper

* Add tests

* Add more tests

* Fix tests

* Fix type error

* More tests

* Remove side effect from constructor

* implementation -> auth_implementation

* Make get_implementation async

* Minor cleanup + Allow picking implementations.

* Add support for extra authorize data
2019-10-18 13:06:33 -07:00
Malte Franken 1a5b4c105a Move imports in mqtt component (#27835)
* move imports to top-level in mqtt server

* move imports to top-level in mqtt configflow

* move imports to top-level in mqtt init

* move imports to top-level in mqtt vacuum

* move imports to top-level in mqtt light
2019-10-17 17:04:27 -07:00
Paulus Schoutsen e866d769e8
Google Assistant Local SDK (#27428)
* Local Google

* Fix test

* Fix tests
2019-10-13 14:16:27 -07:00
Erik Montnemery 3e99743244
Add device trigger support to sensor entities (#27133)
* Add device trigger support to sensor entities

* Fix typing

* Fix tests, add test helper for comparing lists
2019-10-03 06:14:35 +02:00
Erik Montnemery 65ce3b49c1
Add support for for to binary_sensor, light and switch device triggers (#26658)
* Add support for `for` to binary_sensor, light and switch device triggers

* Add WS API device_automation/trigger/capabilities
2019-10-02 22:14:52 +02: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
Paulus Schoutsen 6fdff9ffab
Reorg device automation (#26880)
* async_trigger -> async_attach_trigger

* Reorg device automations

* Update docstrings

* Fix types

* Fix extending schemas
2019-09-24 14:57:05 -07:00
Erik Montnemery 6a60ebdb30
Rename MockToggleDevice to MockToggleEntity (#26644)
* Rename MockToggleDevice to MockToggleEntity

* Fix tests
2019-09-15 09:50:17 +02:00
Paulus Schoutsen adaa200935
Home Assistant Cast (#26566)
* Add backend support for Home Assistant Cast

* Update test reqs
2019-09-11 12:34:10 -06:00
Robert Svensson a2589f56e1 Add system options to config entries (#25926)
* Add system options to config entries

* For feedback

* Follow most of balloobs comments

* Fix balloobs comments

* Improvements

* Fix second round of Balloobs comments

* Fix third round

* Add system options to mock config entry

* Fix integration tests

* Fix the last failing tests

* Fix disabled string

* Fix failing disabled_by tests

* New tests

* Config entry WS API tests

* Fix comments
2019-08-17 21:34:11 -07:00
Paulus Schoutsen 6c292846be
Allow entities to indicate they should be disabled by default (#26011) 2019-08-16 16:17:16 -07:00
Paulus Schoutsen 6f357cb23e First pass fixing tests that raise exceptions caught by asyncio.gather (#25860)
* First pass fixing tests that raise exceptions caught by asyncio.gather

* Fix demo test

* lint
2019-08-12 16:42:12 +02:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Phil Bruckner c80683bb15 Restore automation last_triggered as datetime & fix test (#24951)
* Restore automation last_triggered as datetime & fix test

* last_triggered is always a string
2019-07-10 20:42:38 -07:00
Johann Kellerman 2e26f0bd2b Add check_config helper (#24557)
* check_config

* no ignore

* tests

* try tests again
2019-07-10 11:56:50 -07:00
Franck Nijhof 31f569ada9 Batch of Component(s) -> Integration(s) (#24972) 2019-07-05 15:24:26 -07:00
Paulus Schoutsen f995ab9d54
Don't pass in loop (#23984)
* 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
Erik Montnemery afe9fc221e
Fire event when core config is updated (#23922)
* Fire event when core config is updated
2019-05-20 20:02:36 +02:00
Paulus Schoutsen 1e22c8daca
Automatically generate config flow list (#23802)
* Add config flow to manifest.json

* Still load config flows via config flow platform

* Fix typo

* Lint

* Update config_flows.py"

* Catch import error when setting up entry

* Lint

* Fix tests

* Fix imports

* Lint

* Fix Unifi tests

* Fix translation test

* Add homekit_controller config flow
2019-05-13 01:16:55 -07:00
Paulus Schoutsen 5888e32360 Add support for an external step in config flow (#23782)
* Add support for an external step in config flow

* Types

* Lint
2019-05-10 14:33:49 +02:00
Ties de Kock 4004867eda Split up yaml loaders into multiple files (#23774)
* Start moving parts of yaml utils to own module

Move parts of yaml loader out of the single large file and start
to create the structure of the yaml loaders in Ansible [0].

[0]: https://github.com/ansible/ansible/tree/devel/lib/ansible/parsing/yaml

* Finish yaml migration, update tests and mocks

  * Move code around to finish the migration
  * Update the mocks so that `open` is patched in
    `homeassistant.util.yaml.loader` instead of
    `homeassistant.util.yaml`.
  * Updated mypy ignores
  * Updated external API of `homeasistant.util.yaml`, see below:

Checked what part of the api of `homeassistant.util.yaml` was actually
called from outside the tests and added an `__ALL__` that contains only
these elements.

Updated the tests so that references to internal parts of the API (e.g.
the yaml module imported into `homeassistant.util.yaml.loader`) are
referenced directly from `homeassistant.util.yaml.loader`.

In `tests/test_yaml.py` the import `yaml` refers to
`homeassistant.util.yaml` and `yaml_loader` refers to `~.loader`.

Future work that remains for the next iteration is to create a custom
SafeConstructor and refers to that instead of monkey patching `yaml` with
custom loaders.

* Update mocks in yaml dumper, check_config
2019-05-09 09:07:56 -07:00
Jc2k b3a8b0056b Add and use an async_fire_service_discovered helper (#23232) 2019-04-19 08:38:50 -04:00
Paulus Schoutsen 77244eab1e Fix empty components (#23177) 2019-04-17 19:17:13 -07:00
Paulus Schoutsen 10e8f4f70a
Add support for after_dependencies (#23148)
* Add support for after_dependencies

* Remove assert false"

* Fix types
2019-04-16 13:40:21 -07:00
Paulus Schoutsen d722f4d64a
Further integration load cleanups (#23104)
* Further integration load cleanups

* Fix tests

* Unflake MQTT vacuum command test
2019-04-14 19:07:05 -07:00
Paulus Schoutsen 3368e30279
Migrate packages and check config (#23082)
* Migrate packages and check config

* Fix typing

* Fix check config script
2019-04-14 07:23:01 -07:00
Paulus Schoutsen f7d4c48199
Convert service helper to use async_get_integration (#23023)
* Convert service helper to use async_get_integration

* Fix tests
2019-04-12 10:09:17 -07:00
Rohan Kapoor 6ba9ccf052 Load requirements and dependencies from manifests. Fallback to current REQUIREMENTS and DEPENDENCIES (#22717)
* Load dependencies from manifests. Fallback to current DEPENDENCIES

* Fix typing

* Ignore typing correctly

* Split out dependency processing to a new method

* Fix tests

* Only pull from manifest if dependencies is non empty

* Inline temporary function

* Fix light tests [skip ci]

* Fix tests/common

* Fix some mqtt tests [skip ci]

* Fix tests and component manifests which have only one platform

* Fix rflink tests

* Fix more tests and manifests

* Readability over shorthand format

* Fix demo/notify tests

* Load dependencies from manifests. Fallback to current DEPENDENCIES

* Load requirements from manifests. Fallback to current REQUIREMENTS

* Fix typing

* Ignore typing correctly

* Split out dependency processing to a new method

* Only pull from manifest if dependencies is non empty

* Inline temporary function

* Fix tests and component manifests which have only one platform

* Fix rflink tests

* Readability over shorthand format

* Clean up requirements

* Use integration to resolve deps/reqs

* Lint

* Lint

* revert a change

* Revert a test change

* Fix types

* Fix types

* Add back cache for load component

* Fix test_component_not_found

* Move light.test and device_tracker.test into test package instead with manifest to fix tests

* Fix broken device_tracker tests

* Add docstrings to __init__

* Fix all of the light tests that I broke earlier

* Embed the test.switch platform to fix other tests

* Embed and fix the test.imagimage_processing platform

* Fix tests for nx584

* Add dependencies from platform file's DEPENDENCIES

* Try to setup component when entity_platform is setting up

Fix tests in helpers folder

* Rewrite test_setup

* Simplify

* Lint

* Disable demo component if running in test

Temp workaround to unblock CI tests

* Skip demo tests

* Fix config entry test

* Fix repeat test

* Clarify doc

* One extra guard

* Fix import

* Lint

* Workaround google tts
2019-04-11 01:26:36 -07:00
Jason Hu c82d2cb11c
Cherry pick test fix (#22939) 2019-04-09 13:59:15 -07:00
Paulus Schoutsen cac00f5b26 Test for circular dependencies using manifests (#22908)
* Integration dependencies

* Lint

* Lint

* Fix one test

* Lint

* Fix load custom component integration

Fix async issue
Add circular dependency detection in manifest validation

* Fix test

* Address review comment

* Apply suggestions from code review

Co-Authored-By: balloob <paulus@home-assistant.io>
2019-04-09 09:30:32 -07:00
Paulus Schoutsen 590eead128
Test fixes (#22911)
* Fix light tests [skip ci]

* Fix tests/common

* Fix some mqtt tests [skip ci]

* Fix tests and component manifests which have only one platform

* Fix more tests and manifests

* Fix demo/notify tests

* Rollback test for demo.geo_location
2019-04-08 23:16:55 -07:00
Penny Wood 646c4a7137
Bootstrap to start registry loading early (#22321)
* Registries store directly in data on loading.

* Loading registries concurent with stage 1.

* Removed comments
2019-03-27 22:06:20 +08:00
Andrew Sayre 0903bd92f0 Add config entry remove callback (#21576) 2019-03-01 21:13:55 -08:00
Robert Svensson d9712027e8
Config entry options (#18929)
Add support for options flow for config entries
2019-02-22 17:59:43 +01:00
Paulus Schoutsen 2435456248 Prevent partial custom component overlays (#21070)
* Prevent partial custom component overlays

* Fix tests
2019-02-21 09:41:36 +01:00
Andrew Sayre 383813bfe6 Config Entry migrations (#20888)
* Updated per review feedback.

* Fixed line length

* Review comments and lint error

* Fixed mypy typeing error

* Moved migration logic to setup

* Use new migration error state

* Fix bug and ignore mypy type error

* Removed SmartThings example and added unit tests.

* Fixed test comments.
2019-02-15 09:30:47 -08:00
Paulus Schoutsen 16159cc3d0
Update platform loading path (#20807)
* Warn when platform loaded from an entity component folder

* Fix tests
2019-02-07 13:33:12 -08:00
Paulus Schoutsen e2cc1564a0
Add lovelace systeam health (#20592) 2019-01-30 12:57:56 -08:00
emontnemery d7ba2aad1d Add COMPONENT_SCHEMA and use it in alarm_control_panel (#20224)
* Add COMPONENT_SCHEMA and use in alarm and mqtt

* Revert MQTT changes

* Lint

* Small tweak

* Add tests

* Rename COMPONENT_SCHEMA to PLATFORM_SCHEMA_BASE

* Fix tests

* Improve tests
2019-01-28 16:14:55 -08:00
Robert Svensson bd335e1ac1 Area registry (#20435)
* First draft of area registry

* Refactor based on input

* Add tests for areas
Add tests for updating device

* Updating a device shouldn't require area

* Fix Martins comment

* Require admin

* Save after deleting

* Rename read to list_areas
Fix device entry_dict
Remove area id from device when deleting area

* Fix tests
2019-01-28 15:52:42 -08:00
Paulus Schoutsen 3928d034a3 Allow checking entity permissions based on devices (#19007)
* Allow checking entity permissions based on devices

* Fix tests
2018-12-05 11:41:00 +01:00
Adam Mills 22f27b8621 Store state last seen time separately (#18806)
* Store state last seen time separately

This ensures that infrequently updated entities aren't accidentally
dropped from the restore states store

* Fix mock restore cache
2018-11-30 08:26:19 +01:00
Adam Mills 5c3a4e3d10 Restore states through a JSON store instead of recorder (#17270)
* Restore states through a JSON store

* Accept entity_id directly in restore state helper

* Keep states stored between runs for a limited time

* Remove warning
2018-11-28 13:16:43 +01:00
Paulus Schoutsen 8b8629a5f4 Add permission checks to Rest API (#18639)
* Add permission checks to Rest API

* Clean up unnecessary method

* Remove all the tuple stuff from entity check

* Simplify perms

* Correct param name for owner permission

* Hass.io make/update user to be admin

* Types
2018-11-25 18:04:48 +01:00
emontnemery de9bac9ee3 Reconfigure MQTT binary_sensor component if discovery info is changed (#18169)
* Recreate component if discovery info is changed

* Update component instead of remove+add

* Set name and unique_id in __init__

* Update unit test

* Cleanup

* More cleanup

* Refactor according to review comments

* Change discovery_hash

* Review comments, add tests

* Fix handling of value_template
2018-11-19 16:49:04 +01:00
Paulus Schoutsen f7f0a4e811
System groups (#18303)
* Add read only and admin policies

* Migrate to 2 system groups

* Add system groups

* Add system groups admin & read only

* Dont' mutate parameters

* Fix types
2018-11-08 12:57:00 +01:00
Paulus Schoutsen 61f7a39748
Add permissions foundation (#16890)
* Add permission foundation

* Address comments

* typing

* False > True

* Convert more lambdas

* Use constants

* Remove support for False

* Fix only allow True
2018-10-11 19:24:25 +02:00
Otto Winter 26cf5acd5b Make async_track_time_change smarter (#17199)
* Make async_track_time_change smarter

* Move to util/dt

* Remove unnecessary check

* Lint

* Remove tzinfo check

* Remove check

* Add comment about async_track_point_in_utc_time

* Fix typing check

* Lint
2018-10-09 10:14:18 +02:00
Paulus Schoutsen c3b1121d77
Add group foundation (#16935)
Add group foundation
2018-10-08 16:35:38 +02:00
Paulus Schoutsen a559c06d6b
Make it easier for auth to consume newer formats (#17127) 2018-10-04 10:41:13 +02:00