mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Directly prompt for lock code in dashboards (#19835)
Prompt for lock codes in more places
This commit is contained in:
parent
a39cf99024
commit
e8fca5d93c
@ -14,6 +14,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import { EntityConfig, LovelaceRow } from "./types";
|
import { EntityConfig, LovelaceRow } from "./types";
|
||||||
|
import { callProtectedLockService } from "../../../data/lock";
|
||||||
|
|
||||||
@customElement("hui-lock-entity-row")
|
@customElement("hui-lock-entity-row")
|
||||||
class HuiLockEntityRow extends LitElement implements LovelaceRow {
|
class HuiLockEntityRow extends LitElement implements LovelaceRow {
|
||||||
@ -75,10 +76,11 @@ class HuiLockEntityRow extends LitElement implements LovelaceRow {
|
|||||||
private _callService(ev): void {
|
private _callService(ev): void {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const stateObj = this.hass!.states[this._config!.entity];
|
const stateObj = this.hass!.states[this._config!.entity];
|
||||||
this.hass!.callService(
|
callProtectedLockService(
|
||||||
"lock",
|
this,
|
||||||
stateObj.state === "locked" ? "unlock" : "lock",
|
this.hass!,
|
||||||
{ entity_id: stateObj.entity_id }
|
stateObj,
|
||||||
|
stateObj.state === "locked" ? "unlock" : "lock"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { supportsFeature } from "../common/entity/supports-feature";
|
import { supportsFeature } from "../common/entity/supports-feature";
|
||||||
import "../components/entity/state-info";
|
import "../components/entity/state-info";
|
||||||
import { LockEntityFeature } from "../data/lock";
|
import { callProtectedLockService, LockEntityFeature } from "../data/lock";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import { haStyle } from "../resources/styles";
|
import { haStyle } from "../resources/styles";
|
||||||
|
|
||||||
@ -56,10 +56,10 @@ class StateCardLock extends LitElement {
|
|||||||
private async _callService(ev) {
|
private async _callService(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const service = ev.target.dataset.service;
|
const service = ev.target.dataset.service;
|
||||||
const data = {
|
if (!this.hass || !this.stateObj) {
|
||||||
entity_id: this.stateObj.entity_id,
|
return;
|
||||||
};
|
}
|
||||||
await this.hass.callService("lock", service, data);
|
await callProtectedLockService(this, this.hass, this.stateObj, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user