Warn when punctuation is used in conversation trigger (#17119)

This commit is contained in:
Bram Kragten 2023-06-30 17:14:58 +02:00 committed by GitHub
parent e5146512d5
commit d6f8941098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,8 @@ import { showConfirmationDialog } from "../../../../../dialogs/generic/show-dial
import { HomeAssistant } from "../../../../../types";
import { TriggerElement } from "../ha-automation-trigger-row";
const PATTERN = "^[^.。,?¿?؟!;:]+$";
@customElement("ha-automation-trigger-conversation")
export class HaConversationTrigger
extends LitElement
@ -39,6 +41,12 @@ export class HaConversationTrigger
iconTrailing
.index=${index}
.value=${option}
.validationMessage=${this.hass.localize(
"ui.panel.config.automation.editor.triggers.type.conversation.no_punctuation"
)}
autoValidate
validateOnInitialRender
pattern=${PATTERN}
@change=${this._updateOption}
>
<ha-icon-button
@ -56,6 +64,11 @@ export class HaConversationTrigger
.label=${this.hass.localize(
"ui.panel.config.automation.editor.triggers.type.conversation.add_sentence"
)}
.validationMessage=${this.hass.localize(
"ui.panel.config.automation.editor.triggers.type.conversation.no_punctuation"
)}
autoValidate
pattern=${PATTERN}
@keydown=${this._handleKeyAdd}
@change=${this._addOption}
></ha-textfield>`;

View File

@ -2382,6 +2382,7 @@
},
"conversation": {
"label": "Sentence",
"no_punctuation": "You should not use punctuation in your sentence",
"add_sentence": "Add sentence",
"delete": "Delete sentence",
"confirm_delete": "Are you sure you want to delete this sentence?",