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