Skip to content

Commit

Permalink
Do not add serial number to device info in HA before 2023.11 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner authored Feb 19, 2024
1 parent 05eaf7e commit e0b3c5e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/google_maps/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.device_registry import (
STORAGE_VERSION_MAJOR,
STORAGE_VERSION_MINOR,
)

# DeviceInfo moved in 2023.9.0b0
try:
Expand Down Expand Up @@ -275,11 +279,13 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None:
@property
def device_info(self) -> DeviceInfo | None:
"""Return device specific attributes."""
return DeviceInfo(
info = DeviceInfo(
identifiers={(DOMAIN, cast(str, self.unique_id))},
name=self._full_name,
serial_number=self.unique_id,
)
if (STORAGE_VERSION_MAJOR, STORAGE_VERSION_MINOR) >= (1, 4):
info["serial_number"] = self.unique_id
return info

@property
def entity_picture(self) -> str | None:
Expand Down

0 comments on commit e0b3c5e

Please sign in to comment.