mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Fix use of "" on lock entity more info (use default code) (#18706)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
8a93284bb3
commit
97b71c785b
@ -2,6 +2,7 @@ import {
|
|||||||
HassEntityAttributeBase,
|
HassEntityAttributeBase,
|
||||||
HassEntityBase,
|
HassEntityBase,
|
||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
|
import { getExtendedEntityRegistryEntry } from "./entity_registry";
|
||||||
import { showEnterCodeDialogDialog } from "../dialogs/enter-code/show-enter-code-dialog";
|
import { showEnterCodeDialogDialog } from "../dialogs/enter-code/show-enter-code-dialog";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
|
|
||||||
@ -30,15 +31,20 @@ export const callProtectedLockService = async (
|
|||||||
service: ProtectedLockService
|
service: ProtectedLockService
|
||||||
) => {
|
) => {
|
||||||
let code: string | undefined;
|
let code: string | undefined;
|
||||||
|
const lockRegistryEntry = await getExtendedEntityRegistryEntry(
|
||||||
|
hass,
|
||||||
|
stateObj.entity_id
|
||||||
|
).catch(() => undefined);
|
||||||
|
const defaultCode = lockRegistryEntry?.options?.lock?.default_code;
|
||||||
|
|
||||||
if (stateObj!.attributes.code_format) {
|
if (stateObj!.attributes.code_format && !defaultCode) {
|
||||||
const response = await showEnterCodeDialogDialog(element, {
|
const response = await showEnterCodeDialogDialog(element, {
|
||||||
codeFormat: "text",
|
codeFormat: "text",
|
||||||
codePattern: stateObj!.attributes.code_format,
|
codePattern: stateObj!.attributes.code_format,
|
||||||
title: hass.localize(`ui.card.lock.${service}`),
|
title: hass.localize(`ui.card.lock.${service}`),
|
||||||
submitText: hass.localize(`ui.card.lock.${service}`),
|
submitText: hass.localize(`ui.card.lock.${service}`),
|
||||||
});
|
});
|
||||||
if (!response) {
|
if (response == null) {
|
||||||
throw new Error("Code dialog closed");
|
throw new Error("Code dialog closed");
|
||||||
}
|
}
|
||||||
code = response;
|
code = response;
|
||||||
|
@ -99,6 +99,8 @@ export class DialogEnterCode
|
|||||||
id="code"
|
id="code"
|
||||||
.label=${this.hass.localize("ui.dialogs.enter_code.input_label")}
|
.label=${this.hass.localize("ui.dialogs.enter_code.input_label")}
|
||||||
type="password"
|
type="password"
|
||||||
|
autoValidate
|
||||||
|
validateOnInitialRender
|
||||||
pattern=${ifDefined(this._dialogParams.codePattern)}
|
pattern=${ifDefined(this._dialogParams.codePattern)}
|
||||||
inputmode="text"
|
inputmode="text"
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user