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

export const iperf3Domain = "iperf3";
export const iperf3DefaultName = "Iperf3";

export type TIperf3RawData = TSimpleLocalRawData;
export interface IIperf3Snapshot extends ISimpleLocalSnapshot {}
export interface IIperf3Config extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantIperf3Config extends IIperf3Config {}

export const iperf3Profile: ISimpleLocalIntegrationProfile = {
  domain: iperf3Domain,
  displayName: "Iperf3",
  manufacturer: "Iperf3",
  model: "Iperf3 local integration",
  defaultName: iperf3DefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [
    "speedtest",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "iperf3",
    "Iperf3",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/iperf3",
    "upstreamDomain": "iperf3",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "iperf3==0.1.11",
    ],
    "codeowners": [
      "@rohankapoorcom",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/iperf3",
    "loggers": [
      "iperf3",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "speedtest",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "No native iperf3 live client is implemented; Home Assistant uses the Python iperf3 package wrapping libiperf, and the documented setup requires the iperf3 OS command/libiperf rather than a simple HTTP/TCP JSON API.",
      "implemented": [
        "manual local setup for Iperf3 endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Iperf3 device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native iperf3 speed tests; Home Assistant depends on iperf3==0.1.11, which wraps libiperf.so/iperf3, and this repo has no libiperf binding or allowed iperf3 command wrapper",
        "implementing the iperf3 control/data protocol directly from TypeScript; it is not exposed by Home Assistant as a simple documented HTTP/TCP JSON protocol",
        "claiming live Iperf3 polling or speedtest success without an injected native client, commandExecutor, snapshotProvider, snapshot, or rawData",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
