mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-22 16:46:29 +00:00
Fix serialization issue adding error to job (#4853)
This commit is contained in:
parent
6ed26cdd1f
commit
88d718271d
@ -201,8 +201,11 @@ class JobManager(FileConfiguration, CoreSysAttributes):
|
||||
self, job: SupervisorJob, attribute: Attribute, value: Any
|
||||
) -> None:
|
||||
"""Notify Home Assistant of a change to a job and bus on job start/end."""
|
||||
if attribute.name == "errors":
|
||||
value = [err.as_dict() for err in value]
|
||||
|
||||
self.sys_homeassistant.websocket.supervisor_event(
|
||||
WSEvent.JOB, job.as_dict() | {attribute.alias: value}
|
||||
WSEvent.JOB, job.as_dict() | {attribute.name: value}
|
||||
)
|
||||
|
||||
if attribute.name == "done":
|
||||
|
@ -175,6 +175,32 @@ async def test_notify_on_change(coresys: CoreSys):
|
||||
}
|
||||
)
|
||||
|
||||
job.capture_error()
|
||||
await asyncio.sleep(0)
|
||||
coresys.homeassistant.websocket._client.async_send_command.assert_called_with(
|
||||
{
|
||||
"type": "supervisor/event",
|
||||
"data": {
|
||||
"event": "job",
|
||||
"data": {
|
||||
"name": TEST_JOB,
|
||||
"reference": "test",
|
||||
"uuid": ANY,
|
||||
"progress": 50,
|
||||
"stage": "test",
|
||||
"done": False,
|
||||
"parent_id": None,
|
||||
"errors": [
|
||||
{
|
||||
"type": "HassioError",
|
||||
"message": "Unknown error, see supervisor logs",
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
await asyncio.sleep(0)
|
||||
coresys.homeassistant.websocket._client.async_send_command.assert_called_with(
|
||||
{
|
||||
@ -189,7 +215,12 @@ async def test_notify_on_change(coresys: CoreSys):
|
||||
"stage": "test",
|
||||
"done": True,
|
||||
"parent_id": None,
|
||||
"errors": [],
|
||||
"errors": [
|
||||
{
|
||||
"type": "HassioError",
|
||||
"message": "Unknown error, see supervisor logs",
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user