Commit Graph

1000 Commits (4d12fcc2189b7c08d53d4bc5a459427f403650d4)

Author SHA1 Message Date
J. Nick Koston fe69a85386
Improve logging when a unique id conflict is detected (#38434)
* fix error when unique id is re-used

* add test for the logging

* Update homeassistant/helpers/entity_platform.py

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

* Update homeassistant/helpers/entity_platform.py

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-08-01 11:20:37 +02:00
J. Nick Koston 79055487ed
Simplify generate_entity_id (#38418)
* Simplify generate_entity_id

Use similar optimized logic for async_generate_entity_id
from entity_registry that was already optimized

* pylint

* make generate_entity_id a wrapper around async_generate_entity_id instead
2020-07-31 08:50:42 +02:00
Ville Skyttä c2a21fa496
Update coordinator improvements (#38366)
* Make generic

* Add type info to bunch of uses

* Recognize requests exceptions

* Recognize urllib exceptions
2020-07-30 18:04:00 +03:00
Phil Bruckner 1158925b53
Fix repeat action when variables present (#38237) 2020-07-27 16:51:34 -05:00
Phil Bruckner 1a760c63d0
Fix parallel script containing repeat or choose action with max_runs > 10 (#38243) 2020-07-27 10:43:58 +02:00
Phil Bruckner 2f87da8aa9
Fix script repeat variable lifetime (#38124) 2020-07-23 23:11:21 -07:00
Phil Bruckner 65d1dfba62
Update automation logger to include object_id like scripts (#37948) 2020-07-22 10:55:49 -05:00
Ville Skyttä aa1c5fc43d
Various type hint improvements (#37952) 2020-07-22 08:06:37 -07:00
Phil Bruckner 726d5fdd94
Allow float values in time periods (#38023) 2020-07-21 19:41:42 -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
David F. Mulcahey 967a168ab7
Update comment about parallel updates to match the documentation (#37964) 2020-07-19 14:40:08 -10:00
J. Nick Koston 910b6c9c2c
Index entity_registry_updated listeners (#37940) 2020-07-17 21:59:18 -07:00
J. Nick Koston fa4e9c0485
Increase test line coverage of homeassistant/helpers/event.py to 100% (#37927)
* Increase test line coverage of homeassistant/helpers/event.py to 100%

* fix test
2020-07-16 21:47:53 -07:00
J. Nick Koston b6befa2e83
Ensure a state change tracker setup from inside a state change listener does not fire immediately (#37924)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-07-16 17:50:06 -07:00
Phil Bruckner 716cee6907
Fix automation & script restart mode bug (#37909) 2020-07-16 12:03:43 -07:00
Phil Bruckner cf498b7beb
Stop running scripts at shutdown (#37858) 2020-07-15 09:28:32 -07:00
J. Nick Koston 41cd90648e
Have async_track_point_in_utc_time call async_run_job directly from call_at (#37790)
We do not need a nested function here since call_at
takes args
2020-07-14 17:24:36 -10:00
Bram Kragten 7d77fa92c2
Add mode info attributes to script and automation (#37815)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-07-14 10:47:59 -07:00
Ville Skyttä ac0dbb17af
Attrs cleanups (#37849) 2020-07-14 10:30:30 -07:00
Phil Bruckner 7e280e2b27
Add choose script action (#37818)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-07-14 10:22:54 -07:00
Jakob Schlyter dbcd5f4c2c
Add urlencode template filter (#37753)
* add urlencode template filter

* fix flake8

* add test to string ang integer

* better test vectors
2020-07-13 16:48:29 +02:00
Phil Bruckner e5a081c7dd
Fix script queued mode typo (#37759) 2020-07-11 13:34:53 -05:00
Phil Bruckner 63e55bff52
Remove legacy script mode and simplify remaining modes (#37729) 2020-07-10 17:00:57 -07:00
Rohan Kapoor 0db8140c13
Add support for the DataUpdateCoordinator to not automatically update (#37734) 2020-07-10 15:48:20 -07:00
Phil Bruckner 91271f388c
Add new repeat loop for scripts and automations (#37589) 2020-07-10 13:37:19 -05: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 34ccb6588c
Cleanup async_track_state_change and augment docstring (#37251)
* Cleanup async_track_state_change and augment docstrings.

Skip from_state and to_state matching in
async_track_state_change when they are None

Optimize the state change listener for the most
common use case: no to_state and from_state
matching.

* Update benchmark to be more realistic (previously we assumed only one entity was present in the whole instance)

* Add more tests to ensure behavior is preserved

* Ensure new behavior matches test

* remove MATCH_ALL from zone automation since its the default anyways

* Might as well use async_track_state_change_event instead since MATCH_ALL is removed
2020-07-05 17:31:33 -05:00
Franck Nijhof 53545c984b
Log lines do not end with a full stop (#37527) 2020-07-05 23:04:19 +02:00
Phil Bruckner f7c4900d5c
Enhance automation integration to use new features in script helper (#37479) 2020-07-05 09:25:15 -05:00
Kevin Eifinger eb66da6436
Add helpers.location.coordinates (#37234) 2020-07-03 11:28:44 -07:00
Paulus Schoutsen d08d00daa7
Limit entity platform entity service to same integration (#37313) 2020-07-02 11:39:53 +02:00
mdegat01 52f3238e17
Add constant for PlatformNotReady wait time to use in tests (#37266) 2020-07-01 08:42:57 -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
J. Nick Koston a63a11a11a
Ensure all async_track_state_change_event callbacks run if one throws (#37179) 2020-06-27 17:48:27 -07:00
J. Nick Koston 4acc6f333e
Improve scalability of state change event routing (#37174) 2020-06-27 14:46:45 -07:00
Paulus Schoutsen 5bc6ed4cef
Add logbook platforms (#37078)
* Add logbook platforms

* Fix logbook describe test
2020-06-24 18:14:50 -07:00
mdegat01 6c7355785a
Add support for glob matching to entity filters (#36913)
* Added GLOB capability to entityfilter and every place that uses it. All existing tests are passing

* added tests for components affected by glob change

* fixed flake8 error

* mocking the correct listener

* mocking correct bus method in azure test

* tests passing in 3.7 and 3.8

* fixed formatting issue from rebase/conflict

* Checking against glob patterns in more performant way

* perf improvments and reverted unnecessarily adjusted tests

* added new benchmark test around filters

* no longer using get with default in entityfilter

* changed filter name and removed logbook from filter benchmark

* simplified benchmark tests from feedback

* fixed apache tests and returned include exclude schemas to normal

* fixed azure event hub tests to properly go through component logic

* fixed azure test and clean up for other tests

* renaming test files to match standard

* merged mqtt statestream test changes with base

* removed dependency on recorder filter schema from history

* fixed recorder tests after merge and a bunch of lint errors
2020-06-23 20:02:29 -05:00
J. Nick Koston 152a80abed
Complete deprecation of hidden attribute (ATTR_HIDDEN) (#37041) 2020-06-23 17:05:32 -05:00
Joakim Sørensen 835f433cf7
Remove loading of legacy translations (#37021) 2020-06-23 10:58:11 +02:00
Franck Nijhof 8b21b415c4
Fix/Rewrite of Toon integration (#36952)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-06-22 18:22:41 -07:00
Franck Nijhof f131959f4b
Correct inst method names in system info and issue templates (#36998) 2020-06-22 14:46:31 +02:00
Franck Nijhof 02f174e2e6
Add support for multiple states/zones in conditions (#36835)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-06-16 00:53:13 +02:00
Franck Nijhof ba73ac12ba
Add support for multiple entity_ids in conditions (#36817) 2020-06-15 22:54:19 +02:00
Franck Nijhof 3cc94f7d6a
ConfigFlow default discovery without unique ID (#36754) 2020-06-15 13:38:38 +02:00
Paulus Schoutsen 1ffa8fcbba
Platforms cleanup when adding entity fails (#36742) 2020-06-12 17:54:46 -07:00
Erik Montnemery 14bff5a375
Abort other config flows on import (#36608)
* Abort other flows on import

* Add test
2020-06-10 22:46:14 +02:00
Paulus Schoutsen 8f3c84b349
Mark config dependency of frontend (#36587) 2020-06-09 23:27:47 -07:00
Ville Skyttä 29b8f76e57
Use past tense in messages for already invalidated deprecated configs (#36591) 2020-06-09 23:26:55 -07: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
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
Franck Nijhof e86bedb223
Prevent possible secret values to show up in deprecation logs (#36368)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-06-02 17:29:59 +02:00
Franck Nijhof 0629b30ade
Correct inst method names in system info, add Docker version (#36360) 2020-06-02 10:50:34 +02:00
Paulus Schoutsen 276f3afb00
Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-31 22:18:30 -07:00
Phil Bruckner 1e9ec917f6
Add support for simultaneous runs of Script helper - Part 3 (#36202) 2020-05-27 15:10:28 -07:00
Ville Skyttä f8416484f8
More data entry flow and HTTP related type hints (#34430) 2020-05-26 09:28:22 -05:00
Robert Chmielowiec d21cfd869e
Fix service registration supported features check (#35718) 2020-05-23 18:11:51 +02:00
Andre Lengwenus 919f3243de
Fix device_registry cleanup behavior (#35977)
* Fix: Only decives which are not referenced by an entity or a config_entry are removed

* Adapted test for async_cleanup

* Changed variable names
2020-05-23 09:46:03 +02:00
J. Nick Koston 6d03496372
Ensure storage write consume the data under the lock (#35889)
If two writes trigger at the same time the data would already
be consumed.
2020-05-21 10:27:40 +02:00
Bram Kragten cb7b8d94c0
Add check for HTML in translations (#35615)
* Add check for HTML in translations

and remove existing html

* Add test
2020-05-14 19:33:14 +02:00
Martin Hjelmare 2a120d9045
Patch aiohttp client session close (#34769)
* Patch aiohttp client session close

* Add test

* Restore close regardless of auto_cleanup

* Close session instead of detaching and do not restore

* Delint test

* Add frame helper

* Use frame helper

* Test warning log when closing session

* Clean up

* Correct docstring

* Do not change shutdown

* Fix tests
2020-05-13 09:58:33 +02:00
Franck Nijhof eddb5c6c3f
Add more system information from Supervisor (#35560) 2020-05-12 15:27:34 -07:00
Thomas Hollstegge 8f285c15d3
Listen for group member state changes when using `expand` in templates (#35398)
* Re-evaluate template on group member state change

* Use named groups for entity extraction regex

This will avoid unnecessary edits of match indices if the regex is
amended in the future

* Improve test coverage
2020-05-10 10:48:56 -05:00
Franck Nijhof e3e3a113e9
async_get_url -> get_url (#35382) 2020-05-08 21:53:28 +02:00
Franck Nijhof e56dd8ed50
Detect use of deprecated base_url (#35353)
* Detect use of deprecated base_url

* Update get_url helper

* Update core migration

* Migrate all tests
2020-05-08 17:52:32 +02:00
Franck Nijhof 2223592486
Add get_url helper, deprecate base_url (#35224) 2020-05-08 02:29:47 +02:00
Paulus Schoutsen a330eba61c
Guard bad entity ID in entity registry (#35271) 2020-05-05 15:07:54 -07:00
Paulus Schoutsen 4ae31bc938
Clean up device registry if entity registry updates (#35106) 2020-05-05 10:53:46 -07:00
Paulus Schoutsen e54e9279e3
Extract instance ID helper from updater (#35043) 2020-05-04 11:23:12 -07:00
Martin Hjelmare 39431c0764
Add required features to cover service registration (#35073)
* Fix typing in component service method

* Add required features to cover service registration

* Fix template cover tilt features

* Delint template cover tests
2020-05-03 23:21:12 +02:00
Paulus Schoutsen b90cb09fd1
Add type to device registry (#35095) 2020-05-03 13:56:58 -07:00
Ville Skyttä 752679c55d
Check isinstance on collections.abc, not typing classes (#35087) 2020-05-02 23:57:48 +02:00
Paulus Schoutsen b3201523aa
Fix translation merging for custom components without translations (#35032) 2020-05-01 11:34:09 -07:00
Paulus Schoutsen 8f9467492d
Remove some passings of loop (#34995) 2020-04-30 21:34:51 -07:00
J. Nick Koston 793592b2b8
Config flow for homekit (#34560)
* Config flow for homekit

Allows multiple homekit bridges to run

HAP-python state is now stored at .storage/homekit.{entry_id}.state
aids is now stored at .storage/homekit.{entry_id}.aids

Overcomes 150 device limit by supporting
multiple bridges.

Name and port are now automatically allocated
to avoid conflicts which was one of the main
reasons pairing failed.

YAML configuration remains available in order to offer entity
specific configuration.

Entries created by config flow can add and remove
included domains and entities without having to restart

* Fix services as there are multiple now

* migrate in executor

* drop title from strings

* Update homeassistant/components/homekit/strings.json

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

* Make auto_start advanced mode only, add coverage

* put back title

* more references

* delete port since manual config is no longer needed

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-04-30 23:05:06 -05:00
Paulus Schoutsen 6056753a9c
Introduce a singleton decorator (#34803) 2020-04-30 16:47:14 -07:00
Franck Nijhof 928d9ec117
Fix not condition validation and entity/device extraction (#34959) 2020-05-01 00:15:53 +02:00
J. Nick Koston 13f4393042
Fix flapping reload tests (#34837) 2020-04-28 22:58:55 -07:00
Paulus Schoutsen 87801d8aca
Minor helpers cleanup (#34786) 2020-04-28 14:31:25 -07:00
Paulus Schoutsen 28f6e79385
Parallelize collections helper (#34783) 2020-04-28 14:31:16 -07:00
Paulus Schoutsen cc14dfa31c
Allow ignoring discovery config flow helper (#34740) 2020-04-26 23:35:04 -07:00
Franck Nijhof c93c6a66e8
Add NOT condition helper (#34624) 2020-04-24 09:40:23 -07:00
Paulus Schoutsen 6404882ec4
Allow flows to know if user is in advanced mode (#34629) 2020-04-24 09:31:56 -07:00
Paulus Schoutsen d3bbd9ec65
Delay sync for Google and limit updates to relevant info (#34622) 2020-04-24 10:49:11 +02:00
Paulus Schoutsen e9ff1940d6
Translation fixes and tweaks (#34489)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-04-21 17:57:21 -07:00
J. Nick Koston 96649a7e27
Use registry to find linked batteries for homekit (#33519) 2020-04-21 17:43:49 -07:00
Joakim Sørensen 730a257f3c
Rename translations dir for integrations (#34494) 2020-04-21 16:11:05 -07:00
Martin Hjelmare fbde040f59
Complete device registry update (#34500)
* Add manufacturer and model parameters to device registry update
  method.
2020-04-21 19:40:16 +02:00
Franck Nijhof bc5a2da7b7
Add transition support to scenes, cleanup blocking parameter (#34434) 2020-04-20 18:07:50 -07:00
Mikael Svensson ccc818266b
Fix relative_time datetime object without timezone (#34273) 2020-04-20 10:29:12 -07:00
Paulus Schoutsen 4720a7a891
Add foundation for state translations (#34443) 2020-04-19 20:35:49 -07:00
J. Nick Koston 0abcf2d176
Optimize async_generate_entity_id (#34440) 2020-04-19 18:19:11 -05:00
Paulus Schoutsen 26f78132ae
Fix circular import (#34441) 2020-04-19 14:41:52 -07:00
Paulus Schoutsen d10f5a48d4
Fix translations merging (#34417)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-04-19 12:37:44 -07:00
Paulus Schoutsen 98f1548f2d
Allow fetching translations by categories (#34329) 2020-04-18 17:13:13 -07:00
Ville Skyttä 267d98b5eb
Type hint improvements (#33082) 2020-04-17 11:33:58 -07:00
Paulus Schoutsen ff469cb592
Update Coordinator: Only schedule a refresh if listenerrs (#34317) 2020-04-16 16:44:14 -07:00
Paulus Schoutsen 94a3cec4bf
Take integration title from manifest if not translated (#34283) 2020-04-16 08:38:54 -07:00
Paulus Schoutsen 5a9970e63c
Dump states in event handler for HA_Stop (#33974)
* Dump states in event handler for HA_Stop

* Fix type
2020-04-13 17:41:01 -07:00
Franck Nijhof 6d24a65313
Various light test improvements (#34131) 2020-04-13 15:33:04 +02:00
springstan 00b6409b76
Use LENGTH_METERS constant (#34110) 2020-04-12 21:44:56 +02:00
Ville Skyttä 9b7e31eca3
Make f-strings without placeholder normal strings (#33938) 2020-04-10 09:59:06 +02:00
springstan 9a40d5b7ed
Use HTTP_NOT_FOUND constant (#33835) 2020-04-09 00:57:47 +02:00
springstan fca90a8ddc
Improve string formatting v5 (#33697)
* Improve string formatting v5

* Address review comments
2020-04-05 17:48:55 +02:00
Franck Nijhof 7d3c974747
Use set & dict literals (#33636)
Co-authored-by: Daniel Høyer Iversen <mail@dahoiv.net>
2020-04-04 20:05:15 +02:00
Franck Nijhof b9b1cee403
Enable pylint import-outside-toplevel (#33631) 2020-04-04 17:07:36 +02:00
Paulus Schoutsen dc7127aacf
Data Coordinator to return unsub func (#33588) 2020-04-03 20:15:42 +02:00
Paulus Schoutsen aef06a3544
Directly call write state 2 (#33513)
* 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
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
Ziv 4dbbf93af9
Replace asyncio.wait with asyncio.gather since wait ignores exceptions (#33380)
* replace asyncio.wait with asyncio.gather since wait ignores exceptions
fix for test_entity_platform so it expects the exception

* changed to log on failed domains

* discovered that this fix actually removes other uncaught exceptions

* fix in the list of ignored exceptions

* replaced a few ignores on dyson tests that work locally but fail in the CI

* two more tests that are failing on the CI and not locally

* removed assertion on multiple entries with same unique_id - replaced with log and return
reverted test_entity_platform to its original since now there is no exception thrown

* entered all the dyson tests. they all pass locally and probabilistically fail in the CI

* removed unnecessary str() for exception

* added log message for duplicate entity_id / unique_id

* removed log in case of False return value

* added exc_info

* change the use of exc_info
2020-04-01 07:09:13 -07:00
David F. Mulcahey bcd1eb952c
RFC - Add a 3rd state to the HA shutdown sequence for writing… (#33358)
* add third stage to hass shutdown

* use 3rd stage in storage

* update core state

* add writing data to multi stop ignore

* update core test

* review comment

* update name based on feedback
2020-03-30 10:18:39 -07:00
Paulus Schoutsen 73c52e668e
Fix dispatcher logging (#33299) 2020-03-26 20:44:44 -07:00
Erik Montnemery 867630a4a7
Remove state when entity is removed from registry (#32184) 2020-03-26 16:33:50 -07:00
Fabian Affolter 2647296475
Refactor API documentation (#33217)
* Upgrade Sphinx to 2.4.4

* Refactor API documentation

* Remove left-over

* Remove Markdown from docstring

* Update titels
2020-03-25 13:21:04 -07:00
Eugenio Panadero fb22f6c301
Add Context support for async_entity removal (#33209)
* Add Context for async_remove

* Check context in state automation on entity removal
2020-03-24 09:59:17 -07:00
Eugenio Panadero cd57b764ce
Fix state_automation_listener when new state is None (#32985)
* Fix state_automation_listener when new state is None (fix #32984)

* Listen to EVENT_STATE_CHANGED instead of using async_track_state_change

and use the event context on automation trigger.

* Share `process_state_match` with helpers/event

* Add test for state change automation on entity removal
2020-03-23 16:05:21 -07:00
Paulus Schoutsen 1ff245d9c2
Make sure entity platform services work for all platforms of d… (#33176)
* Make sure entity platform services work for all platforms of domain

* Register a bad service handler

* Fix cleaning up

* Tiny cleanup
2020-03-23 12:59:36 -07:00
Paulus Schoutsen f95c3e265d
Fix script logging with name (#33120) 2020-03-22 13:29:50 +01:00
Eugenio Panadero d5e606640c
Fix scheduled update time-drift in data update coordinator (#32974)
* Fix scheduled update time-drift in data update coordinator

As next schedule is calculated **after** the update is done,
setting now + update_interval makes 1 second drift in practice,
as the tick is 1Hz.

* Floor the utcnow timestamp

to remove sub-second error precision, and generate constant frequency updates
as long as the update takes < 1s.
2020-03-21 16:57:12 -07:00
Ville Skyttä 05abf37046
Type hint improvements (#32905)
* Complete helpers.entity_component type hints

* Add discovery info type
2020-03-18 19:27:25 +02:00
Franck Nijhof ff92a8b260
Add update class method to DataUpdateCoordinator (#32724)
* Add update class method to DataUpdateCoordinator

* Update homeassistant/helpers/update_coordinator.py

Co-Authored-By: Paulus Schoutsen <balloob@gmail.com>

* Move update_method param

* Rename async_update_data to _async_update_data

* Raise NotImplementedError

* Re-raise NotImplementedError

* Remove caplog, not needed anymore

* Don't set last_update_success on NotImplementedError

* Fix test

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-03-13 00:27:19 +01:00
Ville Skyttä 221d5205e4
Upgrade mypy to 0.770, tighten config a bit (#32715)
* Upgrade mypy to 0.770, related cleanups

https://mypy-lang.blogspot.com/2020/03/mypy-0770-released.html

* Clean up config and make it a notch stricter, address findings
2020-03-12 11:52:20 +01: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
Alexei Chetroi 440c837eb6
Allow sw_version update of a device registry entry. (#32630) 2020-03-11 09:31:02 -07:00
Paulus Schoutsen 6a21afa2a8
Improve script validation (#32461) 2020-03-05 11:44:42 -08:00
Paulus Schoutsen b27c46750c
Update error handling in update coordinator (#32452) 2020-03-04 08:05:46 -08:00
Paulus Schoutsen fcbea47c74
Coronavirus updates (#32417)
* Sort countries alphabetically

* Update sensor name

* Add migration to stable unique IDs

* Update sensor.py
2020-03-02 17:59:32 -08: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
Balazs Sandor 75e8d49af1
Show kernel version on linux (#32276) 2020-02-27 13:59:30 -08:00
Paulus Schoutsen 2a88ae559e
Improve debounce cooldown (#32161) 2020-02-26 11:27:37 -08:00
Paulus Schoutsen 7d8da47309
Revert "Use orjson to parse json faster (#32153)" (#32185)
This reverts commit 2365e2e8cf.
2020-02-25 21:07:16 +01:00
Paulus Schoutsen 536b31305a
Support multiple Lovelace dashboards (#32134)
* Support multiple Lovelace dashboards

* Mark collection maintenance as unfinished

* Fix import

* Add websockets commands for resource management

* Revert "Add websockets commands for resource management"

This reverts commit 7d140b2bcc.

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2020-02-25 11:18:21 -08:00
Ruslan Sayfutdinov 2365e2e8cf
Use orjson to parse json faster (#32153)
* [recorder] Use orjson to parse json faster

* Remove from http manifest

* Bump to orjson 2.5.1

* Empty commit to trigger CI

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-02-25 10:20:51 -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
Ville Skyttä 9b2544c923
Remove some unneeded pylint suppressions (#32152) 2020-02-24 16:47:15 -08:00
Phil Bruckner b2d7bc40dc
Add support for simultaneous runs of Script helper (#31937)
* 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 ca01e9a537
Improve condition validation error msg (#32135) 2020-02-24 09:59:34 +01:00
MatthewFlamm 6c9d4a6d15
Add missing name to logging in DataUpdateCoordinator (#32023) 2020-02-20 16:51:15 +01:00
Paulus Schoutsen 7be3a4cd37
Fix entity registry not saving name/icon (#31932) 2020-02-18 08:32:34 -08:00
Ville Skyttä 03f7fe483b
Type hint improvements (#31876)
* Complete components.remote type hints

* Define ConfigType only in helpers.typing
2020-02-16 13:47:55 +01:00
jjlawren 91018034b6
Use new custom_serializer (#31871) 2020-02-15 15:36:57 -08:00
Ville Skyttä 733f1e1101
Helpers typing improvements (#31865) 2020-02-15 13:03:53 -08:00
Paulus Schoutsen 52b045ed30
Fix person device_trackers null (#31829) 2020-02-14 15:27:31 -08:00
Robert Svensson 043d36f7c6
Change multi_select config validator to class (#31828)
* Move multi_select to class

* Fix serializer and add test

* Serializer should also return options
2020-02-14 11:09:40 -08:00
Paulus Schoutsen e019280d94
Annotate more async functions correctly (#31802) 2020-02-14 10:00:22 -08:00
Robert Svensson 6211a2bb98
Add multi select support to config validation and to custom serializer (#31798) 2020-02-13 13:12:09 -08:00
Paulus Schoutsen 9e7185c676
Write state if schedule update state from async context (#31758)
* Write state if schedule update state from async context

* Fix most tests

* Fix test and PS4 I/O in event loop

* Fix ps4 better
2020-02-13 10:22:06 -08:00
Paulus Schoutsen 51c35ab9a8
Entity Registry to store and restore name/icon (#31714)
* Entity Registry to store and restore name/icon

* Update test_entity_registry.py

* Add original name/icon to JSON result
2020-02-11 09:40:50 -08:00
Paulus Schoutsen 5a0f21cbe3
Adjust entity slow warning for custom component (#31711) 2020-02-10 16:32:47 -08:00