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

export const gogogate2Domain = 'gogogate2';
export const gogogate2DefaultName = 'Gogogate2 and ismartgate';

export type TGogogate2RawData = TSimpleLocalRawData;
export interface IGogogate2Snapshot extends ISimpleLocalSnapshot {}
export interface IGogogate2Config extends ISimpleLocalConfig {
  ipAddress?: string;
  ip_address?: string;
  device?: 'gogogate2' | 'ismartgate' | string;
}
export interface IHomeAssistantGogogate2Config extends IGogogate2Config {}

export const gogogate2Profile: ISimpleLocalIntegrationProfile = {
  domain: 'gogogate2',
  displayName: 'Gogogate2 and ismartgate',
  manufacturer: 'Remsol',
  model: 'Gogogate2/ismartgate',
  defaultName: gogogate2DefaultName,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'cover',
    'sensor',
  ],
  serviceDomains: [
    'cover',
    'sensor',
  ],
  controlServices: [
    'open_cover',
    'close_cover',
  ],
  discoverySources: [
    'manual',
    'dhcp',
    'mdns',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'gogogate2',
    'gogogate',
    'ismartgate',
    'garage',
    'gate',
    'door',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/gogogate2',
    upstreamDomain: 'gogogate2',
    integrationType: 'hub',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'ismartgate==5.0.2',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@vangorra',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/gogogate2',
    dhcp: [
      { hostname: 'ismartgate*' },
    ],
    homekit: {
      models: ['iSmartGate'],
    },
    loggers: [
      'ismartgate',
    ],
    homeAssistantPlatforms: [
      'cover',
      'sensor',
    ],
    defaults: {
      deviceTypes: ['gogogate2', 'ismartgate'],
      updateIntervalSeconds: 5,
      wiredSensorId: 'WIRE',
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'open_cover',
        'close_cover',
      ],
      platforms: [
        'cover',
        'sensor',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup plus DHCP/mDNS candidate matching',
        'runtime mapping for configured doors, cover states, sensor batteries, and sensor temperatures',
        'safe cover control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'direct ismartgate API calls from this TypeScript package',
        'claiming cover open or close success without an injected client.execute or commandExecutor',
        'HomeKit pairing and device-specific credential validation',
      ],
    },
  },
};
