Skip to content

Commit

Permalink
Add automation/editor/show command to external bus (#19524)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jan 24, 2024
1 parent 2925ef3 commit b224ec5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/external_app/external_app_entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This is the entry point for providing external app stuff from app entrypoint.

import { fireEvent } from "../common/dom/fire_event";
import { mainWindow } from "../common/dom/get_main_window";
import { showAutomationEditor } from "../data/automation";
import { HomeAssistantMain } from "../layouts/home-assistant-main";
import type { EMIncomingMessageCommands } from "./external_messaging";

Expand Down Expand Up @@ -79,6 +80,14 @@ const handleExternalMessage = (
success: true,
result: null,
});
} else if (msg.command === "automation/editor/show") {
showAutomationEditor(msg.payload?.config);
bus.fireMessage({
id: msg.id,
type: "result",
success: true,
result: null,
});
} else {
return false;
}
Expand Down
14 changes: 13 additions & 1 deletion src/external_app/external_messaging.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AutomationConfig } from "../data/automation";

const CALLBACK_EXTERNAL_BUS = "externalBus";

interface CommandInFlight {
Expand Down Expand Up @@ -147,11 +149,21 @@ interface EMIncomingMessageShowSidebar {
command: "sidebar/show";
}

interface EMIncomingMessageShowAutomationEditor {
id: number;
type: "command";
command: "automation/editor/show";
payload?: {
config?: Partial<AutomationConfig>;
};
}

export type EMIncomingMessageCommands =
| EMIncomingMessageRestart
| EMIncomingMessageShowNotifications
| EMIncomingMessageToggleSidebar
| EMIncomingMessageShowSidebar;
| EMIncomingMessageShowSidebar
| EMIncomingMessageShowAutomationEditor;

type EMIncomingMessage =
| EMMessageResultSuccess
Expand Down

0 comments on commit b224ec5

Please sign in to comment.