mirror of
https://github.com/home-assistant/core
synced 2024-09-15 17:29:45 +02:00
33077f0cdd
* Add config flow to songpal * Add config flow to songpal * Add songpal to migrated service in discovery * Improve songpal/set_sound_setting service * Remove songpal config flow from .coveragerc omit * Bump python-songpal to 0.12 and fix exception handling * Revert "Improve songpal/set_sound_setting service" This reverts commit 9be076ab52e21f268322572c36709a17d41db771. * Code style fix * Add connections to device_info * Fix pylint * Ignore braava tv * Fix test warning * Add @shenxn as codeowner * Remove model from configuration data * Get name from device in user step * Add unload entry support * Delete translations as it will get generated as part of CI * Code cleanup * Fix typo * Remove _show_setup_form * Change configuration from media_player to songpal Co-authored-by: Raman Gupta <7243222+raman325@users.noreply.github.com>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""The songpal component."""
|
|
from collections import OrderedDict
|
|
import logging
|
|
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
|
from homeassistant.const import CONF_NAME
|
|
from homeassistant.helpers import config_validation as cv
|
|
from homeassistant.helpers.typing import HomeAssistantType
|
|
|
|
from .const import CONF_ENDPOINT, DOMAIN
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
SONGPAL_CONFIG_SCHEMA = vol.Schema(
|
|
{vol.Optional(CONF_NAME): cv.string, vol.Required(CONF_ENDPOINT): cv.string}
|
|
)
|
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
{vol.Optional(DOMAIN): vol.All(cv.ensure_list, [SONGPAL_CONFIG_SCHEMA])},
|
|
extra=vol.ALLOW_EXTRA,
|
|
)
|
|
|
|
|
|
async def async_setup(hass: HomeAssistantType, config: OrderedDict) -> bool:
|
|
"""Set up songpal environment."""
|
|
conf = config.get(DOMAIN)
|
|
if conf is None:
|
|
return True
|
|
for config_entry in conf:
|
|
hass.async_create_task(
|
|
hass.config_entries.flow.async_init(
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=config_entry,
|
|
),
|
|
)
|
|
return True
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
|
"""Set up songpal media player."""
|
|
hass.async_create_task(
|
|
hass.config_entries.async_forward_entry_setup(entry, "media_player")
|
|
)
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
|
"""Unload songpal media player."""
|
|
return await hass.config_entries.async_forward_entry_unload(entry, "media_player")
|