Entity to handle updates via events (#24733)

* Entity to handle updates via events

* Fix a bug

* Update entity.py
This commit is contained in:
Paulus Schoutsen 2019-06-26 09:22:51 -07:00 committed by GitHub
parent 9e0636eefa
commit 06af6f19a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 66 deletions

View file

@ -320,9 +320,8 @@ class EntityPlatform:
'"{} {}"'.format(self.platform_name, entity.unique_id))
return
entity.registry_entry = entry
entity.entity_id = entry.entity_id
entity.registry_name = entry.name
entity.async_on_remove(entry.add_update_listener(entity))
# We won't generate an entity ID if the platform has already set one
# We will however make sure that platform cannot pick a registered ID
@ -360,6 +359,7 @@ class EntityPlatform:
self.entities[entity_id] = entity
entity.async_on_remove(lambda: self.entities.pop(entity_id))
await entity.async_internal_added_to_hass()
await entity.async_added_to_hass()
await entity.async_update_ha_state()