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

export const egardiaDomain = 'egardia';
export const egardiaDefaultName = 'Egardia';
export const egardiaDefaultPort = 80;
export const egardiaDefaultVersion = 'GATE-01';

export type TEgardiaRawData = TSimpleLocalRawData;
export interface IEgardiaSnapshot extends ISimpleLocalSnapshot {}
export interface IEgardiaConfig extends ISimpleLocalConfig {
  version?: string;
  reportServerEnabled?: boolean;
  report_server_enabled?: boolean;
  reportServerPort?: number;
  report_server_port?: number;
  reportServerCodes?: Record<string, string[]>;
  report_server_codes?: Record<string, string[]>;
}
export interface IHomeAssistantEgardiaConfig extends IEgardiaConfig {}

export const egardiaProfile: ISimpleLocalIntegrationProfile = {
  domain: 'egardia',
  displayName: 'Egardia',
  manufacturer: 'Egardia',
  model: egardiaDefaultVersion,
  defaultName: egardiaDefaultName,
  defaultPort: egardiaDefaultPort,
  defaultProtocol: 'http',
  status: 'control-runtime',
  platforms: [
    'sensor',
    'binary_sensor',
  ],
  serviceDomains: [
    'alarm_control_panel',
  ],
  controlServices: [
    'alarm_disarm',
    'alarm_arm_home',
    'alarm_arm_away',
  ],
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'egardia',
    'woonveilig',
    'alarm',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/egardia',
    upstreamDomain: 'egardia',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'pythonegardia==1.0.52',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@jeroenterheerdt',
    ],
    configFlow: false,
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'alarm_disarm',
        'alarm_arm_home',
        'alarm_arm_away',
      ],
      platforms: [
        'sensor',
        'binary_sensor',
      ],
      controls: true,
    },
    localApi: {
      implemented: [
        'manual local host and credential setup',
        'snapshot, raw data, snapshotProvider, and injected native client operation',
        'Egardia alarm state and sensor snapshot mapping with commandExecutor-backed alarm control',
      ],
      explicitUnsupported: [
        'claiming live alarm command success without injected client.execute or commandExecutor',
        'starting the optional Egardia report server callback listener',
        'direct pythonegardia device operation without an injected native client',
      ],
    },
  },
};
