Entity to handle updates via events (#24733)
* Entity to handle updates via events * Fix a bug * Update entity.py
This commit is contained in:
parent
9e0636eefa
commit
06af6f19a3
5 changed files with 71 additions and 66 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue