Disable BLE options flow for sleepy shelly devices (#82283)

This commit is contained in:
J. Nick Koston 2022-11-17 12:39:51 -06:00 committed by GitHub
parent 0aa5610d88
commit 8da969b767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -341,7 +341,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
cls, config_entry: config_entries.ConfigEntry
) -> bool:
"""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):

View File

@ -1,4 +1,6 @@
"""Test the Shelly config flow."""
from __future__ import annotations
from unittest.mock import AsyncMock, Mock, patch
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)
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):
"""Test setting ble options for gen2 devices."""
entry = await init_integration(hass, 2)