export interface IZwaveJsConfig {
  url?: string;
  schemaVersion?: number;
  version?: IZwaveJsVersion;
  state?: IZwaveJsState;
  nodes?: IZwaveJsNode[];
  controller?: IZwaveJsController;
}

export interface IZwaveJsVersion {
  type?: 'version';
  driverVersion?: string;
  serverVersion?: string;
  homeId?: number;
  minSchemaVersion?: number;
  maxSchemaVersion?: number;
}

export interface IZwaveJsState {
  driver?: Record<string, unknown>;
  controller?: IZwaveJsController;
  nodes?: IZwaveJsNode[];
}

export interface IZwaveJsController {
  homeId?: number;
  ownNodeId?: number;
  status?: string;
  isUsingHomeIdFromOtherNetwork?: boolean;
  statistics?: Record<string, unknown>;
  [key: string]: unknown;
}

export interface IZwaveJsNode {
  nodeId: number;
  id?: number;
  name?: string;
  location?: string;
  status?: string;
  ready?: boolean;
  isControllerNode?: boolean;
  manufacturer?: string;
  manufacturerId?: number;
  productLabel?: string;
  productDescription?: string;
  productId?: number;
  productType?: number;
  firmwareVersion?: string;
  deviceConfig?: Record<string, unknown>;
  values?: Record<string, IZwaveJsValue> | IZwaveJsValue[];
  [key: string]: unknown;
}

export interface IZwaveJsValueId {
  commandClass: number;
  endpoint?: number;
  property: string | number;
  propertyKey?: string | number;
}

export interface IZwaveJsValueMetadata {
  label?: string;
  type?: string;
  readable?: boolean;
  writeable?: boolean;
  unit?: string;
  states?: Record<string, string>;
  min?: number;
  max?: number;
  [key: string]: unknown;
}

export interface IZwaveJsValue {
  id?: string;
  nodeId?: number;
  commandClass?: number;
  commandClassName?: string;
  endpoint?: number;
  property?: string | number;
  propertyName?: string;
  propertyKey?: string | number;
  propertyKeyName?: string;
  metadata?: IZwaveJsValueMetadata;
  value?: unknown;
  [key: string]: unknown;
}

export interface IZwaveJsSnapshot {
  version?: IZwaveJsVersion;
  controller?: IZwaveJsController;
  nodes: IZwaveJsNode[];
  events: IZwaveJsServerEvent[];
  connected: boolean;
  url?: string;
}

export interface IZwaveJsServerCommand {
  command: string;
  [key: string]: unknown;
}

export interface IZwaveJsServerEvent {
  source?: string;
  event?: string;
  nodeId?: number;
  valueId?: IZwaveJsValueId;
  value?: unknown;
  newValue?: unknown;
  [key: string]: unknown;
}

export interface IZwaveJsMdnsRecord {
  type?: string;
  name?: string;
  host?: string;
  port?: number;
  txt?: Record<string, string | undefined>;
}

export interface IZwaveJsUsbRecord {
  vid?: string;
  pid?: string;
  manufacturer?: string;
  description?: string;
  path?: string;
  serialNumber?: string;
}

export interface IZwaveJsManualEntry {
  url?: string;
  host?: string;
  port?: number;
  usbPath?: string;
  id?: string;
  name?: string;
  model?: string;
  metadata?: Record<string, unknown>;
}
