editor support for scene script action (#3942)

Script support added in home-assistant/home-assistant#27223
This commit is contained in:
Matthew Donoughe 2019-10-05 18:14:37 -04:00 committed by Paulus Schoutsen
parent edd77e1f32
commit efb28d337a
3 changed files with 43 additions and 0 deletions

View File

@ -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();

View File

@ -0,0 +1,38 @@
import { h, Component } from "preact";
import "../../../../components/entity/ha-entity-picker";
export default class SceneAction extends Component<any> {
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 (
<div>
<ha-entity-picker
value={scene}
onChange={this.sceneChanged}
hass={hass}
domainFilter="scene"
allowCustomEntity
/>
</div>
);
}
}
(SceneAction as any).defaultConfig = {
alias: "",
scene: "",
};

View File

@ -899,6 +899,9 @@
},
"device_id": {
"label": "Device"
},
"scene": {
"label": "Activate scene"
}
}
}