AI_UIAutomation/config/device.config.ts

124 lines
3.3 KiB
TypeScript

import { getAddedDevice } from '../utils/common/device-registry.helper';
export interface DeviceCategoryConfig {
devices: string[];
defaultDevice: string;
}
export const DEVICE_CONFIG: Record<string, DeviceCategoryConfig> = {
bot: {
devices: ['Bot 0F'],
defaultDevice: 'Bot 0F',
},
camera: {
devices: ['摄像机Plus 3K', 'Pan Tilt', 'Pan Tilt Cam 2K', 'Pan Tilt Plus 2K', 'Pan Tilt Plus 3K', 'Indoor Cam'],
defaultDevice: '摄像机Plus 3K',
},
osc: {
devices: ['OSC 2K', 'Outdoor'],
defaultDevice: 'OSC 2K',
},
curtain: {
devices: ['Curtain 1A', 'Curtain3 2B', 'BlindTilt 3C'],
defaultDevice: 'Curtain 1A',
},
plug: {
devices: ['Plug 4D', 'PlugMini 5E', 'Plug Mini (JP)'],
defaultDevice: 'Plug 4D',
},
lock: {
devices: ['Lock 6F', 'LockPro 7G'],
defaultDevice: 'Lock 6F',
},
hub: {
devices: ['Hub2 8H', 'HubMini 9I', 'HubMiniMatter 0J', 'Hub Plus'],
defaultDevice: 'Hub2 8H',
},
humidifier: {
devices: ['Humidifier 1K', 'Humidifier2 2L'],
defaultDevice: 'Humidifier 1K',
},
meter: {
devices: ['Meter 3M', 'Meter Plus', 'Outdoor Meter 4N'],
defaultDevice: 'Meter 3M',
},
sensor: {
devices: ['Contact Sensor 5O', 'Motion Sensor 6P'],
defaultDevice: 'Contact Sensor 5O',
},
ceilingLight: {
devices: ['CeilingLight 7Q', 'Ceiling Light pro'],
defaultDevice: 'CeilingLight 7Q',
},
colorBulb: {
devices: ['ColorBulb 8R'],
defaultDevice: 'ColorBulb 8R',
},
stripLight: {
devices: ['StripLight 9S'],
defaultDevice: 'StripLight 9S',
},
fan: {
devices: ['Fan 0T'],
defaultDevice: 'Fan 0T',
},
waterDetector: {
devices: ['WaterDetector 1U'],
defaultDevice: 'WaterDetector 1U',
},
keypad: {
devices: ['Keypad 2V', 'Keypad Touch'],
defaultDevice: 'Keypad 2V',
},
remote: {
devices: ['Remote 3W'],
defaultDevice: 'Remote 3W',
},
airCondition: {
devices: ['AirCondition IR'],
defaultDevice: 'AirCondition IR',
},
findCard: {
devices: ['FindCard 4X'],
defaultDevice: 'FindCard 4X',
},
urc: {
devices: ['URC 5Y'],
defaultDevice: 'URC 5Y',
},
robot: {
devices: ['Robot S1', 'Robot S1P', 'Robot K10+', 'Robot S10'],
defaultDevice: 'Robot S1',
},
aihub: {
devices: ['AI Hub 6C'],
defaultDevice: 'AI Hub 6C',
},
aihubshow: {
devices: ['AI Hub Show'],
defaultDevice: 'AI Hub Show',
},
};
export function getDeviceName(category: string, envVar?: string): string {
if (envVar && process.env[envVar]) {
return process.env[envVar]!;
}
// 添加成功后写入的实际设备名(进入功能页入口),优先于配置默认值
const added = getAddedDevice(category);
if (added) return added;
return DEVICE_CONFIG[category]?.defaultDevice || category;
}
/**
* 型号名(用于 ONES 锚点解析等"按型号"的场景):env 覆盖 > 配置默认值。
* **不读注册表**——注册表是真机实际显示名(如 "Meter 0B"),而锚点表按型号名(如 "Meter 3M")建,
* 两者需区分:操作入口用 getDeviceName(实际名),锚点/型号用 getModelName(型号名)。
*/
export function getModelName(category: string, envVar?: string): string {
if (envVar && process.env[envVar]) {
return process.env[envVar]!;
}
return DEVICE_CONFIG[category]?.defaultDevice || category;
}