Commit graph

169 commits

Author SHA1 Message Date
Erik Montnemery
7e4be921a8
Add helper to get an entity's supported features ()
* 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
Ruslan Sayfutdinov
a6759d731d
Use Mapping[str, Any] instead of dict in Entity () 2021-03-31 19:34:00 +02:00
Marc Mueller
6fb2e63e49
Update typing 02 () 2021-03-17 18:34:19 +01:00
Franck Nijhof
5d5a110a20
None optional hass typing in base entity and notify () 2021-03-15 15:11:41 +01:00
Erik Montnemery
3a054c3be7
Replace Entity.device_state_attributes with Entity.extra_state_attributes () 2021-03-09 13:58:43 +01:00
tkdrob
c2302784c2
Use core constants for helpers () 2021-02-08 22:53:17 +01:00
Paulus Schoutsen
9e07910ab0
Mark entities as unavailable when they are removed but are still registered ()
* 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
df2ede6522
Fix state overwrite race condition where two platforms request the same entity_id ()
* 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
J. Nick Koston
f50976a0b3
Switch to asyncio.wait for slow update warning implementation () 2020-10-05 15:28:15 +02:00
springstan
a2c3c33b22
Use core GitHub URL in all files () 2020-10-03 00:04:11 +02:00
Franck Nijhof
1c2ebdf307
Upgrade black to 20.8b1 () 2020-08-27 13:56:20 +02:00
Paulus Schoutsen
3dc79aa60a
Track entity sources ()
Co-authored-by: David Mulcahey <david.mulcahey@me.com>
2020-08-19 14:57:38 +02:00
Ville Skyttä
802c556e82
State and service related type hint improvements ()
* Improve type hint of service_func to register

* Add named type for state values

* Narrow some unnecessarily broad state type hints
2020-08-17 15:02:43 -04:00
J. Nick Koston
79055487ed
Simplify generate_entity_id ()
* 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
J. Nick Koston
910b6c9c2c
Index entity_registry_updated listeners () 2020-07-17 21:59:18 -07:00
Franck Nijhof
53545c984b
Log lines do not end with a full stop () 2020-07-05 23:04:19 +02:00
J. Nick Koston
152a80abed
Complete deprecation of hidden attribute (ATTR_HIDDEN) () 2020-06-23 17:05:32 -05:00
Ville Skyttä
0c5ca3084e
Add and fix type hints ()
* 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
J. Nick Koston
13f4393042
Fix flapping reload tests () 2020-04-28 22:58:55 -07:00
Ville Skyttä
267d98b5eb
Type hint improvements () 2020-04-17 11:33:58 -07:00
Franck Nijhof
6d24a65313
Various light test improvements () 2020-04-13 15:33:04 +02:00
Erik Montnemery
867630a4a7
Remove state when entity is removed from registry () 2020-03-26 16:33:50 -07:00
Eugenio Panadero
fb22f6c301
Add Context support for async_entity removal ()
* Add Context for async_remove

* Check context in state automation on entity removal
2020-03-24 09:59:17 -07:00
Erik Montnemery
7e387f93d6
Add MQTT WS command to remove device ()
* Add MQTT WS command to remove device

* Review comments, fix test

* Fix tests
2020-02-24 20:46:02 -08:00
Paulus Schoutsen
9e7185c676
Write state if schedule update state from async context ()
* 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 ()
* 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
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
e9e44dbd97
Fix callback and async ()
* Fix callback and async

* Fix a return

* Fix test

* Fix mqtt tests

* Fix some more callbacks
2020-01-29 13:59:45 -08:00
Paulus Schoutsen
0fba9e44ed
Migrate zone to use collection helpers () 2020-01-22 12:36:25 -08:00
Paulus Schoutsen
b9aba30a6e
Extract Collection helper from Person integration ()
* Add CRUD foundation

* Use collection helper in person integration

* Lint/pytest

* Add tests

* Lint

