diff --git a/custom_components/west_wood_club/const.py b/custom_components/west_wood_club/const.py index 48c6bd8..487eab7 100644 --- a/custom_components/west_wood_club/const.py +++ b/custom_components/west_wood_club/const.py @@ -4,6 +4,10 @@ from datetime import timedelta DOMAIN = 'west_wood_club' +# Shown as the device name; also the prefix the API puts on every club name +# (e.g. 'West Wood Club Dun Laoghaire'), stripped from per-club entity names. +DEVICE_NAME = 'West Wood Club' + # PerfectGym Go backend (West Wood is a white-label tenant). BASE_URL = 'https://goapi2.perfectgym.com' diff --git a/custom_components/west_wood_club/manifest.json b/custom_components/west_wood_club/manifest.json index 46ad428..2879150 100644 --- a/custom_components/west_wood_club/manifest.json +++ b/custom_components/west_wood_club/manifest.json @@ -7,5 +7,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "requirements": [], - "version": "0.1.0" + "version": "0.1.1" } diff --git a/custom_components/west_wood_club/sensor.py b/custom_components/west_wood_club/sensor.py index 520f47f..1dea165 100644 --- a/custom_components/west_wood_club/sensor.py +++ b/custom_components/west_wood_club/sensor.py @@ -11,7 +11,7 @@ from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import CONF_CLUBS, DOMAIN +from .const import CONF_CLUBS, DEVICE_NAME, DOMAIN from .coordinator import WestWoodConfigEntry, WestWoodCoordinator @@ -46,12 +46,14 @@ class WestWoodOccupancySensor(CoordinatorEntity[WestWoodCoordinator], SensorEnti ) -> None: super().__init__(coordinator) self._club_id = club_id - self._attr_name = name + # has_entity_name prepends the device name, so drop the duplicate prefix + # the API includes (e.g. 'West Wood Club Dun Laoghaire' -> 'Dun Laoghaire'). + self._attr_name = name.removeprefix(f'{DEVICE_NAME} ') or name self._attr_unique_id = f'{entry.entry_id}_{club_id}' # All club sensors share one device so they group together in the UI. self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, entry.entry_id)}, - name='West Wood Club', + name=DEVICE_NAME, manufacturer='PerfectGym', ) diff --git a/flake.nix b/flake.nix index c7493e8..7e065c9 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ west_wood_club = final.buildHomeAssistantComponent { owner = "deplayer0"; domain = "west_wood_club"; - version = "0.1.0"; + version = "0.1.1"; src = ./.; }; };