Stellt Spotify-Musik via Spotify Connect als HTTP-MP3-Stream bereit, den das Busch-Jäger Unterputz-Internetradio direkt abspielen kann. Komponenten: - ha-addon/: Home Assistant Add-on (librespot + ffmpeg + Icecast2) - custom_components/: Optionale HA Integration mit Media-Player-Entity - README.md: Vollständige Installations- und Konfigurationsanleitung - example-config.yaml: Kommentierte Beispielkonfiguration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Busch-Radio Spotify Bridge – Home Assistant Custom Component.
|
||
|
||
Diese Integration stellt einen Media-Player-Entity bereit, der den Status
|
||
des Icecast-Streams (vom Add-on) in der HA-Oberfläche anzeigt.
|
||
|
||
Voraussetzung: Das 'Busch-Radio Spotify Bridge' Add-on muss laufen.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import logging
|
||
|
||
from homeassistant.config_entries import ConfigEntry
|
||
from homeassistant.core import HomeAssistant
|
||
|
||
_LOGGER = logging.getLogger(__name__)
|
||
|
||
DOMAIN = "busch_radio_spotify"
|
||
PLATFORMS = ["media_player"]
|
||
|
||
CONF_HOST = "host"
|
||
CONF_PORT = "port"
|
||
CONF_MOUNT = "mount"
|
||
CONF_PASSWORD = "password"
|
||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||
"""Integration aus einem Config-Entry aufsetzen."""
|
||
hass.data.setdefault(DOMAIN, {})
|
||
hass.data[DOMAIN][entry.entry_id] = entry.data
|
||
|
||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||
_LOGGER.info(
|
||
"Busch-Radio Spotify Bridge verbunden: %s:%s%s",
|
||
entry.data[CONF_HOST],
|
||
entry.data[CONF_PORT],
|
||
entry.data[CONF_MOUNT],
|
||
)
|
||
return True
|
||
|
||
|
||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||
"""Config-Entry entladen."""
|
||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||
if unload_ok:
|
||
hass.data[DOMAIN].pop(entry.entry_id, None)
|
||
return unload_ok
|