mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-21 02:07:21 +00:00
44 lines
949 B
TypeScript
44 lines
949 B
TypeScript
import type { HomeAssistant } from "../types";
|
|
|
|
export interface InputBoolean {
|
|
id: string;
|
|
name: string;
|
|
icon?: string;
|
|
initial?: boolean;
|
|
}
|
|
|
|
export interface InputBooleanMutableParams {
|
|
name: string;
|
|
icon: string;
|
|
initial: boolean;
|
|
}
|
|
|
|
export const fetchInputBoolean = (hass: HomeAssistant) =>
|
|
hass.callWS<InputBoolean[]>({ type: "input_boolean/list" });
|
|
|
|
export const createInputBoolean = (
|
|
hass: HomeAssistant,
|
|
values: InputBooleanMutableParams
|
|
) =>
|
|
hass.callWS<InputBoolean>({
|
|
type: "input_boolean/create",
|
|
...values,
|
|
});
|
|
|
|
export const updateInputBoolean = (
|
|
hass: HomeAssistant,
|
|
id: string,
|
|
updates: Partial<InputBooleanMutableParams>
|
|
) =>
|
|
hass.callWS<InputBoolean>({
|
|
type: "input_boolean/update",
|
|
input_boolean_id: id,
|
|
...updates,
|
|
});
|
|
|
|
export const deleteInputBoolean = (hass: HomeAssistant, id: string) =>
|
|
hass.callWS({
|
|
type: "input_boolean/delete",
|
|
input_boolean_id: id,
|
|
});
|