Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions homeassistant/components/zwave_js/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ async def websocket_network_status(
) -> None:
"""Get the status of the Z-Wave JS network."""
controller = client.driver.controller
await controller.async_get_state()
data = {
"client": {
"ws_server_url": client.ws_server_url,
Expand All @@ -390,6 +391,7 @@ async def websocket_network_status(
"suc_node_id": controller.suc_node_id,
"supports_timers": controller.supports_timers,
"is_heal_network_active": controller.is_heal_network_active,
"inclusion_state": controller.inclusion_state,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I explicitly use controller.inclusion_state.value to make it more clear?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters. It will be converted to a number by the json serializer before the websocket consumer gets it. It's the possible values that may be interesting and those aren't shown anyway by the code here.

"nodes": list(client.driver.controller.nodes),
},
}
Expand Down
3 changes: 2 additions & 1 deletion tests/components/zwave_js/fixtures/controller_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
],
"sucNodeId": 1,
"supportsTimers": false,
"isHealNetworkActive": false
"isHealNetworkActive": false,
"inclusionState": 0
},
"nodes": [
]
Expand Down
13 changes: 8 additions & 5 deletions tests/components/zwave_js/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
from zwave_js_server.const import (
InclusionState,
InclusionStrategy,
LogLevel,
Protocols,
Expand Down Expand Up @@ -76,14 +77,16 @@ async def test_network_status(hass, integration, hass_ws_client):
entry = integration
ws_client = await hass_ws_client(hass)

await ws_client.send_json(
{ID: 2, TYPE: "zwave_js/network_status", ENTRY_ID: entry.entry_id}
)
msg = await ws_client.receive_json()
result = msg["result"]
with patch("zwave_js_server.model.controller.Controller.async_get_state"):
await ws_client.send_json(
{ID: 2, TYPE: "zwave_js/network_status", ENTRY_ID: entry.entry_id}
)
msg = await ws_client.receive_json()
result = msg["result"]

assert result["client"]["ws_server_url"] == "ws://test:3000/zjs"
assert result["client"]["server_version"] == "1.0.0"
assert result["controller"]["inclusion_state"] == InclusionState.IDLE

# Test sending command with not loaded entry fails
await hass.config_entries.async_unload(entry.entry_id)
Expand Down