import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const eufyDomain = 'eufy';
export const eufyDefaultName = 'EufyHome';

export type TEufyRawData = TSimpleLocalRawData;
export interface IEufyConfiguredDevice {
  address: string;
  accessToken: string;
  type: string;
  name?: string;
}
export interface IEufySnapshot extends ISimpleLocalSnapshot {}
export interface IEufyConfig extends ISimpleLocalConfig {
  address?: string;
  accessToken?: string;
  code?: string;
  deviceType?: string;
  type?: string;
  devices?: IEufyConfiguredDevice[];
}
export interface IHomeAssistantEufyConfig extends IEufyConfig {}

export const eufyProfile: ISimpleLocalIntegrationProfile = {
  domain: eufyDomain,
  displayName: 'EufyHome',
  manufacturer: 'Eufy',
  model: 'EufyHome Device',
  defaultName: eufyDefaultName,
  defaultProtocol: 'local',
  status: 'control-runtime',
  platforms: [
    'light',
    'switch',
  ],
  serviceDomains: [
    'light',
    'switch',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
    'toggle',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'eufy',
    'eufyhome',
    'lakeside',
    'T1011',
    'T1012',
    'T1013',
    'T1201',
    'T1202',
    'T1203',
    'T1211',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/eufy',
    upstreamDomain: 'eufy',
    documentation: 'https://www.home-assistant.io/integrations/eufy',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'lakeside==0.13',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    loggers: [
      'lakeside',
    ],
    supportedDeviceTypes: {
      T1011: 'light',
      T1012: 'light',
      T1013: 'light',
      T1201: 'switch',
      T1202: 'switch',
      T1203: 'switch',
      T1211: 'switch',
    },
    homeAssistantPlatforms: [
      'light',
      'switch',
    ],
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
        'toggle',
      ],
      platforms: [
        'light',
        'switch',
      ],
      controls: true,
    },
    localApi: {
      implemented: [
        'manual local EufyHome device setup from address, access token, and device type metadata',
        'snapshot, raw data, snapshotProvider, and injected native client operation',
        'light and switch service dispatch only through injected client.execute or commandExecutor',
      ],
      explicitUnsupported: [
        'calling the lakeside device protocol directly without an injected native client',
        'cloud username/password device enumeration without a supplied snapshot or native client',
        'claiming live light or switch command success without injected client.execute or commandExecutor',
      ],
    },
  },
};
