mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Fix Shelly diagnostics for devices without WebSocket Outbound support (#140501)
* Don't assume that `ws` is always in config * Fix device
This commit is contained in:
parent
8ea2d40467
commit
fa57d57215
@ -79,12 +79,14 @@ async def async_get_config_entry_diagnostics(
|
|||||||
device_settings = {
|
device_settings = {
|
||||||
k: v for k, v in rpc_coordinator.device.config.items() if k in ["cloud"]
|
k: v for k, v in rpc_coordinator.device.config.items() if k in ["cloud"]
|
||||||
}
|
}
|
||||||
ws_config = rpc_coordinator.device.config["ws"]
|
if not (ws_config := rpc_coordinator.device.config.get("ws", {})):
|
||||||
device_settings["ws_outbound_enabled"] = ws_config["enable"]
|
device_settings["ws_outbound"] = "not supported"
|
||||||
if ws_config["enable"]:
|
if (ws_outbound_enabled := ws_config.get("enable")) is not None:
|
||||||
device_settings["ws_outbound_server_valid"] = bool(
|
device_settings["ws_outbound_enabled"] = ws_outbound_enabled
|
||||||
ws_config["server"] == get_rpc_ws_url(hass)
|
if ws_outbound_enabled:
|
||||||
)
|
device_settings["ws_outbound_server_valid"] = bool(
|
||||||
|
ws_config["server"] == get_rpc_ws_url(hass)
|
||||||
|
)
|
||||||
device_status = {
|
device_status = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in rpc_coordinator.device.status.items()
|
for k, v in rpc_coordinator.device.status.items()
|
||||||
|
@ -194,3 +194,21 @@ async def test_rpc_config_entry_diagnostics_ws_outbound(
|
|||||||
result["device_settings"]["ws_outbound_server_valid"]
|
result["device_settings"]["ws_outbound_server_valid"]
|
||||||
== ws_outbound_server_valid
|
== ws_outbound_server_valid
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_rpc_config_entry_diagnostics_no_ws(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
mock_rpc_device: Mock,
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
) -> None:
|
||||||
|
"""Test config entry diagnostics for rpc device which doesn't support ws outbound."""
|
||||||
|
config = deepcopy(mock_rpc_device.config)
|
||||||
|
config.pop("ws")
|
||||||
|
monkeypatch.setattr(mock_rpc_device, "config", config)
|
||||||
|
|
||||||
|
entry = await init_integration(hass, 3)
|
||||||
|
|
||||||
|
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||||
|
|
||||||
|
assert result["device_settings"]["ws_outbound"] == "not supported"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user