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

View File

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