Fix siren and device unique id

develop 0.9.0-snapshot7
Matthieu DUVAL 3 years ago
parent fd10326489
commit e92ac1825d

@ -54,7 +54,7 @@ class Device:
@property @property
def unique_id(self) -> str: def unique_id(self) -> str:
"""Get the unique id.""" """Get the unique id."""
return f"{GEORIDE_DOMAIN}_{self._tracker.tracker_id}" return {(GEORIDE_DOMAIN, self._tracker.tracker_id)}
def __str__(self) -> str: def __str__(self) -> str:
"""Get string representation.""" """Get string representation."""
@ -103,7 +103,7 @@ class DeviceBeacon:
def unique_id(self) -> str: def unique_id(self) -> str:
"""Get the unique id.""" """Get the unique id."""
return f"{GEORIDE_DOMAIN}_beacon_{self._tracker.tracker_id}" return {(GEORIDE_DOMAIN, self._beacon.beacon_id)}
def __str__(self) -> str: def __str__(self) -> str:
"""Get string representation.""" """Get string representation."""

@ -17,7 +17,7 @@ import georideapilib.api as GeoRideApi
from .const import DOMAIN as GEORIDE_DOMAIN from .const import DOMAIN as GEORIDE_DOMAIN
from .device import Device from .device import Device
ENTITY_ID_FORMAT: Final = GEORIDE_DOMAIN + ".{}" ENTITY_ID_FORMAT = GEORIDE_DOMAIN + ".{}"
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -31,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # pylint: d
for coordoned_tracker in coordoned_trackers: for coordoned_tracker in coordoned_trackers:
tracker_device = coordoned_tracker['tracker_device'] tracker_device = coordoned_tracker['tracker_device']
coordinator = coordoned_tracker['coordinator'] coordinator = coordoned_tracker['coordinator']
hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.unique_id] = coordinator hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.tracker.tracker_id] = coordinator
if tracker_device.tracker.version > 2: if tracker_device.tracker.version > 2:
entities.append(GeoRideSirenEntity(coordinator, tracker_device, hass)) entities.append(GeoRideSirenEntity(coordinator, tracker_device, hass))

Loading…
Cancel
Save