Remove not needed call_soon
@@ -153,15 +153,12 @@ class HomeAssistantWebSocket(CoreSysAttributes):
def supervisor_update_event(self, key: str, data: Optional[Dict[str, Any]] = None):
"""Send a supervisor/event command."""
- if self.sys_core.state not in CLOSING_STATES:
- self.sys_loop.call_soon(
- self.sys_loop.create_task,
- self.async_supervisor_update_event(key, data),
- )
+ if self.sys_core.state in CLOSING_STATES:
+ return
+ self.sys_create_task(self.async_supervisor_update_event(key, data))
def send_command(self, message: Dict[str, Any]):
"""Send a supervisor/event command."""
- if self.sys_core.state not in CLOSING_STATES:
- self.sys_loop.call_soon(
- self.sys_loop.create_task, self.async_send_command(message)
- )
+ if self.sys_core.state in CLOSING_STATES:
+ return
+ self.sys_create_task(self.async_send_command(message))
