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

export const ihcDomain = 'ihc';
export const ihcDefaultName = 'IHC Controller';

export type TIhcRawData = TSimpleLocalRawData;
export interface IIhcSnapshot extends ISimpleLocalSnapshot {}
export interface IIhcConfig extends ISimpleLocalConfig {
  url?: string;
  autoSetup?: boolean;
  info?: boolean;
  controllerId?: string;
}
export interface IHomeAssistantIhcConfig extends IIhcConfig {}

export const ihcProfile: ISimpleLocalIntegrationProfile = {
  domain: ihcDomain,
  displayName: 'IHC Controller',
  manufacturer: 'Schneider Electric',
  model: 'IHC Controller',
  defaultName: ihcDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'light',
    'sensor',
    'switch',
  ],
  serviceDomains: [
    'light',
    'switch',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
    'set_runtime_value_bool',
    'set_runtime_value_float',
    'set_runtime_value_int',
    'pulse',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'ihc',
    'IHC Controller',
    'schneider',
    'LK IHC',
    'runtime value',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/ihc',
    upstreamDomain: 'ihc',
    iotClass: 'local_push',
    qualityScale: 'legacy',
    requirements: [
      'defusedxml==0.7.1',
      'ihcsdk==2.8.5',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/ihc',
    loggers: [
      'ihcsdk',
    ],
    homeAssistantPlatforms: [
      'binary_sensor',
      'light',
      'sensor',
      'switch',
    ],
    services: [
      'set_runtime_value_bool',
      'set_runtime_value_float',
      'set_runtime_value_int',
      'pulse',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
        'set_runtime_value_bool',
        'set_runtime_value_float',
        'set_runtime_value_int',
        'pulse',
      ],
      platforms: [
        'binary_sensor',
        'light',
        'sensor',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual controller setup from URL credentials metadata, snapshots, rawData, snapshotProvider, and injected native clients',
        'runtime mapping for IHC binary sensor, light, sensor, and switch snapshots',
        'safe runtime value and pulse service delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'authenticating to IHC controllers or reading project XML without an injected native client or snapshotProvider',
        'Home Assistant YAML auto setup and manual setup discovery loading',
        'claiming runtime value, pulse, light, or switch write success without injected client.execute or commandExecutor',
      ],
    },
  },
};
