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

export const ledBleDomain = "led_ble";
export const ledBleDefaultName = "LED BLE";

export type TLedBleRawData = TSimpleLocalRawData;
export interface ILedBleSnapshot extends ISimpleLocalSnapshot {}
export interface ILedBleConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}

export const ledBleProfile: ISimpleLocalIntegrationProfile = {
  domain: ledBleDomain,
  displayName: "LED BLE",
  manufacturer: "LED BLE",
  model: "LED BLE local integration",
  defaultName: ledBleDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "light",
  ],
  serviceDomains: [
    "light",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "led_ble",
    "LED BLE",
    "Led Ble",
    "LED",
    "BLE",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/led_ble",
    "upstreamDomain": "led_ble",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "bluetooth-data-tools==1.28.4",
      "led-ble==1.1.8",
    ],
    "dependencies": [
      "bluetooth_adapters",
    ],
    "codeowners": [
      "@bdraco",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/led_ble",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "light",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "No native live client is implemented: Home Assistant uses the led-ble Python library with bleak/Bluetooth GATT, and this repo has no BLE stack or documented LED BLE GATT implementation available in existing dependencies.",
      "implemented": [
        "manual local setup for LED BLE endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for LED BLE device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native LED BLE discovery, GATT polling, pairing, and writes because HA delegates that to the unavailable led-ble Python library and Bluetooth stack",
        "LEDnetWF devices because the Home Assistant flow explicitly aborts them as a different unsupported protocol",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