* Create notification
2020-01-03 21:37:11 +01:00
Ville Skyttä
fa4fa30461 Various string cleanups ()
* 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 ()
* 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
Bas Nijholt
67c56c860d Sort imports according to PEP8 for 'homeassistant' folder ()
Components are already done
2019-12-09 16:42:10 +01:00
Paulus Schoutsen
9771826ed6
Add capability-attributes () 2019-12-02 11:15:50 -08:00
Paulus Schoutsen
94675ca5a7
Mark entity abc ()
* Mark entity abc

* Use abstractmethod in climate

* Lint
2019-11-19 13:42:09 -06:00
Ville Skyttä
3adac699c7 Note snake_case state attribute name convention in entity docs ()
https://github.com/home-assistant/home-assistant/pull/26675#discussion_r331763063
2019-10-07 08:16:26 -07:00
Robbert Müller
7a156059e9 Switch on/off all lights, and wait for the result ()
* Switch on/off all lights, and wait for the result

Reuses the parallel_updates semaphore.
This is a small crutch which serializes platforms which already do tis
for updates. Platforms which can parallelize everything, this makes it
go faster

* Fix broken unittest

With manual validation, with help from @frenck, we found out that the
assertions are wrong and the test should be failing.

The sequence requested is
OFF
ON

without cancelation, this code should result in:
off,off,off,on,on,on

testable, by adding a `await hass.async_block_till_done()` between the
off and on call.

with cancelation. there should be less off call's so
off,on,on,on

* Adding tests for async_request_call

* Process review feedback

* Switch gather with wait

* 👕 running black
2019-10-06 08:23:12 -07:00
Ville Skyttä
f259ff17d5
Type hint additions ()
* Type hint additions

* Remove optional from sidebar_icon comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Remove optional from sidebar_title comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Fix issues after rebase and mypy 0.730
2019-09-29 20:07:49 +03:00
Franck Nijhof
b52cfd3409 Add comment for clarity to helper.entity.enabled() ()
* Fixes entity enabled expression

* Ensure True is returned when there is no registry_entity

* Add comment for clarity to helper.entity.enabled()
2019-09-24 14:21:00 -07:00
Franck Nijhof
6f9ccb5434 Add and corrects typehints in Entity helper & core class ()
* Add and corrects typehints in Entity class

* Adjust state type based on comments
2019-09-24 14:20:04 -07:00
Franck Nijhof
2f0eb07624 Migrate legacy typehints in core to PEP-526 ()
* Migrate legacy typehints in core to PEP-526

* Fix one type
2019-09-03 20:36:04 -07:00
SukramJ
cf3bb300e6 Fix for 0.98: Don't update disabled entities (Homematic IP Cloud) ()
* Homematic IP Cloud Fix: Don't update disabled entities

* Added enabled to entity.py

* Update test for enabled

* Update entity.py
2019-08-28 13:38:20 -07:00
Franck Nijhof
decf13b948 Use literal string interpolation in core (f-strings) () 2019-08-23 09:53:33 -07:00
Paulus Schoutsen
f704a8e90e Reload config entry when entity enabled in entity registry, remove entity if disabled. ()
* Reload config entry when disabled_by updated in entity registry

* Add types

* Remove entities that get disabled

* Remove unnecessary domain checks.

* Attach handler in async_setup

* Remove unused var

* Type

* Fix test

* Fix tests
2019-08-22 19:32:43 -05:00
Paulus Schoutsen
aa56b4dd30
Log warning if disabled entities receive updates. ()
* Log warning if disabled entities receive updates.

* Fix test

* Always set entity ID on disabled entities
2019-08-22 14:12:24 -07:00
Paulus Schoutsen
6c292846be
Allow entities to indicate they should be disabled by default () 2019-08-16 16:17:16 -07:00
Ville Skyttä
aa508b5106 Complete some incomplete type hints in helpers () 2019-08-15 08:53:25 -07:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00