mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 12:46:35 +00:00
Fix device automations
This commit is contained in:
parent
cc07d51613
commit
e642c80003
@ -3,6 +3,7 @@ import "@material/mwc-list/mwc-list-item";
|
|||||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import { stopPropagation } from "../../common/dom/stop_propagation";
|
||||||
import { fullEntitiesContext } from "../../data/context";
|
import { fullEntitiesContext } from "../../data/context";
|
||||||
import {
|
import {
|
||||||
DeviceAutomation,
|
DeviceAutomation,
|
||||||
@ -103,6 +104,7 @@ export abstract class HaDeviceAutomationPicker<
|
|||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
.value=${value}
|
.value=${value}
|
||||||
@selected=${this._automationChanged}
|
@selected=${this._automationChanged}
|
||||||
|
@closed=${stopPropagation}
|
||||||
.disabled=${this._automations.length === 0}
|
.disabled=${this._automations.length === 0}
|
||||||
>
|
>
|
||||||
${value === NO_AUTOMATION_KEY
|
${value === NO_AUTOMATION_KEY
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ContextProvider } from "@lit-labs/context";
|
||||||
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
@ -14,7 +16,10 @@ import "../../../components/ha-assist-pipeline-picker";
|
|||||||
import { HaFormSchema, SchemaUnion } from "../../../components/ha-form/types";
|
import { HaFormSchema, SchemaUnion } from "../../../components/ha-form/types";
|
||||||
import "../../../components/ha-help-tooltip";
|
import "../../../components/ha-help-tooltip";
|
||||||
import "../../../components/ha-navigation-picker";
|
import "../../../components/ha-navigation-picker";
|
||||||
|
import { HaSelect } from "../../../components/ha-select";
|
||||||
import "../../../components/ha-service-control";
|
import "../../../components/ha-service-control";
|
||||||
|
import { fullEntitiesContext } from "../../../data/context";
|
||||||
|
import { subscribeEntityRegistry } from "../../../data/entity_registry";
|
||||||
import {
|
import {
|
||||||
ActionConfig,
|
ActionConfig,
|
||||||
CallServiceActionConfig,
|
CallServiceActionConfig,
|
||||||
@ -22,9 +27,9 @@ import {
|
|||||||
UrlActionConfig,
|
UrlActionConfig,
|
||||||
} from "../../../data/lovelace/config/action";
|
} from "../../../data/lovelace/config/action";
|
||||||
import { ServiceAction } from "../../../data/script";
|
import { ServiceAction } from "../../../data/script";
|
||||||
|
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { EditorTarget } from "../editor/types";
|
import { EditorTarget } from "../editor/types";
|
||||||
import { HaSelect } from "../../../components/ha-select";
|
|
||||||
|
|
||||||
export type UiAction = Exclude<ActionConfig["action"], "fire-dom-event">;
|
export type UiAction = Exclude<ActionConfig["action"], "fire-dom-event">;
|
||||||
|
|
||||||
@ -81,7 +86,7 @@ const SEQUENCE_SCHEMA = [
|
|||||||
] as const satisfies readonly HaFormSchema[];
|
] as const satisfies readonly HaFormSchema[];
|
||||||
|
|
||||||
@customElement("hui-action-editor")
|
@customElement("hui-action-editor")
|
||||||
export class HuiActionEditor extends LitElement {
|
export class HuiActionEditor extends SubscribeMixin(LitElement) {
|
||||||
@property({ attribute: false }) public config?: ActionConfig;
|
@property({ attribute: false }) public config?: ActionConfig;
|
||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
@ -96,6 +101,19 @@ export class HuiActionEditor extends LitElement {
|
|||||||
|
|
||||||
@query("ha-select") private _select!: HaSelect;
|
@query("ha-select") private _select!: HaSelect;
|
||||||
|
|
||||||
|
private _entitiesContext = new ContextProvider(this, {
|
||||||
|
context: fullEntitiesContext,
|
||||||
|
initialValue: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
public hassSubscribe(): UnsubscribeFunc[] {
|
||||||
|
return [
|
||||||
|
subscribeEntityRegistry(this.hass!.connection!, (entities) => {
|
||||||
|
this._entitiesContext.setValue(entities);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
get _navigation_path(): string {
|
get _navigation_path(): string {
|
||||||
const config = this.config as NavigateActionConfig | undefined;
|
const config = this.config as NavigateActionConfig | undefined;
|
||||||
return config?.navigation_path || "";
|
return config?.navigation_path || "";
|
||||||
@ -132,6 +150,7 @@ export class HuiActionEditor extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(_changedProperties: PropertyValues): void {
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
||||||
this.hass!.loadFragmentTranslation("config");
|
this.hass!.loadFragmentTranslation("config");
|
||||||
|
this.hass!.loadBackendTranslation("device_automation");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user