This commit is contained in:
fuenmao
2026-09-22 15:03:13 +08:00
parent 426eaca97f
commit dec3dfdfe3
9 changed files with 3341 additions and 4 deletions
+80 -1
View File
@@ -40,11 +40,63 @@ export type HealthPlan = {
items: PlanItem[]
}
export type PersonalizedSceneConfig = {
targetHumidity: number
dehumidifierMode: string
fanLevel: string
enableUv: boolean
lightBrightnessPercent: number
lightColorTemperatureKelvin: number
mattressTargetTemp: number
mattressLeftFirmness: number
mattressRightFirmness: number
mattressHeatingLevel: number
mattressMode: string
enableFragrance: boolean
fragranceLevel: number
enableSpeakerSleepMode: boolean
speakerAudioMode: string
speakerVolumePercent: number
}
export type HealthAssessmentAnswers = {
sleepDuration: string
fallingAsleepSpeed: string
temperaturePreference: string
nightAwakening: string
mattressPreference: string
exerciseFrequency: string
muscleFatigueArea: string
activeTimeOfDay: string
mealRegularity: string
flavorPreference: string
lateNightEating: string
dailyWaterIntake: string
}
export type SaveHealthAssessmentInput = {
basicInfo: HealthProfile
answers: HealthAssessmentAnswers
}
export type HealthAssessmentOutput = {
hasCompletedAssessment: boolean
basicInfo: HealthProfile
answers: HealthAssessmentAnswers
sceneConfig: PersonalizedSceneConfig
bmi?: number | null
bmiStatus: string
}
export type Dashboard = {
user: HealthUser
profile?: HealthProfile
selectedModules: string[]
currentPlan?: HealthPlan
hasCompletedAssessment: boolean
bmi?: number | null
bmiStatus?: string
sceneConfig?: PersonalizedSceneConfig
}
export type HealthDeviceCategory =
@@ -131,6 +183,14 @@ export type HomeAssistantStatus = {
sceneDevices: HomeAssistantSceneDevicesSummary
environment: HomeAssistantEnvironmentData
scenePresets?: HomeAssistantScenePreset[]
controlParameters?: Record<string, HomeAssistantParameterState>
}
export type HomeAssistantParameterState = {
entityId: string
state: string
available: boolean
attributes?: Record<string, unknown>
}
export type HomeAssistantSceneAction = {
@@ -150,6 +210,20 @@ export type HomeAssistantSceneResult = {
actions: HomeAssistantSceneAction[]
}
export type HomeAssistantSetParameterInput = {
deviceId: string
entityId?: string
parameterType: string
value: unknown
}
export type HomeAssistantSetParameterOutput = {
success: boolean
deviceId: string
parameterType: string
message: string
}
export const healthApi = {
register: (payload: { phone: string; password: string; displayName: string }) =>
http.post<never, AuthOutput>('/api/health/auth/register', payload),
@@ -161,6 +235,9 @@ export const healthApi = {
saveModules: (moduleCodes: string[]) =>
http.put<never, string[]>('/api/health/modules', { moduleCodes }),
generatePlan: () => http.post<never, HealthPlan>('/api/health/plans/generate'),
getAssessment: () => http.get<never, HealthAssessmentOutput>('/api/health/assessment'),
saveAssessment: (payload: SaveHealthAssessmentInput) =>
http.post<never, HealthAssessmentOutput>('/api/health/assessment', payload),
homeAssistantStatus: () =>
http.get<never, HomeAssistantStatus>('/api/health/home-assistant/status'),
executeSleepScene: () =>
@@ -168,5 +245,7 @@ export const healthApi = {
executeAllOffScene: () =>
http.post<never, HomeAssistantSceneResult>('/api/health/home-assistant/scenes/all-off'),
switchDevice: (payload: { deviceId: string; turnOn: boolean; entityId?: string }) =>
http.post<never, HomeAssistantDeviceSwitchOutput>('/api/health/home-assistant/devices/switch', payload)
http.post<never, HomeAssistantDeviceSwitchOutput>('/api/health/home-assistant/devices/switch', payload),
setParameter: (payload: HomeAssistantSetParameterInput) =>
http.post<never, HomeAssistantSetParameterOutput>('/api/health/home-assistant/devices/set-parameter', payload)
}