Allow adding variable action in the automation UI (#16502)

This commit is contained in:
Paul Bottein 2023-05-11 11:19:36 +02:00 committed by GitHub
parent 72403f4276
commit 450565799e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import { import {
mdiAbTesting, mdiAbTesting,
mdiApplicationVariableOutline,
mdiArrowDecision, mdiArrowDecision,
mdiCallSplit, mdiCallSplit,
mdiCodeBraces, mdiCodeBraces,
@ -30,4 +31,9 @@ export const ACTION_TYPES = {
device_id: mdiDevices, device_id: mdiDevices,
stop: mdiHandBackRight, stop: mdiHandBackRight,
parallel: mdiShuffleDisabled, parallel: mdiShuffleDisabled,
}; variables: mdiApplicationVariableOutline,
} as const;
export const YAML_ONLY_ACTION_TYPES = new Set<keyof typeof ACTION_TYPES>([
"variables",
]);

View File

@ -8,8 +8,8 @@ import {
mdiPlay, mdiPlay,
mdiPlayCircleOutline, mdiPlayCircleOutline,
mdiRenameBox, mdiRenameBox,
mdiStopCircleOutline,
mdiSort, mdiSort,
mdiStopCircleOutline,
} from "@mdi/js"; } from "@mdi/js";
import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
@ -25,7 +25,7 @@ import "../../../../components/ha-card";
import "../../../../components/ha-expansion-panel"; import "../../../../components/ha-expansion-panel";
import "../../../../components/ha-icon-button"; import "../../../../components/ha-icon-button";
import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; import type { HaYamlEditor } from "../../../../components/ha-yaml-editor";
import { ACTION_TYPES } from "../../../../data/action"; import { ACTION_TYPES, YAML_ONLY_ACTION_TYPES } from "../../../../data/action";
import { validateConfig } from "../../../../data/config"; import { validateConfig } from "../../../../data/config";
import { import {
EntityRegistryEntry, EntityRegistryEntry,
@ -134,7 +134,9 @@ export default class HaAutomationActionRow extends LitElement {
if (!changedProperties.has("action")) { if (!changedProperties.has("action")) {
return; return;
} }
this._uiModeAvailable = getType(this.action) !== undefined; const type = getType(this.action);
this._uiModeAvailable =
type !== undefined && !YAML_ONLY_ACTION_TYPES.has(type as any);
if (!this._uiModeAvailable && !this._yamlMode) { if (!this._uiModeAvailable && !this._yamlMode) {
this._yamlMode = true; this._yamlMode = true;
} }

View File

@ -2566,6 +2566,9 @@
}, },
"parallel": { "parallel": {
"label": "Run in parallel" "label": "Run in parallel"
},
"variables": {
"label": "Define variables"
} }
} }
} }