mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Disable BLE options flow for sleepy shelly devices (#82283)
This commit is contained in:
parent
0aa5610d88
commit
8da969b767
@ -341,7 +341,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
cls, config_entry: config_entries.ConfigEntry
|
cls, config_entry: config_entries.ConfigEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return options flow support for this handler."""
|
"""Return options flow support for this handler."""
|
||||||
return config_entry.data.get("gen") == 2
|
return config_entry.data.get("gen") == 2 and not config_entry.data.get(
|
||||||
|
CONF_SLEEP_PERIOD
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class OptionsFlowHandler(config_entries.OptionsFlow):
|
class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Test the Shelly config flow."""
|
"""Test the Shelly config flow."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from aioshelly.exceptions import (
|
from aioshelly.exceptions import (
|
||||||
@ -927,6 +929,27 @@ async def test_options_flow_enabled_gen_2(hass, mock_rpc_device, hass_ws_client)
|
|||||||
await hass.config_entries.async_unload(entry.entry_id)
|
await hass.config_entries.async_unload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_options_flow_disabled_sleepy_gen_2(
|
||||||
|
hass, mock_rpc_device, hass_ws_client
|
||||||
|
):
|
||||||
|
"""Test options are disabled for sleepy gen2 devices."""
|
||||||
|
await async_setup_component(hass, "config", {})
|
||||||
|
entry = await init_integration(hass, 2, sleep_period=10)
|
||||||
|
|
||||||
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
await ws_client.send_json(
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"type": "config_entries/get",
|
||||||
|
"domain": "shelly",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
response = await ws_client.receive_json()
|
||||||
|
assert response["result"][0]["supports_options"] is False
|
||||||
|
await hass.config_entries.async_unload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow_ble(hass, mock_rpc_device):
|
async def test_options_flow_ble(hass, mock_rpc_device):
|
||||||
"""Test setting ble options for gen2 devices."""
|
"""Test setting ble options for gen2 devices."""
|
||||||
entry = await init_integration(hass, 2)
|
entry = await init_integration(hass, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user