Commit graph

595 commits

Author SHA1 Message Date
J. Nick Koston
96649a7e27
Use registry to find linked batteries for homekit () 2020-04-21 17:43:49 -07:00
Joakim Sørensen
730a257f3c
Rename translations dir for integrations () 2020-04-21 16:11:05 -07:00
Martin Hjelmare
fbde040f59
Complete device registry update ()
* 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 () 2020-04-20 18:07:50 -07:00
Mikael Svensson
ccc818266b
Fix relative_time datetime object without timezone () 2020-04-20 10:29:12 -07:00
Paulus Schoutsen
4720a7a891
Add foundation for state translations () 2020-04-19 20:35:49 -07:00
Paulus Schoutsen
d10f5a48d4
Fix translations merging ()
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-04-19 12:37:44 -07:00
Paulus Schoutsen
98f1548f2d
Allow fetching translations by categories () 2020-04-18 17:13:13 -07:00
Paulus Schoutsen
ff469cb592
Update Coordinator: Only schedule a refresh if listenerrs () 2020-04-16 16:44:14 -07:00
Paulus Schoutsen
94a3cec4bf
Take integration title from manifest if not translated () 2020-04-16 08:38:54 -07:00
Franck Nijhof
60bc517d01
Collection of core tests improvements ()
* Collection of core tests improvements

* Added some more

* Fix aiohttp client response release
2020-04-07 09:33:23 -07:00
Franck Nijhof
98a2efcbab
Collection of random (mainly) test improvements () 2020-04-06 12:51:48 +02:00
Franck Nijhof
528c7f4871
Removal of extraneous parenthesis in tests ()
* Removal of extraneous parenthesis

* Process review suggestions

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-05 03:50:30 +02:00
Franck Nijhof
03dd92d51b
Use set literals in tests () 2020-04-05 02:20:09 +02:00
Franck Nijhof
d7e9959442
String formatting improvements for tests (2) () 2020-04-05 00:33:07 +02:00
Paulus Schoutsen
dc7127aacf
Data Coordinator to return unsub func () 2020-04-03 20:15:42 +02:00
Paulus Schoutsen
aef06a3544
Directly call write state 2 ()
* Directly call async_write_ha_state pt2

* Directly call async_write_ha_state pt2

* Fix mock

* Address comments
2020-04-03 09:34:50 +02:00
David F. Mulcahey
8b0a0ee521
Don't write storage to disk while stopping ()
* 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 ()
* 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… ()
* 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 () 2020-03-26 20:44:44 -07:00
Paulus Schoutsen
1ff245d9c2
Make sure entity platform services work for all platforms of d… ()
* 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 () 2020-03-22 13:29:50 +01:00
Franck Nijhof
ff92a8b260
Add update class method to DataUpdateCoordinator ()
* 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
Phil Bruckner
5f5cb8bea8
Add support for simultaneous runs of Script helper - Part 2 ()
* 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. () 2020-03-11 09:31:02 -07:00
Paulus Schoutsen
6a21afa2a8
Improve script validation () 2020-03-05 11:44:42 -08:00
Paulus Schoutsen
b27c46750c
Update error handling in update coordinator () 2020-03-04 08:05:46 -08:00
Paulus Schoutsen
deda2f86e7
Allow managing Lovelace storage dashboards ()
* 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
springstan
f1a0ca7cd3
Add and use percentage constant ()
* Add and use percentage constant

* Fix pylint error and broken test
2020-02-28 11:46:48 -08:00
Paulus Schoutsen
2a88ae559e
Improve debounce cooldown () 2020-02-26 11:27:37 -08:00
Phil Bruckner
b2d7bc40dc
Add support for simultaneous runs of Script helper ()
* Add tests for legacy Script helper behavior

* Add Script helper if_running and run_mode options

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

* Change per review

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

Also:

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

* Change per review 2

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

* Change per review 3 and add tests

- Remove Script.set_logger().
- Enhance existing tests to check all run modes.
- Add tests for new features.
- Fix a few minor bugs found by tests.
2020-02-24 14:56:00 -08:00
Ruslan Sayfutdinov
15b4975681
Use ciso8601 library to parse datetime faster () 2020-02-24 08:33:10 -08:00
Paulus Schoutsen
ca01e9a537
Improve condition validation error msg () 2020-02-24 09:59:34 +01:00
Paulus Schoutsen
7be3a4cd37
Fix entity registry not saving name/icon () 2020-02-18 08:32:34 -08:00
Robert Svensson
043d36f7c6
Change multi_select config validator to class ()
* Move multi_select to class

* Fix serializer and add test

* Serializer should also return options
2020-02-14 11:09:40 -08:00
Robert Svensson
6211a2bb98
Add multi select support to config validation and to custom serializer () 2020-02-13 13:12:09 -08:00
Paulus Schoutsen
51c35ab9a8
Entity Registry to store and restore name/icon ()
* 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 () 2020-02-10 16:32:47 -08:00
Paulus Schoutsen
0d474e1183
Update the update coordinator API to make it easier to use ()
* Update the update coordinator API to make it easier to use

* failed_last_update -> last_update_success
2020-02-06 09:29:29 -08:00
Paulus Schoutsen
a3b3924e21
Update link when IO in event loop () 2020-02-06 11:37:35 +01:00
Paulus Schoutsen
e970177eeb
Use entity.async_request_call in service helper ()
* Use entity.async_request_call in service helper

* Clean up semaphore handling

* Address comments

* Simplify call entity service helper

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

* Make it a warning, not an error

* Add support for MATCH_ENTITY_NONE

* Fix lint

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

* Filter area_id from service data

* Fix services not accepting entities

* Typo
2020-02-02 15:36:39 -08:00
Paulus Schoutsen
c67f53dc43
Remove hour delay before checking for updates ()
* Check for updates at startup

* Add 100% test coverage for update_coordinator

* Address comments
2020-02-01 08:14:28 -08:00
Paulus Schoutsen
166d770ddd
Update Hue data fetching ()
* Refactor Hue Lights to use DataCoordinator

* Redo how Hue updates data

* Address comments

* Inherit from Entity and remove pylint disable

* Add tests for debounce
2020-01-31 14:47:40 -08:00
Christian Clauss
df7d2b3aeb
Fix typos found by codespell ()
* Fix typos found by codespell

* Fix typos found by codespell

* codespell: Furture  ==> Future

* Update test_config_flow.py

* Update __init__.py

* Spellcheck: successfull  ==> successful

* Codespell: unsuccesful  ==> unsuccessful

* Codespell: cant  ==> can't

* Codespell: firware ==> firmware

* Codespell: mimick  ==> mimic
2020-01-31 08:33:00 -08:00
Paulus Schoutsen
d24e397a80
Handle service calls that do not refer entity IDs () 2020-01-30 09:28:06 -08:00
Paulus Schoutsen
01dad31adc
Fix service helper not handling sync methods ()
* Fix service helper not handling sync methods

* Add legacy support for returning coroutine objects

* Fix tests

* Fix tests

* Convert demo cover to async
2020-01-29 16:27:25 -08:00
Paulus Schoutsen
424e15c7a7
Find related items scripts/automations ()
* Find related items scripts/automations

* Update manifest
2020-01-29 16:19:13 -08:00