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

export const futurenowDomain = 'futurenow';
export const futurenowDefaultName = 'P5 FutureNow';

export type TFuturenowDriver = 'FNIP6x10ad' | 'FNIP8x10a';
export type TFuturenowRawData = TSimpleLocalRawData;
export interface IFuturenowSnapshot extends ISimpleLocalSnapshot {}
export interface IFuturenowConfig extends ISimpleLocalConfig {
  driver?: TFuturenowDriver | string;
  channels?: Record<string, { name: string; dimmable?: boolean }>;
}
export interface IHomeAssistantFuturenowConfig extends IFuturenowConfig {}

export const futurenowProfile: ISimpleLocalIntegrationProfile = {
  domain: futurenowDomain,
  displayName: 'P5 FutureNow',
  manufacturer: 'FutureNow',
  model: 'Ethernet output unit',
  defaultName: futurenowDefaultName,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'light',
  ],
  serviceDomains: [
    'light',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'futurenow',
    'p5',
    'fnip',
    'fnip6x10ad',
    'fnip8x10a',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/futurenow',
    upstreamDomain: 'futurenow',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'pyfnip==0.2',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/futurenow',
    defaults: {
      drivers: [
        'FNIP6x10ad',
        'FNIP8x10a',
      ],
      brightnessRange: [0, 255],
      deviceLevelRange: [0, 100],
    },
    platforms: [
      'light',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
      ],
      platforms: [
        'light',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for FutureNow host, port, driver, channel metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime light entity mapping for configured channel snapshots',
        'safe light control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native pyfnip FNIP socket output polling and writes in this TypeScript package',
        'claiming light turn_on or turn_off success without an injected client.execute or commandExecutor',
        'Home Assistant YAML light platform setup',
      ],
    },
  },
};
