-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a37d274
commit a64e8ee
Showing
12 changed files
with
152 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
"""The bluesound component.""" | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import Platform | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import config_validation as cv | ||
from homeassistant.helpers.typing import ConfigType | ||
|
||
from .const import DOMAIN | ||
from .media_player import setup_services | ||
|
||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) | ||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: | ||
"""Set up the Bluesound entry.""" | ||
await hass.config_entries.async_forward_entry_setup( | ||
config_entry, Platform.MEDIA_PLAYER | ||
) | ||
|
||
return True | ||
|
||
|
||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: | ||
"""Set up the Bluesound.""" | ||
setup_services(hass) | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Config flow for bluesound.""" | ||
|
||
import logging | ||
from typing import Any | ||
|
||
import voluptuous as vol | ||
|
||
from homeassistant import config_entries | ||
from homeassistant.config_entries import ConfigFlowResult | ||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT | ||
|
||
from .const import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class BluesoundConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): | ||
"""Bluesound config flow.""" | ||
|
||
VERSION = 1 | ||
MINOR_VERSION = 1 | ||
|
||
async def async_step_user( | ||
self, user_input: dict[str, Any] | None = None | ||
) -> ConfigFlowResult: | ||
"""Handle a flow initiated by the user.""" | ||
if user_input is not None: | ||
return self.async_create_entry( | ||
title=user_input[CONF_NAME], | ||
data=user_input, | ||
) | ||
|
||
return self.async_show_form( | ||
step_id="user", | ||
data_schema=vol.Schema( | ||
{ | ||
vol.Required(CONF_NAME, default="Bluesound"): str, | ||
vol.Required(CONF_HOST, description="host"): str, | ||
vol.Optional(CONF_PORT, default=11000): int, | ||
} | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ | |
"blink", | ||
"blue_current", | ||
"bluemaestro", | ||
"bluesound", | ||
"bluetooth", | ||
"bmw_connected_drive", | ||
"bond", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for the Bluesound integration.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Common fixtures for the Bluesound tests.""" | ||
|
||
from collections.abc import Generator | ||
from unittest.mock import AsyncMock, patch | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def mock_setup_entry() -> Generator[AsyncMock, None, None]: | ||
"""Override async_setup_entry.""" | ||
with patch( | ||
"homeassistant.components.bluesound.async_setup_entry", return_value=True | ||
) as mock_setup_entry: | ||
yield mock_setup_entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Test the Bluesound config flow.""" | ||
|
||
from unittest.mock import AsyncMock | ||
|
||
from homeassistant import config_entries | ||
from homeassistant.components.bluesound.const import DOMAIN | ||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.data_entry_flow import FlowResultType | ||
|
||
|
||
async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: | ||
"""Test we get the form.""" | ||
result = await hass.config_entries.flow.async_init( | ||
DOMAIN, context={"source": config_entries.SOURCE_USER} | ||
) | ||
assert result["type"] == FlowResultType.FORM | ||
assert result["errors"] is None | ||
|
||
result = await hass.config_entries.flow.async_configure( | ||
result["flow_id"], | ||
{ | ||
CONF_HOST: "1.1.1.1", | ||
CONF_NAME: "test-name", | ||
}, | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert result["type"] == FlowResultType.CREATE_ENTRY | ||
assert result["title"] == "test-name" | ||
assert result["data"] == { | ||
CONF_HOST: "1.1.1.1", | ||
CONF_PORT: 11000, | ||
CONF_NAME: "test-name", | ||
} | ||
assert len(mock_setup_entry.mock_calls) == 1 |