UniFi - Logs spam with not adding disabled entity (#34479)
* Proposed solution, unfortunately this makes the implementation less pretty * Clarify why mac is registered in init
This commit is contained in:
parent
bc5a2da7b7
commit
f12bd7ad99
5 changed files with 15 additions and 5 deletions
|
@ -9,11 +9,16 @@ from homeassistant.helpers.entity_registry import async_entries_for_device
|
|||
class UniFiBase(Entity):
|
||||
"""UniFi entity base class."""
|
||||
|
||||
DOMAIN = ""
|
||||
TYPE = ""
|
||||
|
||||
def __init__(self, controller) -> None:
|
||||
"""Set up UniFi entity base."""
|
||||
"""Set up UniFi entity base.
|
||||
|
||||
Register mac to controller entities to cover disabled entities.
|
||||
"""
|
||||
self.controller = controller
|
||||
self.controller.entities[self.DOMAIN][self.TYPE].add(self.mac)
|
||||
|
||||
@property
|
||||
def mac(self):
|
||||
|
@ -22,7 +27,6 @@ class UniFiBase(Entity):
|
|||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Entity created."""
|
||||
self.controller.entities[self.platform.domain][self.TYPE].add(self.mac)
|
||||
for signal, method in (
|
||||
(self.controller.signal_reachable, self.async_update_callback),
|
||||
(self.controller.signal_options_update, self.options_updated),
|
||||
|
@ -32,7 +36,7 @@ class UniFiBase(Entity):
|
|||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Disconnect object when removed."""
|
||||
self.controller.entities[self.platform.domain][self.TYPE].remove(self.mac)
|
||||
self.controller.entities[self.DOMAIN][self.TYPE].remove(self.mac)
|
||||
|
||||
async def async_remove(self):
|
||||
"""Clean up when removing entity.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue