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

export const hueBleDomain = 'hue_ble';
export const hueBleDefaultName = 'Philips Hue BLE';
export const hueBleServiceUuid = '0000fe0f-0000-1000-8000-00805f9b34fb';

export type THueBleRawData = TSimpleLocalRawData;
export interface IHueBleSnapshot extends ISimpleLocalSnapshot {}
export interface IHueBleConfig extends ISimpleLocalConfig {
  address?: string;
  mac?: string;
  model?: string;
}
export interface IHomeAssistantHueBleConfig extends IHueBleConfig {}

export const hueBleProfile: ISimpleLocalIntegrationProfile = {
  domain: 'hue_ble',
  displayName: 'Philips Hue BLE',
  manufacturer: 'Philips Hue',
  model: 'Hue BLE light',
  defaultName: hueBleDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'light',
  ],
  serviceDomains: [
    'light',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
  ],
  discoverySources: [
    'manual',
    'bluetooth',
    'custom',
  ],
  discoveryKeywords: [
    'hue',
    'philips hue',
    'hue ble',
    hueBleServiceUuid,
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hue_ble',
    upstreamDomain: 'hue_ble',
    integrationType: 'device',
    iotClass: 'local_push',
    qualityScale: 'bronze',
    requirements: [
      'HueBLE==2.2.2',
    ],
    dependencies: [
      'bluetooth_adapters',
    ],
    afterDependencies: [],
    codeowners: [
      '@flip-dots',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/hue_ble',
    loggers: [
      'bleak',
      'HueBLE',
    ],
    bluetooth: [
      {
        connectable: true,
        service_data_uuid: hueBleServiceUuid,
        service_uuid: hueBleServiceUuid,
      },
    ],
    urls: {
      pairingMode: 'https://www.home-assistant.io/integrations/hue_ble#initial-setup',
      factoryReset: 'https://www.philips-hue.com/en-gb/support/article/how-to-factory-reset-philips-hue-lights/000004',
    },
    platforms: [
      'light',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
      ],
      platforms: [
        'light',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual Bluetooth setup from discovered device metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime light snapshot mapping for Hue BLE state, brightness, color temperature, and XY color attributes',
        'safe Hue BLE control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'active BLE pairing, connection management, and notification subscriptions without an injected native client',
        'claiming turn_on or turn_off success without injected client.execute or commandExecutor',
        'Home Assistant Bluetooth scanner selection and device registry side effects',
      ],
    },
  },
};
