Use execute_script call in services developer tool (#8657)

This commit is contained in:
Erik Montnemery 2021-03-16 12:38:49 +01:00 committed by GitHub
parent 60de74a375
commit e3b72fe0aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

8
src/data/service.ts Normal file
View File

@ -0,0 +1,8 @@
import { HomeAssistant } from "../types";
import { Action } from "./script";
export const callExecuteScript = (hass: HomeAssistant, sequence: Action[]) =>
hass.callWS({
type: "execute_script",
sequence,
});

View File

@ -21,6 +21,7 @@ import "../../../components/ha-service-picker";
import "../../../components/ha-yaml-editor";
import type { HaYamlEditor } from "../../../components/ha-yaml-editor";
import { ServiceAction } from "../../../data/script";
import { callExecuteScript } from "../../../data/service";
import { haStyle } from "../../../resources/styles";
import "../../../styles/polymer-ha-style";
import { HomeAssistant } from "../../../types";
@ -250,17 +251,10 @@ class HaPanelDevService extends LitElement {
);
private _callService() {
const domain = computeDomain(this._serviceData!.service);
const service = computeObjectId(this._serviceData!.service);
if (!domain || !service) {
if (!this._serviceData?.service) {
return;
}
this.hass.callService(
domain,
service,
this._serviceData!.data,
this._serviceData!.target
);
callExecuteScript(this.hass, [this._serviceData]);
}
private _toggleYaml() {