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

export const greeDomain = 'gree';
export const greeDefaultName = 'Gree Climate';
export const greeDefaultPort = 7000;

export type TGreeRawData = TSimpleLocalRawData;
export interface IGreeSnapshot extends ISimpleLocalSnapshot {}
export interface IGreeConfig extends ISimpleLocalConfig {
  macAddress?: string;
}
export interface IHomeAssistantGreeConfig extends IGreeConfig {}

export const greeProfile: ISimpleLocalIntegrationProfile = {
  domain: 'gree',
  displayName: 'Gree Climate',
  manufacturer: 'Gree',
  model: 'Gree climate device',
  defaultName: greeDefaultName,
  defaultPort: greeDefaultPort,
  defaultProtocol: 'local',
  status: 'control-runtime',
  platforms: [
    'climate',
    'switch',
  ],
  serviceDomains: [
    'climate',
    'switch',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
    'toggle',
    'set_temperature',
    'set_hvac_mode',
    'set_fan_mode',
    'set_preset_mode',
    'set_swing_mode',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'gree',
    'gree climate',
    'greeclimate',
    'air conditioner',
    'hvac',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/gree',
    upstreamDomain: 'gree',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'greeclimate==2.1.1',
    ],
    dependencies: [
      'network',
    ],
    afterDependencies: [],
    codeowners: [
      '@cmroche',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/gree',
    loggers: [
      'greeclimate',
    ],
    defaults: {
      port: greeDefaultPort,
      discoveryScanIntervalSeconds: 300,
      discoveryTimeoutSeconds: 8,
      updateIntervalSeconds: 60,
      targetTemperatureStep: 1,
      fanModes: ['auto', 'low', 'medium low', 'medium', 'medium high', 'high'],
      presetModes: ['eco', 'away', 'boost', 'none', 'sleep'],
      swingModes: ['off', 'vertical', 'horizontal', 'both'],
    },
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
        'toggle',
        'set_temperature',
        'set_hvac_mode',
        'set_fan_mode',
        'set_preset_mode',
        'set_swing_mode',
      ],
      platforms: [
        'climate',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for discovered Gree device metadata, snapshots, rawData, snapshotProvider, and injected native clients',
        'runtime mapping for Gree climate state and panel light, quiet, fresh air, xfan, and health switches',
        'safe control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'UDP broadcast discovery and device binding without an injected client or snapshotProvider',
        'claiming HVAC or switch command success without an injected client.execute or commandExecutor',
      ],
    },
  },
};
