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

export const oppleDomain = "opple";
export const oppleDefaultName = "Opple";

export type TOppleRawData = TSimpleLocalRawData;
export interface IOppleSnapshot extends ISimpleLocalSnapshot {}
export interface IOppleConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOppleConfig extends IOppleConfig {}

export const oppleProfile: ISimpleLocalIntegrationProfile = {
  domain: oppleDomain,
  displayName: "Opple",
  manufacturer: "Opple",
  model: "Opple local integration",
  defaultName: oppleDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "light",
  ],
  serviceDomains: [
    "light",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "opple",
    "Opple",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/opple",
    "upstreamDomain": "opple",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "pyoppleio-legacy==1.0.8",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/opple",
    "loggers": [
      "pyoppleio",
    ],
    "runtime": {
      "type": "control-runtime",
      "blocker": "HA delegates live Opple access to pyoppleio-legacy, which uses a UDP-only reverse-engineered binary protocol with CRC16/encrypted payloads; no HTTP/TCP/TLS/file API is documented for native TypeScript support.",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "light",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "blocked-udp-only-undocumented-binary-protocol",
      "implemented": [
        "manual local setup for Opple endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Opple device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native live Opple polling/control because HA uses pyoppleio-legacy OppleLightDevice over socket.SOCK_DGRAM UDP broadcast/device datagrams, not HTTP/TCP/TLS/file",
        "reimplementing the pyoppleio-legacy reverse-engineered binary protocol with CRC16/encrypted payloads without an existing TypeScript dependency",
        "claiming live Opple 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",
      ],
    },
  },
};
