mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Bump pybravia to 0.3.0 (#85127)
This commit is contained in:
parent
6b68d3d365
commit
49885757db
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from aiohttp import CookieJar
|
from aiohttp import CookieJar
|
||||||
from pybravia import BraviaTV
|
from pybravia import BraviaClient
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC, Platform
|
from homeassistant.const import CONF_HOST, CONF_MAC, Platform
|
||||||
@ -30,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
session = async_create_clientsession(
|
session = async_create_clientsession(
|
||||||
hass, cookie_jar=CookieJar(unsafe=True, quote_cookie=False)
|
hass, cookie_jar=CookieJar(unsafe=True, quote_cookie=False)
|
||||||
)
|
)
|
||||||
client = BraviaTV(host, mac, session=session)
|
client = BraviaClient(host, mac, session=session)
|
||||||
coordinator = BraviaTVCoordinator(
|
coordinator = BraviaTVCoordinator(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
client=client,
|
client=client,
|
||||||
|
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from aiohttp import CookieJar
|
from aiohttp import CookieJar
|
||||||
from pybravia import BraviaTV, BraviaTVAuthError, BraviaTVError, BraviaTVNotSupported
|
from pybravia import BraviaAuthError, BraviaClient, BraviaError, BraviaNotSupported
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@ -41,7 +41,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize config flow."""
|
"""Initialize config flow."""
|
||||||
self.client: BraviaTV | None = None
|
self.client: BraviaClient | None = None
|
||||||
self.device_config: dict[str, Any] = {}
|
self.device_config: dict[str, Any] = {}
|
||||||
self.entry: ConfigEntry | None = None
|
self.entry: ConfigEntry | None = None
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self.hass,
|
self.hass,
|
||||||
cookie_jar=CookieJar(unsafe=True, quote_cookie=False),
|
cookie_jar=CookieJar(unsafe=True, quote_cookie=False),
|
||||||
)
|
)
|
||||||
self.client = BraviaTV(host=host, session=session)
|
self.client = BraviaClient(host=host, session=session)
|
||||||
|
|
||||||
async def gen_instance_ids(self) -> tuple[str, str]:
|
async def gen_instance_ids(self) -> tuple[str, str]:
|
||||||
"""Generate client_id and nickname."""
|
"""Generate client_id and nickname."""
|
||||||
@ -162,18 +162,18 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if self.entry:
|
if self.entry:
|
||||||
return await self.async_reauth_device()
|
return await self.async_reauth_device()
|
||||||
return await self.async_create_device()
|
return await self.async_create_device()
|
||||||
except BraviaTVAuthError:
|
except BraviaAuthError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except BraviaTVNotSupported:
|
except BraviaNotSupported:
|
||||||
errors["base"] = "unsupported_model"
|
errors["base"] = "unsupported_model"
|
||||||
except BraviaTVError:
|
except BraviaError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
assert self.client
|
assert self.client
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.client.pair(client_id, nickname)
|
await self.client.pair(client_id, nickname)
|
||||||
except BraviaTVError:
|
except BraviaError:
|
||||||
return self.async_abort(reason="no_ip_control")
|
return self.async_abort(reason="no_ip_control")
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
@ -198,11 +198,11 @@ class BraviaTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if self.entry:
|
if self.entry:
|
||||||
return await self.async_reauth_device()
|
return await self.async_reauth_device()
|
||||||
return await self.async_create_device()
|
return await self.async_create_device()
|
||||||
except BraviaTVAuthError:
|
except BraviaAuthError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except BraviaTVNotSupported:
|
except BraviaNotSupported:
|
||||||
errors["base"] = "unsupported_model"
|
errors["base"] = "unsupported_model"
|
||||||
except BraviaTVError:
|
except BraviaError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
@ -273,7 +273,7 @@ class BraviaTVOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await coordinator.async_update_sources()
|
await coordinator.async_update_sources()
|
||||||
except BraviaTVError:
|
except BraviaError:
|
||||||
return self.async_abort(reason="failed_update")
|
return self.async_abort(reason="failed_update")
|
||||||
|
|
||||||
sources = coordinator.source_map.values()
|
sources = coordinator.source_map.values()
|
||||||
|
@ -9,13 +9,13 @@ from types import MappingProxyType
|
|||||||
from typing import Any, Final, TypeVar
|
from typing import Any, Final, TypeVar
|
||||||
|
|
||||||
from pybravia import (
|
from pybravia import (
|
||||||
BraviaTV,
|
BraviaAuthError,
|
||||||
BraviaTVAuthError,
|
BraviaClient,
|
||||||
BraviaTVConnectionError,
|
BraviaConnectionError,
|
||||||
BraviaTVConnectionTimeout,
|
BraviaConnectionTimeout,
|
||||||
BraviaTVError,
|
BraviaError,
|
||||||
BraviaTVNotFound,
|
BraviaNotFound,
|
||||||
BraviaTVTurnedOff,
|
BraviaTurnedOff,
|
||||||
)
|
)
|
||||||
from typing_extensions import Concatenate, ParamSpec
|
from typing_extensions import Concatenate, ParamSpec
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ SCAN_INTERVAL: Final = timedelta(seconds=10)
|
|||||||
def catch_braviatv_errors(
|
def catch_braviatv_errors(
|
||||||
func: Callable[Concatenate[_BraviaTVCoordinatorT, _P], Awaitable[None]]
|
func: Callable[Concatenate[_BraviaTVCoordinatorT, _P], Awaitable[None]]
|
||||||
) -> Callable[Concatenate[_BraviaTVCoordinatorT, _P], Coroutine[Any, Any, None]]:
|
) -> Callable[Concatenate[_BraviaTVCoordinatorT, _P], Coroutine[Any, Any, None]]:
|
||||||
"""Catch BraviaTV errors."""
|
"""Catch BraviaClient errors."""
|
||||||
|
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def wrapper(
|
async def wrapper(
|
||||||
@ -53,10 +53,10 @@ def catch_braviatv_errors(
|
|||||||
*args: _P.args,
|
*args: _P.args,
|
||||||
**kwargs: _P.kwargs,
|
**kwargs: _P.kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Catch BraviaTV errors and log message."""
|
"""Catch BraviaClient errors and log message."""
|
||||||
try:
|
try:
|
||||||
await func(self, *args, **kwargs)
|
await func(self, *args, **kwargs)
|
||||||
except BraviaTVError as err:
|
except BraviaError as err:
|
||||||
_LOGGER.error("Command error: %s", err)
|
_LOGGER.error("Command error: %s", err)
|
||||||
await self.async_request_refresh()
|
await self.async_request_refresh()
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class BraviaTVCoordinator(DataUpdateCoordinator[None]):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
client: BraviaTV,
|
client: BraviaClient,
|
||||||
config: MappingProxyType[str, Any],
|
config: MappingProxyType[str, Any],
|
||||||
ignored_sources: list[str],
|
ignored_sources: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -133,7 +133,7 @@ class BraviaTVCoordinator(DataUpdateCoordinator[None]):
|
|||||||
nickname=self.nickname,
|
nickname=self.nickname,
|
||||||
)
|
)
|
||||||
self.connected = True
|
self.connected = True
|
||||||
except BraviaTVAuthError as err:
|
except BraviaAuthError as err:
|
||||||
raise ConfigEntryAuthFailed from err
|
raise ConfigEntryAuthFailed from err
|
||||||
|
|
||||||
power_status = await self.client.get_power_status()
|
power_status = await self.client.get_power_status()
|
||||||
@ -147,18 +147,18 @@ class BraviaTVCoordinator(DataUpdateCoordinator[None]):
|
|||||||
await self.async_update_sources()
|
await self.async_update_sources()
|
||||||
await self.async_update_volume()
|
await self.async_update_volume()
|
||||||
await self.async_update_playing()
|
await self.async_update_playing()
|
||||||
except BraviaTVNotFound as err:
|
except BraviaNotFound as err:
|
||||||
if self.skipped_updates < 10:
|
if self.skipped_updates < 10:
|
||||||
self.connected = False
|
self.connected = False
|
||||||
self.skipped_updates += 1
|
self.skipped_updates += 1
|
||||||
_LOGGER.debug("Update skipped, Bravia API service is reloading")
|
_LOGGER.debug("Update skipped, Bravia API service is reloading")
|
||||||
return
|
return
|
||||||
raise UpdateFailed("Error communicating with device") from err
|
raise UpdateFailed("Error communicating with device") from err
|
||||||
except (BraviaTVConnectionError, BraviaTVConnectionTimeout, BraviaTVTurnedOff):
|
except (BraviaConnectionError, BraviaConnectionTimeout, BraviaTurnedOff):
|
||||||
self.is_on = False
|
self.is_on = False
|
||||||
self.connected = False
|
self.connected = False
|
||||||
_LOGGER.debug("Update skipped, Bravia TV is off")
|
_LOGGER.debug("Update skipped, Bravia TV is off")
|
||||||
except BraviaTVError as err:
|
except BraviaError as err:
|
||||||
self.is_on = False
|
self.is_on = False
|
||||||
self.connected = False
|
self.connected = False
|
||||||
raise UpdateFailed("Error communicating with device") from err
|
raise UpdateFailed("Error communicating with device") from err
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "braviatv",
|
"domain": "braviatv",
|
||||||
"name": "Sony Bravia TV",
|
"name": "Sony Bravia TV",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/braviatv",
|
"documentation": "https://www.home-assistant.io/integrations/braviatv",
|
||||||
"requirements": ["pybravia==0.2.5"],
|
"requirements": ["pybravia==0.3.0"],
|
||||||
"codeowners": ["@bieniu", "@Drafteed"],
|
"codeowners": ["@bieniu", "@Drafteed"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
|
@ -1506,7 +1506,7 @@ pyblackbird==0.5
|
|||||||
pybotvac==0.0.23
|
pybotvac==0.0.23
|
||||||
|
|
||||||
# homeassistant.components.braviatv
|
# homeassistant.components.braviatv
|
||||||
pybravia==0.2.5
|
pybravia==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.nissan_leaf
|
# homeassistant.components.nissan_leaf
|
||||||
pycarwings2==2.14
|
pycarwings2==2.14
|
||||||
|
@ -1085,7 +1085,7 @@ pyblackbird==0.5
|
|||||||
pybotvac==0.0.23
|
pybotvac==0.0.23
|
||||||
|
|
||||||
# homeassistant.components.braviatv
|
# homeassistant.components.braviatv
|
||||||
pybravia==0.2.5
|
pybravia==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.cloudflare
|
# homeassistant.components.cloudflare
|
||||||
pycfdns==2.0.1
|
pycfdns==2.0.1
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pybravia import (
|
from pybravia import (
|
||||||
BraviaTVAuthError,
|
BraviaAuthError,
|
||||||
BraviaTVConnectionError,
|
BraviaConnectionError,
|
||||||
BraviaTVError,
|
BraviaError,
|
||||||
BraviaTVNotSupported,
|
BraviaNotSupported,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -107,10 +107,10 @@ async def test_ssdp_discovery(hass):
|
|||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch("pybravia.BraviaTV.pair"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.set_wol_mode"
|
"pybravia.BraviaClient.pair"
|
||||||
), patch(
|
), patch("pybravia.BraviaClient.set_wol_mode"), patch(
|
||||||
"pybravia.BraviaTV.get_system_info",
|
"pybravia.BraviaClient.get_system_info",
|
||||||
return_value=BRAVIA_SYSTEM_INFO,
|
return_value=BRAVIA_SYSTEM_INFO,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
||||||
@ -195,17 +195,17 @@ async def test_user_invalid_host(hass):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"side_effect, error_message",
|
"side_effect, error_message",
|
||||||
[
|
[
|
||||||
(BraviaTVAuthError, "invalid_auth"),
|
(BraviaAuthError, "invalid_auth"),
|
||||||
(BraviaTVNotSupported, "unsupported_model"),
|
(BraviaNotSupported, "unsupported_model"),
|
||||||
(BraviaTVConnectionError, "cannot_connect"),
|
(BraviaConnectionError, "cannot_connect"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_pin_form_error(hass, side_effect, error_message):
|
async def test_pin_form_error(hass, side_effect, error_message):
|
||||||
"""Test that PIN form errors are correct."""
|
"""Test that PIN form errors are correct."""
|
||||||
with patch(
|
with patch(
|
||||||
"pybravia.BraviaTV.connect",
|
"pybravia.BraviaClient.connect",
|
||||||
side_effect=side_effect,
|
side_effect=side_effect,
|
||||||
), patch("pybravia.BraviaTV.pair"):
|
), patch("pybravia.BraviaClient.pair"):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
|
||||||
)
|
)
|
||||||
@ -222,15 +222,15 @@ async def test_pin_form_error(hass, side_effect, error_message):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"side_effect, error_message",
|
"side_effect, error_message",
|
||||||
[
|
[
|
||||||
(BraviaTVAuthError, "invalid_auth"),
|
(BraviaAuthError, "invalid_auth"),
|
||||||
(BraviaTVNotSupported, "unsupported_model"),
|
(BraviaNotSupported, "unsupported_model"),
|
||||||
(BraviaTVConnectionError, "cannot_connect"),
|
(BraviaConnectionError, "cannot_connect"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_psk_form_error(hass, side_effect, error_message):
|
async def test_psk_form_error(hass, side_effect, error_message):
|
||||||
"""Test that PSK form errors are correct."""
|
"""Test that PSK form errors are correct."""
|
||||||
with patch(
|
with patch(
|
||||||
"pybravia.BraviaTV.connect",
|
"pybravia.BraviaClient.connect",
|
||||||
side_effect=side_effect,
|
side_effect=side_effect,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -248,7 +248,7 @@ async def test_psk_form_error(hass, side_effect, error_message):
|
|||||||
|
|
||||||
async def test_no_ip_control(hass):
|
async def test_no_ip_control(hass):
|
||||||
"""Test that error are shown when IP Control is disabled on the TV."""
|
"""Test that error are shown when IP Control is disabled on the TV."""
|
||||||
with patch("pybravia.BraviaTV.pair", side_effect=BraviaTVError):
|
with patch("pybravia.BraviaClient.pair", side_effect=BraviaError):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
|
||||||
)
|
)
|
||||||
@ -274,10 +274,10 @@ async def test_duplicate_error(hass):
|
|||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch("pybravia.BraviaTV.pair"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.set_wol_mode"
|
"pybravia.BraviaClient.pair"
|
||||||
), patch(
|
), patch("pybravia.BraviaClient.set_wol_mode"), patch(
|
||||||
"pybravia.BraviaTV.get_system_info",
|
"pybravia.BraviaClient.get_system_info",
|
||||||
return_value=BRAVIA_SYSTEM_INFO,
|
return_value=BRAVIA_SYSTEM_INFO,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -298,10 +298,10 @@ async def test_create_entry(hass):
|
|||||||
"""Test that entry is added correctly with PIN auth."""
|
"""Test that entry is added correctly with PIN auth."""
|
||||||
uuid = await instance_id.async_get(hass)
|
uuid = await instance_id.async_get(hass)
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch("pybravia.BraviaTV.pair"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.set_wol_mode"
|
"pybravia.BraviaClient.pair"
|
||||||
), patch(
|
), patch("pybravia.BraviaClient.set_wol_mode"), patch(
|
||||||
"pybravia.BraviaTV.get_system_info",
|
"pybravia.BraviaClient.get_system_info",
|
||||||
return_value=BRAVIA_SYSTEM_INFO,
|
return_value=BRAVIA_SYSTEM_INFO,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
||||||
@ -339,10 +339,10 @@ async def test_create_entry(hass):
|
|||||||
|
|
||||||
async def test_create_entry_psk(hass):
|
async def test_create_entry_psk(hass):
|
||||||
"""Test that entry is added correctly with PSK auth."""
|
"""Test that entry is added correctly with PSK auth."""
|
||||||
with patch("pybravia.BraviaTV.connect"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.set_wol_mode"
|
"pybravia.BraviaClient.set_wol_mode"
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.get_system_info",
|
"pybravia.BraviaClient.get_system_info",
|
||||||
return_value=BRAVIA_SYSTEM_INFO,
|
return_value=BRAVIA_SYSTEM_INFO,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
"homeassistant.components.braviatv.async_setup_entry", return_value=True
|
||||||
@ -390,14 +390,14 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.get_power_status",
|
"pybravia.BraviaClient.get_power_status",
|
||||||
return_value="active",
|
return_value="active",
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.get_external_status",
|
"pybravia.BraviaClient.get_external_status",
|
||||||
return_value=BRAVIA_SOURCES,
|
return_value=BRAVIA_SOURCES,
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.send_rest_req",
|
"pybravia.BraviaClient.send_rest_req",
|
||||||
return_value={},
|
return_value={},
|
||||||
):
|
):
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
@ -418,7 +418,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
# Test that saving with missing sources is ok
|
# Test that saving with missing sources is ok
|
||||||
with patch(
|
with patch(
|
||||||
"pybravia.BraviaTV.get_external_status",
|
"pybravia.BraviaClient.get_external_status",
|
||||||
return_value=BRAVIA_SOURCES[1:],
|
return_value=BRAVIA_SOURCES[1:],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
@ -444,22 +444,22 @@ async def test_options_flow_error(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.get_power_status",
|
"pybravia.BraviaClient.get_power_status",
|
||||||
return_value="active",
|
return_value="active",
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.get_external_status",
|
"pybravia.BraviaClient.get_external_status",
|
||||||
return_value=BRAVIA_SOURCES,
|
return_value=BRAVIA_SOURCES,
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.send_rest_req",
|
"pybravia.BraviaClient.send_rest_req",
|
||||||
return_value={},
|
return_value={},
|
||||||
):
|
):
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"pybravia.BraviaTV.send_rest_req",
|
"pybravia.BraviaClient.send_rest_req",
|
||||||
side_effect=BraviaTVError,
|
side_effect=BraviaError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
@ -488,14 +488,14 @@ async def test_reauth_successful(hass, use_psk, new_pin):
|
|||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch("pybravia.BraviaTV.connect"), patch(
|
with patch("pybravia.BraviaClient.connect"), patch(
|
||||||
"pybravia.BraviaTV.get_power_status",
|
"pybravia.BraviaClient.get_power_status",
|
||||||
return_value="active",
|
return_value="active",
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.get_external_status",
|
"pybravia.BraviaClient.get_external_status",
|
||||||
return_value=BRAVIA_SOURCES,
|
return_value=BRAVIA_SOURCES,
|
||||||
), patch(
|
), patch(
|
||||||
"pybravia.BraviaTV.send_rest_req",
|
"pybravia.BraviaClient.send_rest_req",
|
||||||
return_value={},
|
return_value={},
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user