Skip to content

Commit e074273

Browse files
author
Ted Roberts
committed
Fix entity availability and release v0.1.20
1 parent 48ad8ea commit e074273

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

custom_components/kaleidescape_strato/__init__.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
from .coordinator import KaleidescapeSensorCoordinator
2020

2121
type KaleidescapeConfigEntry = ConfigEntry
22+
type KaleidescapePlatform = str
2223

2324
_LOGGER = logging.getLogger(__name__)
25+
DATA_LOADED_PLATFORMS = "loaded_platforms"
2426

2527

2628
async def async_setup_entry(hass: HomeAssistant, entry: KaleidescapeConfigEntry) -> bool:
@@ -57,13 +59,32 @@ async def async_setup_entry(hass: HomeAssistant, entry: KaleidescapeConfigEntry)
5759
DATA_DEVICE_TYPE: device_type,
5860
}
5961

60-
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
62+
loaded_platforms: list[KaleidescapePlatform] = []
63+
for platform in PLATFORMS:
64+
try:
65+
await hass.config_entries.async_forward_entry_setups(entry, [platform])
66+
loaded_platforms.append(platform)
67+
except Exception:
68+
_LOGGER.exception(
69+
"Failed to set up Kaleidescape platform '%s' for entry %s",
70+
platform,
71+
entry.entry_id,
72+
)
73+
74+
if not loaded_platforms:
75+
_LOGGER.error("No Kaleidescape platforms could be set up for entry %s", entry.entry_id)
76+
hass.data[DOMAIN].pop(entry.entry_id, None)
77+
return False
78+
79+
hass.data[DOMAIN][entry.entry_id][DATA_LOADED_PLATFORMS] = loaded_platforms
6180
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
6281
return True
6382

6483

6584
async def async_unload_entry(hass: HomeAssistant, entry: KaleidescapeConfigEntry) -> bool:
66-
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
85+
entry_data = hass.data.get(DOMAIN, {}).get(entry.entry_id, {})
86+
loaded_platforms = entry_data.get(DATA_LOADED_PLATFORMS, PLATFORMS)
87+
unloaded = await hass.config_entries.async_unload_platforms(entry, loaded_platforms)
6788
if unloaded:
6889
hass.data[DOMAIN].pop(entry.entry_id, None)
6990
return unloaded

custom_components/kaleidescape_strato/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
}
1616
],
1717
"requirements": [],
18-
"version": "0.1.19"
18+
"version": "0.1.20"
1919
}

custom_components/kaleidescape_strato/media_player.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def __init__(
7272
self._client = client
7373
self._attr_unique_id = f"{entry.entry_id}_media_player"
7474

75+
@property
76+
def available(self) -> bool:
77+
return True
78+
7579
@property
7680
def device_info(self):
7781
device_type = self.hass.data[DOMAIN][self._entry.entry_id].get(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "kaleidescape-strato-ha"
7-
version = "0.1.19"
7+
version = "0.1.20"
88
description = "Home Assistant custom integration for Kaleidescape Strato players"
99
readme = "README.md"
1010
requires-python = ">=3.12"

0 commit comments

Comments
 (0)