benq-rm-homeassistant/custom_components/benq_smartboard/__init__.py

44 lines
1.3 KiB
Python
Raw Normal View History

2025-01-25 12:42:38 +00:00
"""BenQ Smart Board integration for Home Assistant."""
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
DOMAIN = "benq_smartboard"
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config: dict):
"""
Legacy setup function for when we might support YAML in the future.
Currently, we do not configure anything via YAML. Just return True.
"""
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""
Set up the BenQ Smart Board integration from a config entry (UI flow).
"""
hass.data.setdefault(DOMAIN, {})
# Store config data (host, port, etc.) so other platforms can access it
hass.data[DOMAIN][entry.entry_id] = entry.data
# Forward entry setup to the media_player platform
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "media_player")
)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""
Unload a config entry (if the user removes it).
We must also unload the forwarded platforms.
"""
unload_ok = await hass.config_entries.async_forward_entry_unload(entry, "media_player")
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id, None)
return unload_ok