From d8a20ab9c7bf6a429f80802ce8bca67470199d8d Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Mon, 13 May 2024 23:28:40 +0200 Subject: [PATCH] Ensure device identifier is a string The device identifier is an integer, which made the unique an integer as well. It should have been a string to begin with. This will be a breaking change, because the unique identifiers will change --- custom_components/biketrax/__init__.py | 4 ++-- custom_components/biketrax/device_tracker.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/biketrax/__init__.py b/custom_components/biketrax/__init__.py index 8e195a3..0f3b7dd 100644 --- a/custom_components/biketrax/__init__.py +++ b/custom_components/biketrax/__init__.py @@ -117,11 +117,11 @@ def __init__( self.device = device self._attrs: dict[str, Any] = { - "id": self.device.id, + "id": str(self.device.id), "name": self.device.name, } self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, self.device.id)}, + identifiers={(DOMAIN, str(self.device.id))}, model=device.name, name=device.name, ) diff --git a/custom_components/biketrax/device_tracker.py b/custom_components/biketrax/device_tracker.py index 8021fcb..dfffc5e 100644 --- a/custom_components/biketrax/device_tracker.py +++ b/custom_components/biketrax/device_tracker.py @@ -58,8 +58,8 @@ def __init__( """Initialize the tracker.""" super().__init__(coordinator, device) - self._attr_unique_id = device.id self._attr_name = device.name + self._attr_unique_id = f"{device.id}-location" @property def battery_level(self) -> int | None: