This commit is contained in:
fuenmao
2026-09-21 16:52:32 +08:00
parent 8ce6bec02d
commit 23cae3fda9
3 changed files with 123 additions and 7 deletions
+43 -1
View File
@@ -47,6 +47,42 @@ export type Dashboard = {
currentPlan?: HealthPlan
}
export type HomeAssistantDevice = {
code: string
name: string
entityId: string
state: string
value?: string
unit?: string
isAvailable: boolean
lastUpdated?: string
}
export type HomeAssistantStatus = {
connected: boolean
message: string
checkedAt: string
devices: HomeAssistantDevice[]
environment: HomeAssistantDevice[]
}
export type HomeAssistantSceneAction = {
name: string
entityId: string
status: string
message: string
}
export type HomeAssistantSceneResult = {
sceneCode: string
sceneName: string
success: boolean
status: string
message: string
executedAt: string
actions: HomeAssistantSceneAction[]
}
export const healthApi = {
register: (payload: { phone: string; password: string; displayName: string }) =>
http.post<never, AuthOutput>('/api/health/auth/register', payload),
@@ -57,5 +93,11 @@ export const healthApi = {
http.put<never, HealthProfile>('/api/health/profile', payload),
saveModules: (moduleCodes: string[]) =>
http.put<never, string[]>('/api/health/modules', { moduleCodes }),
generatePlan: () => http.post<never, HealthPlan>('/api/health/plans/generate')
generatePlan: () => http.post<never, HealthPlan>('/api/health/plans/generate'),
homeAssistantStatus: () =>
http.get<never, HomeAssistantStatus>('/api/health/home-assistant/status'),
executeSleepScene: () =>
http.post<never, HomeAssistantSceneResult>('/api/health/home-assistant/scenes/sleep'),
executeAllOffScene: () =>
http.post<never, HomeAssistantSceneResult>('/api/health/home-assistant/scenes/all-off')
}