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

export const lifxDomain = "lifx";
export const lifxDefaultName = "LIFX";

export type TLifxRawData = TSimpleLocalRawData;
export interface ILifxSnapshot extends ISimpleLocalSnapshot {}
export interface ILifxConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantLifxConfig extends ILifxConfig {}

export const lifxProfile: ISimpleLocalIntegrationProfile = {
  domain: lifxDomain,
  displayName: "LIFX",
  manufacturer: "LIFX",
  model: "LIFX local integration",
  defaultName: lifxDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "button",
    "light",
    "select",
    "sensor",
  ],
  serviceDomains: [
    "button",
    "light",
    "select",
  ],
  controlServices: [
    "effect_colorloop",
    "effect_flame",
    "effect_morph",
    "effect_move",
    "effect_pulse",
    "effect_sky",
    "effect_stop",
    "paint_theme",
    "press",
    "select_option",
    "set_hev_cycle_state",
    "set_state",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "lifx",
    "LIFX",
    "Lifx",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/lifx",
    "upstreamDomain": "lifx",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "aiolifx==1.2.1",
      "aiolifx-effects==0.3.2",
      "aiolifx-themes==1.0.2",
    ],
    "dependencies": [
      "network",
    ],
    "codeowners": [
      "@Djelibeybi",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/lifx",
    "loggers": [
      "aiolifx",
      "aiolifx_effects",
      "bitstring",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "effect_colorloop",
        "effect_flame",
        "effect_morph",
        "effect_move",
        "effect_pulse",
        "effect_sky",
        "effect_stop",
        "paint_theme",
        "press",
        "select_option",
        "set_hev_cycle_state",
        "set_state",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "button",
        "light",
        "select",
        "sensor",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor; native live LIFX LAN control is blocked by the aiolifx UDP binary protocol/effects stack",
    },
    "localApi": {
      "status": "snapshot/injected-client only: Home Assistant uses aiolifx over the LIFX LAN UDP binary protocol on port 56700 plus aiolifx-effects/aiolifx-themes; no HTTP/TCP/TLS/file protocol is available to implement with the allowed runtime helpers",
      "implemented": [
        "manual local setup for LIFX snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for LIFX device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native live LIFX LAN polling/control: requires aiolifx UDP binary protocol implementation and effect/theme libraries, not an HTTP/TCP/TLS/file protocol available through existing helpers",
        "LIFX UDP broadcast discovery and HomeKit/DHCP confirmation flows that depend on aiolifx LIFXConnection",
        "claiming live LIFX polling, pairing, subscription, or write success without an injected native client or snapshotProvider",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
