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

export const elvDomain = 'elv';
export const elvDefaultName = 'ELV PCA';

export type TElvRawData = TSimpleLocalRawData;
export interface IElvSnapshot extends ISimpleLocalSnapshot {}
export interface IElvConfig extends ISimpleLocalConfig {
  device?: string;
}
export interface IHomeAssistantElvConfig extends IElvConfig {}

const elvControlServices = [
  'toggle',
  'turn_off',
  'turn_on',
];

export const elvProfile: ISimpleLocalIntegrationProfile = {
  domain: 'elv',
  displayName: 'ELV PCA',
  manufacturer: 'ELV',
  model: 'PCA 301',
  defaultName: elvDefaultName,
  defaultProtocol: 'local',
  status: 'control-runtime',
  platforms: [
    'switch',
  ],
  serviceDomains: [
    'switch',
  ],
  controlServices: elvControlServices,
  discoverySources: [
    'manual',
    'usb',
    'custom',
  ],
  discoveryKeywords: [
    'elv',
    'pca',
    'pca 301',
    'smart plug',
    'serial',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/elv',
    upstreamDomain: 'elv',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'pypca==0.0.7',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@majuss',
    ],
    configFlow: false,
    defaultDevice: '/dev/ttyUSB0',
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...elvControlServices,
      ],
      platforms: [
        'switch',
      ],
      controls: true,
    },
    localApi: {
      implemented: [
        'manual serial device setup, snapshots, raw data, snapshotProvider, and injected native clients',
        'executor-gated PCA 301 switch service dispatch',
      ],
      explicitUnsupported: [
        'claiming PCA switch command success without injected client.execute or commandExecutor',
        'opening pypca serial sessions without an injected native client',
        'cloud account flows and remote API polling',
      ],
    },
  },
};
