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

export const hdfuryDomain = 'hdfury';
export const hdfuryDefaultName = 'HDFury';
export const hdfuryDefaultPort = 80;

export type THdfuryRawData = TSimpleLocalRawData;
export interface IHdfurySnapshot extends ISimpleLocalSnapshot {}
export interface IHdfuryConfig extends ISimpleLocalConfig {}
export interface IHomeAssistantHdfuryConfig extends IHdfuryConfig {}

const hdfuryControlServices = [
  'turn_on',
  'turn_off',
  'toggle',
  'set_value',
  'select_option',
  'press',
];

export const hdfuryProfile: ISimpleLocalIntegrationProfile = {
  domain: hdfuryDomain,
  displayName: 'HDFury',
  manufacturer: 'HDFury',
  model: 'HDMI processor',
  defaultName: hdfuryDefaultName,
  defaultPort: hdfuryDefaultPort,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'button',
    'number',
    'select',
    'sensor',
    'switch',
  ],
  serviceDomains: [
    'button',
    'number',
    'select',
    'sensor',
    'switch',
  ],
  controlServices: hdfuryControlServices,
  discoverySources: [
    'manual',
    'mdns',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'hdfury',
    'diva',
    'vertex2',
    'vrroom',
    '_http._tcp.local.',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hdfury',
    upstreamDomain: 'hdfury',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: 'platinum',
    requirements: [
      'hdfury==1.6.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@glenndehaan',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/hdfury',
    zeroconf: [
      { name: 'diva-*', type: '_http._tcp.local.' },
      { name: 'vertex2-*', type: '_http._tcp.local.' },
      { name: 'vrroom-*', type: '_http._tcp.local.' },
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...hdfuryControlServices,
      ],
      platforms: [
        'button',
        'number',
        'select',
        'sensor',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local host setup for HDFury devices discovered by zeroconf',
        'snapshot, raw HDFury board/info/config data, snapshotProvider, and injected native client operation',
        'device, sensor, switch, number, select, and button mapping from Home Assistant HDFury data shapes',
      ],
      explicitUnsupported: [
        'calling hdfury Python package HTTP methods directly from this TypeScript package',
        'claiming live switch, number, select, or button command success without injected client.execute or commandExecutor',
      ],
    },
  },
};
