mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Fix Axis not generate unique IDs (#114115)
This commit is contained in:
parent
c1e1db9863
commit
71a6653f60
@ -7,7 +7,7 @@ from __future__ import annotations
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from axis.models.event import Event, EventOperation
|
from axis.models.event import Event, EventOperation, EventTopic
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -25,6 +25,7 @@ class AxisEntityLoader:
|
|||||||
"""Initialize the UniFi entity loader."""
|
"""Initialize the UniFi entity loader."""
|
||||||
self.hub = hub
|
self.hub = hub
|
||||||
|
|
||||||
|
self.registered_events: set[tuple[str, EventTopic, str]] = set()
|
||||||
self.platforms: list[
|
self.platforms: list[
|
||||||
tuple[
|
tuple[
|
||||||
AddEntitiesCallback,
|
AddEntitiesCallback,
|
||||||
@ -58,6 +59,11 @@ class AxisEntityLoader:
|
|||||||
@callback
|
@callback
|
||||||
def create_entity(description: AxisEventDescription, event: Event) -> None:
|
def create_entity(description: AxisEventDescription, event: Event) -> None:
|
||||||
"""Create Axis entity."""
|
"""Create Axis entity."""
|
||||||
|
event_id = (event.topic, event.topic_base, event.id)
|
||||||
|
if event_id in self.registered_events:
|
||||||
|
# Device has restarted and all events are initiatlized anew
|
||||||
|
return
|
||||||
|
self.registered_events.add(event_id)
|
||||||
if description.supported_fn(self.hub, event):
|
if description.supported_fn(self.hub, event):
|
||||||
async_add_entities([platform_entity(self.hub, description, event)])
|
async_add_entities([platform_entity(self.hub, description, event)])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user