import { Category } from '../Definitions/Global/Categories.js'; import { Family } from '../Definitions/Global/Families.js'; import type { Feature } from '../Definitions/Global/Features.js'; import type { PickOfType } from '../Utils.js'; import type * as Devices from './index.js'; // tslint:disable-next-line: no-unused-expression // tslint:disable-next-line: no-angle-bracket-type-assertion //type s = ISYDevice; //type DeviceNames = `${T extends Family.Insteon | Family.ZWave | Family.ZigBee ? StringKeyOf< : never}`; //type x = DeviceNames; type LabelFor = T extends Family.Insteon | Family.ZWave | Family.ZigBee ? PickOfType : never; export interface DeviceDef { id: number; type?: string; name: string; modelNumber?: string; //@ts-ignore class?: keyof (typeof Devices)[LabelFor]; features?: Feature; } export interface CategoryDef { id: C; name: string; devices: { [x: number]: DeviceDef }; } export interface FamilyDef { id: T; name: string; description: string; manufacturer?: string; categories: { [key in keyof typeof Category.Insteon]?: CategoryDef }; } /*var s : FamilyDef = { id: Family.Insteon, description: "Insteon", name: "Insteon", categories: {DimmableControl: {id: Category.Insteon.DimmableControl, name: "DimmableControl", devices: {1:{id: 0, name: "DimmableControl"}}}}};*/ export type DeviceMap = { [key in keyof typeof Family]?: FamilyDef<(typeof Family)[key]> & { name: key }; }; /*export function register(deviceMap: DeviceMap) { for (const key in deviceMap) { const element = deviceMap[key]; for (const catKey in element.categories) { for (const devKey in element.categories[catKey].devices) { const dev = element.categories[catKey].devices[devKey]; const device = Devices[key][dev.class as string]; if (device) { device.typeCodes.push(dev.type ?? dev.name); } } } } }*/