Skip to content

Commit

Permalink
HACS update to MASS #16
Browse files Browse the repository at this point in the history
  • Loading branch information
BeardedTinker committed Nov 2, 2023
1 parent 29b7173 commit 5a81314
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 252 deletions.
17 changes: 11 additions & 6 deletions custom_components/mass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
LISTEN_READY_TIMEOUT = 30


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # ruff: noqa: PLR0915
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up from a config entry."""
# ruff: noqa: PLR0915
if use_addon := entry.data.get(CONF_USE_ADDON):
await _async_ensure_addon_running(hass, entry)

Expand All @@ -51,13 +52,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: #
)
raise ConfigEntryError("Invalid configuration (migrating from V1 is not possible)")

mass = MusicAssistantClient(entry.data[CONF_URL], http_session)
mass_url = entry.data[CONF_URL]
mass = MusicAssistantClient(mass_url, http_session)

try:
async with async_timeout.timeout(CONNECT_TIMEOUT):
await mass.connect()
except (CannotConnect, asyncio.TimeoutError) as err:
raise ConfigEntryNotReady("Failed to connect to music assistant server") from err
raise ConfigEntryNotReady(
f"Failed to connect to music assistant server {mass_url}"
) from err
except InvalidServerVersion as err:
if use_addon:
addon_manager = _get_addon_manager(hass)
Expand All @@ -72,10 +76,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: #
translation_key="invalid_server_version",
)
raise ConfigEntryNotReady(f"Invalid server version: {err}") from err

except Exception as err:
LOGGER.exception("Failed to connect to music assistant server")
raise ConfigEntryNotReady("Unknown error connecting to the Music Assistant server") from err
LOGGER.exception("Failed to connect to music assistant server", exc_info=err)
raise ConfigEntryNotReady(
f"Unknown error connecting to the Music Assistant server {mass_url}"
) from err

async_delete_issue(hass, DOMAIN, "invalid_server_version")

Expand Down
2 changes: 1 addition & 1 deletion custom_components/mass/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"issue_tracker": "https://github.com/music-assistant/hass-music-assistant/issues",
"loggers": ["music_assistant"],
"requirements": ["music-assistant==2.0.0b59"],
"version": "2023.6.0b3",
"version": "2023.6.0b6",
"zeroconf": ["_mass._tcp.local."]
}
Loading

0 comments on commit 5a81314

Please sign in to comment.