mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Preserve device elements in automation when device is missing (#22521)
* Preserve device elements in automation when device is missing * lint
This commit is contained in:
parent
64e21e185c
commit
597866ff4e
@ -1,5 +1,5 @@
|
||||
import { consume } from "@lit-labs/context";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { css, html, LitElement, PropertyValues } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
@ -56,6 +56,28 @@ export class HaDeviceAction extends LitElement {
|
||||
}
|
||||
);
|
||||
|
||||
public shouldUpdate(changedProperties: PropertyValues) {
|
||||
if (!changedProperties.has("action")) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
this.action.device_id &&
|
||||
!(this.action.device_id in this.hass.devices)
|
||||
) {
|
||||
fireEvent(
|
||||
this,
|
||||
"ui-mode-not-available",
|
||||
Error(
|
||||
this.hass.localize(
|
||||
"ui.panel.config.automation.editor.edit_unknown_device"
|
||||
)
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const deviceId = this._deviceId || this.action.device_id;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { consume } from "@lit-labs/context";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { css, html, LitElement, PropertyValues } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
@ -57,6 +57,28 @@ export class HaDeviceCondition extends LitElement {
|
||||
}
|
||||
);
|
||||
|
||||
public shouldUpdate(changedProperties: PropertyValues) {
|
||||
if (!changedProperties.has("condition")) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
this.condition.device_id &&
|
||||
!(this.condition.device_id in this.hass.devices)
|
||||
) {
|
||||
fireEvent(
|
||||
this,
|
||||
"ui-mode-not-available",
|
||||
Error(
|
||||
this.hass.localize(
|
||||
"ui.panel.config.automation.editor.edit_unknown_device"
|
||||
)
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const deviceId = this._deviceId || this.condition.device_id;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { consume } from "@lit-labs/context";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { css, html, LitElement, PropertyValues } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
@ -61,6 +61,28 @@ export class HaDeviceTrigger extends LitElement {
|
||||
}
|
||||
);
|
||||
|
||||
public shouldUpdate(changedProperties: PropertyValues) {
|
||||
if (!changedProperties.has("trigger")) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
this.trigger.device_id &&
|
||||
!(this.trigger.device_id in this.hass.devices)
|
||||
) {
|
||||
fireEvent(
|
||||
this,
|
||||
"ui-mode-not-available",
|
||||
Error(
|
||||
this.hass.localize(
|
||||
"ui.panel.config.automation.editor.edit_unknown_device"
|
||||
)
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const deviceId = this._deviceId || this.trigger.device_id;
|
||||
|
||||
|
@ -2864,6 +2864,7 @@
|
||||
"copy_to_clipboard": "Copy to clipboard",
|
||||
"search_in": "Search · {group}",
|
||||
"unknown_entity": "unknown entity",
|
||||
"edit_unknown_device": "Editor not available for unknown device",
|
||||
"triggers": {
|
||||
"name": "Triggers",
|
||||
"header": "When",
|
||||
|
Loading…
x
Reference in New Issue
Block a user