From efb28d337ae347321658cc8eab309bf794a754d3 Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Sat, 5 Oct 2019 18:14:37 -0400 Subject: [PATCH] editor support for scene script action (#3942) Script support added in home-assistant/home-assistant#27223 --- src/panels/config/js/script/action_edit.tsx | 2 ++ src/panels/config/js/script/scene.tsx | 38 +++++++++++++++++++++ src/translations/en.json | 3 ++ 3 files changed, 43 insertions(+) create mode 100644 src/panels/config/js/script/scene.tsx diff --git a/src/panels/config/js/script/action_edit.tsx b/src/panels/config/js/script/action_edit.tsx index 078edbddea..d7dc398efd 100644 --- a/src/panels/config/js/script/action_edit.tsx +++ b/src/panels/config/js/script/action_edit.tsx @@ -8,6 +8,7 @@ import ConditionAction from "./condition"; import DelayAction from "./delay"; import DeviceAction from "./device"; import EventAction from "./event"; +import SceneAction from "./scene"; import WaitAction from "./wait"; const TYPES = { @@ -17,6 +18,7 @@ const TYPES = { condition: ConditionAction, event: EventAction, device_id: DeviceAction, + scene: SceneAction, }; const OPTIONS = Object.keys(TYPES).sort(); diff --git a/src/panels/config/js/script/scene.tsx b/src/panels/config/js/script/scene.tsx new file mode 100644 index 0000000000..a4fbb9a11f --- /dev/null +++ b/src/panels/config/js/script/scene.tsx @@ -0,0 +1,38 @@ +import { h, Component } from "preact"; +import "../../../../components/entity/ha-entity-picker"; + +export default class SceneAction extends Component { + constructor() { + super(); + + this.sceneChanged = this.sceneChanged.bind(this); + } + + public sceneChanged(ev: any) { + this.props.onChange(this.props.index, { + ...this.props.action, + scene: ev.target.value, + }); + } + + public render({ action, hass }) { + const { scene } = action; + + return ( +
+ +
+ ); + } +} + +(SceneAction as any).defaultConfig = { + alias: "", + scene: "", +}; diff --git a/src/translations/en.json b/src/translations/en.json index 5f7759f5c8..7f14d4aa52 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -899,6 +899,9 @@ }, "device_id": { "label": "Device" + }, + "scene": { + "label": "Activate scene" } } }