Compare commits

...
Author SHA1 Message Date
Claude 509bddd594 Accept a single action in the mocked execute_script
`callExecuteScript` takes one action or a list of them, and the automation
editor's run button sends a single one, so filtering the sequence without
normalizing it threw `filter is not a function` for that caller. The mock
handles every `execute_script` call, so this reached running an action in
the demo, not just MQTT.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C6PpwxkMaHCWkEFA27YnLE
2026-09-04 16:23:12 +00:00
+12 -3
View File
@@ -162,9 +162,18 @@ export const mockMqtt = (hass: MockHomeAssistant) => {
// work together.
hass.mockWS(
"execute_script",
(msg: { sequence: { action?: string; data?: Record<string, any> }[] }) => {
msg.sequence
?.filter((action) => action.action === "mqtt.publish")
(msg: {
sequence:
| { action?: string; data?: Record<string, any> }
| { action?: string; data?: Record<string, any> }[];
}) => {
// The sequence is one action or a list of them: the automation editor's
// run button sends a single action, so this cannot assume an array.
const actions = Array.isArray(msg.sequence)
? msg.sequence
: [msg.sequence];
actions
.filter((action) => action?.action === "mqtt.publish")
.forEach((action) => {
const topic = String(action.data?.topic ?? "");
const message: MQTTMessage = {