diff --git a/homeassistant/components/zwave_js/api.py b/homeassistant/components/zwave_js/api.py index 91c316d307e..bed2166a4da 100644 --- a/homeassistant/components/zwave_js/api.py +++ b/homeassistant/components/zwave_js/api.py @@ -281,9 +281,9 @@ class DumpView(HomeAssistantView): msgs = await dump.dump_msgs(entry.data[CONF_URL], async_get_clientsession(hass)) return web.Response( - body="\n".join(json.dumps(msg) for msg in msgs) + "\n", + body=json.dumps(msgs, indent=2) + "\n", headers={ - hdrs.CONTENT_TYPE: "application/jsonl", - hdrs.CONTENT_DISPOSITION: 'attachment; filename="zwave_js_dump.jsonl"', + hdrs.CONTENT_TYPE: "application/json", + hdrs.CONTENT_DISPOSITION: 'attachment; filename="zwave_js_dump.json"', }, ) diff --git a/tests/components/zwave_js/test_api.py b/tests/components/zwave_js/test_api.py index 88e8acc5771..a36743421c9 100644 --- a/tests/components/zwave_js/test_api.py +++ b/tests/components/zwave_js/test_api.py @@ -1,4 +1,5 @@ """Test the Z-Wave JS Websocket API.""" +import json from unittest.mock import patch from zwave_js_server.event import Event @@ -164,7 +165,7 @@ async def test_dump_view(integration, hass_client): ): resp = await client.get(f"/api/zwave_js/dump/{integration.entry_id}") assert resp.status == 200 - assert await resp.text() == '{"hello": "world"}\n{"second": "msg"}\n' + assert json.loads(await resp.text()) == [{"hello": "world"}, {"second": "msg"}] async def test_dump_view_invalid_entry_id(integration, hass_client):