16 lines
688 B
TypeScript
16 lines
688 B
TypeScript
import type { HomeAssistantDiscoveredDevice } from '../services/health'
|
|
|
|
const legacyCategories: Record<string, string> = {
|
|
EnvironmentControl: 'dehumidifier', Lighting: 'lighting', Media: 'audio',
|
|
Fragrance: 'fragrance', EnvironmentSensor: 'environment',
|
|
}
|
|
|
|
/** 新接口未绑定模块时不借用另一台同类设备的参数;仅兼容旧接口没有 moduleKey 的情况。 */
|
|
export function deviceModuleKey(device: HomeAssistantDiscoveredDevice): string {
|
|
return device.moduleKey === undefined ? legacyCategories[device.category] ?? '' : device.moduleKey
|
|
}
|
|
|
|
export function deviceDetailLocation(deviceId: string) {
|
|
return { name: 'device-detail', params: { deviceId } }
|
|
}
|