mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
editor support for scene script action (#3942)
Script support added in home-assistant/home-assistant#27223
This commit is contained in:
parent
edd77e1f32
commit
efb28d337a
@ -8,6 +8,7 @@ import ConditionAction from "./condition";
|
|||||||
import DelayAction from "./delay";
|
import DelayAction from "./delay";
|
||||||
import DeviceAction from "./device";
|
import DeviceAction from "./device";
|
||||||
import EventAction from "./event";
|
import EventAction from "./event";
|
||||||
|
import SceneAction from "./scene";
|
||||||
import WaitAction from "./wait";
|
import WaitAction from "./wait";
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
@ -17,6 +18,7 @@ const TYPES = {
|
|||||||
condition: ConditionAction,
|
condition: ConditionAction,
|
||||||
event: EventAction,
|
event: EventAction,
|
||||||
device_id: DeviceAction,
|
device_id: DeviceAction,
|
||||||
|
scene: SceneAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
const OPTIONS = Object.keys(TYPES).sort();
|
const OPTIONS = Object.keys(TYPES).sort();
|
||||||
|
38
src/panels/config/js/script/scene.tsx
Normal file
38
src/panels/config/js/script/scene.tsx
Normal 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: "",
|
||||||
|
};
|
@ -899,6 +899,9 @@
|
|||||||
},
|
},
|
||||||
"device_id": {
|
"device_id": {
|
||||||
"label": "Device"
|
"label": "Device"
|
||||||
|
},
|
||||||
|
"scene": {
|
||||||
|
"label": "Activate scene"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user