mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-22 12:27:19 +00:00
49 lines
980 B
TypeScript
49 lines
980 B
TypeScript
import { HomeAssistant } from "../types";
|
|
|
|
export interface Person {
|
|
id: string;
|
|
name: string;
|
|
user_id?: string;
|
|
device_trackers?: string[];
|
|
picture?: string;
|
|
}
|
|
|
|
export interface PersonMutableParams {
|
|
name: string;
|
|
user_id: string | null;
|
|
device_trackers: string[];
|
|
picture: string | null;
|
|
}
|
|
|
|
export const fetchPersons = (hass: HomeAssistant) =>
|
|
hass.callWS<{
|
|
storage: Person[];
|
|
config: Person[];
|
|
}>({ type: "person/list" });
|
|
|
|
export const createPerson = (
|
|
hass: HomeAssistant,
|
|
values: PersonMutableParams
|
|
) =>
|
|
hass.callWS<Person>({
|
|
type: "person/create",
|
|
...values,
|
|
});
|
|
|
|
export const updatePerson = (
|
|
hass: HomeAssistant,
|
|
personId: string,
|
|
updates: Partial<PersonMutableParams>
|
|
) =>
|
|
hass.callWS<Person>({
|
|
type: "person/update",
|
|
person_id: personId,
|
|
...updates,
|
|
});
|
|
|
|
export const deletePerson = (hass: HomeAssistant, personId: string) =>
|
|
hass.callWS({
|
|
type: "person/delete",
|
|
person_id: personId,
|
|
});
|